0

In my project, it needs recognise the square marrker in the real time video input. In every frame,the square marker should be recoginzed stability.And the following codes was used to detected the square marker.however,it cause error in same frames,and i have try many methods but still useless.

gray_img = rgb2gray(img);
bw_img= im2bw(gray_img,0.35);  
[B,L] = bwboundaries(bw_img,'noholes');
se1=strel('square',30);
L_erode=imerode(L,se1,'same'); 
stats =[regionprops(L_erode); regionprops(not(L_erode))];
A=[stats.Area];
idx=find(A==min(A(A~=0)));

the test image is here:

enter image description here

rayryeng
  • 102,964
  • 22
  • 184
  • 193
  • what error it causes? – Marcin Nov 10 '16 at 04:03
  • the codes return the centroid coordinate of the square marker, but in some frames, it return the wrong the coordinate. – Sherrysun Nov 10 '16 at 04:55
  • The lights are brighter than the square object so those will compute with your current method. – rayryeng Nov 10 '16 at 05:05
  • That is the problem.In this scenario, the strel function was used to detect all squares or rectangles in image regions.And i find in most frames, the position of square has the minimum area. hence, the centroid of the square can be derived. however,this algorithm is not accurate all the time.In some case, the minimum area does not corresponds to the position of the square. And i want to know how to get the accurate position of the square in this scenario. – Sherrysun Nov 10 '16 at 05:23
  • I'd segment this using histograms. This will work as long as the image looks like this most of the time (there are no extra black things in the screen). If there are you may be bale to improve the histogram segmentation – Ander Biguri Nov 10 '16 at 11:00

0 Answers0