You are on page 1of 10
Your task Find your “target” against a complex background Determine the distance to the target Determine the angle to the target Output those parameters so that your team can aim the ping pong launcher oa a FF WwW N= Image processing steps . Find the fiducials on your target . Measure the distance between them . Translate that into a calibrated distance from camera to target . Measure distance to the edge of the image . Translate that into an angle to the target . Export distances to launcher controls Size is relative to distance from the camera The change in size with distance is a percentage, you will have better resolution with bigger distances as your metric. Horizontal location can also be found from where the target is in the image. Both will need to be “calibrated” for your target and system. The problem with using a particular color as a target or background is that the same color can be mis-labeled. If the computer picks out a pixel as part of the color you are looking for, but it is NOT, that is a false positive. If the computer fails to see a pixel as part of the color you are looking for, but it WAS, then you have a false negative. So we will look at some techniques to help reduce these... ¢ To find color: — Check for pixels that might be your color — Use some built-in tools to get the important information To find circles: — Use built-in tools to find circles in a given radius range — Use built-in tools to get important information When looking for pixels of a certain color, break the image first into red, green and blue planes. r_channel=image(:,:,1); ime g_channel=image(:,:,2); b_channel=image(:,:,3); Blue plane Ratios of pixel colors are much more immune to changes in lighting than going for specific colors: gr_ratio=double(g_channel)./double(r_channel); % green red ratio - why the “.” 2 double=double precision (you are dividing integers and you want to force a decimal point) How would you do a green/blue ratio? gb_ratio=double(g_channel)./double(b_channel); % green blue ratio gr_ratio(isnan(g_ratio))=0; a i is NaN it sets it to zero -- this should only happen if it is lacl * This creates a logical array that says if a pixel meets criteria or not. In this case, is it “green” enough. g_bin=g_ratio>=1.1 && gb_ratio >=1.1; % if more green than red and more green than blue its pretty green In addition this now a black and white image Get rid of things that are two small (in this case less than 50 pixels): black_and_white_image_of_squares=bwareaopen(g_bin,50); % gets rid of object smaller than 50pixels area Thresholds: ThrBlue = imbinarize(|_Blue, levelb); f New image t : Threshold can remove ee Black and Value between sone backs cand an oot ae whitelmage “San some background and set white the image to just black ce and white. 2. OOM 800? er | Blue ThrBlue For non-round objects: square_bounding_boxes = regionprops(black_and_white_image_of_squares, 'BoundingBox’); % get bounding box for all object we have For round objects: [centers, radii] = imfindcircles(Thrsum,[R1. R2]) cs Image to look Toreircles in c = viscircles(centers,radii);

You might also like