function smart_motion() global vid gray_picture rgb_picture global T_Point target_point global CMin_X CMin_Y CMax_X CMax_Y while(1) %standart işlemler preview(vid); rgb_picture = getsnapshot(vid); gray_picture = rgb2gray(rgb_picture); imshow(gray_picture) %Resmin belirli bir sınır dahilinde taranması for x=CMin_X:CMax_X for y=CMin_Y:CMax_Y pixel_value = gray_picture(y,x); if (pixel_value > T_Point) target_point = [x y] calculate_new_border(); break; end end %ikincil kontrol if (pixel_value > T_Point) target_point = [x y] calculate_new_border(); break; end end %hedef çiz veya dön if (pixel_value > T_Point) display_target(); else return; end end end