Novice at image processing, need help with tracking circles in a video

15 views (last 30 days)
Hi, I have been trying to track the circles glued onto the limbs of the robot in the video. I tried using imfindcircles and played around with different options, but it doesn't seem to work in my case, since the circles being picked up by the program, are all over the place, I then moved to edge detection and centroid finding, and again I can't seem to have the desired tracking. I would ideally like to have information about the center of the 3 links that make the robot. This is the script, I am using to find the centroids.
clear all
clc
v=VideoReader('Translation.mp4');
a=read(v,107);
figure(1)
imagesc(a);
%[centers,radii]=imfindcircles(a,[10 20],'ObjectPolarity','bright','Sensitivity',0.95,'EdgeThreshold',0.068);
%viscircles(centers,radii)
A=rgb2gray(a);
figure(2)
imshow(A)
%mask=false(size(A,1),size(A,2));
%mask(300:700,700:1100)=true;
%bw=activecontour(A,mask,300,'edge');
%figure(3)
%imshow(bw)
A(1:140,:)=0;
A(950:end,:)=0;
A(:,1:325)=0;
A(:,1400:end)=0;
[~,threshold]=edge(A,'sobel');
fudgeFactor=0.7;
BWs=edge(A,'sobel',fudgeFactor*threshold);
figure(4)
imshow(BWs)
se90=strel('line',10,90);
se0=strel('line',10,0);
BWsdil=imdilate(BWs,[se90 se0]);
%BWnobord=imclearborder(BWsdil,8);
seD=strel('diamond',5);
BWfinal=imerode(BWsdil,seD);
BWfinal=imerode(BWfinal,seD);
s=regionprops(BWfinal,'centroid');
centroids=cat(1,s.Centroid);
figure(6)
imshow(BWfinal)
hold on
plot(centroids(:,1),centroids(:,2),'b*')
hold off
I am attaching the still image from one of the video frames and my results after doing findcircles and edge detection, I would appreciate any help that you guys can offer.

Answers (1)

Yash Ubale
Yash Ubale on 14 Nov 2018
Hello,
So your basic requirement is to track the circles in a continous video frame, right? I would suggest you to have a look at the examples and links mentioned below.
You can track points which correspond to these circles using Kanade-Lucas-Tomasi (KLT) algorithm as mentioned below.
The underlying idea is to set a reference image which in your case is the arm / corner which contains the circles. You can also refer to the example mentioned below in which a part of the webinar discusses the same.

Community Treasure Hunt

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

Start Hunting!