how do I detect object from a set of images

1 view (last 30 days)
I am trying to detect an object from an image.My code is as follows:
function tri=ball_detection()
% A= imread('greyscale.jpg');
B= rgb2gray(imread('C:\Users\Tipu_Standard\Desktop\MatlabhelpImage\original12.jpg'));
A=adapthisteq(B);
% Display the original image
figure,imshow(A);
distance =0;
angle=0;
rmin=8;
rmax=40;
% Find all the circles with radius >= 15 and radius <= 30
% [centersbright,radiibright] = imfindcircles(A,[rmin rmax],'Objectpolarity','bright');
[centersdark,radiidark] = imfindcircles(A,[rmin rmax],'Objectpolarity','dark');
k=numel(radiidark);
viscircles(centersdark,radiidark ,'EdgeColor','b');
if(k==0)
z=0;
else
z=1;
p=2*radiidark;
f=2.1;
w=62;
h=144;
s=2.88;
distance=(f*w*h)/(p*s);
a=(192/2)-centersdark(1);
b=144-centersdark(2);
angle=atan2(a,b)*(180/pi);
end
tri=[z,distance,angle];
end

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!