finding points in a video
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a video of a series of footballs. I have plotted the centroids of each football in each frame, which has allowed me to work out translation.
I am trying to work out if it is possible to find another point on the footballs, for example the centre of the black pentagons, which will let me work out rotation.
Does anybody know if this is possible?
%Track the particles and plot velocity for t and t+1 (frames 1 + 2)
for loop = 1:numFrames;
%binarize frames 1 and 2 from the video (using rgb2gray)
frame_1 = rgb2gray(read(obj,loop+start_frame-1));
frame_2 = rgb2gray(read(obj,loop+start_frame));
%identify the circles in frames 1 and 2 with radii between the defined min and max
centres_1 =imfindcircles(frame_1,[min_radius,max_radius],'Sensitivity',quality,'Method','TwoStage');
centres_2 =imfindcircles(frame_2,[min_radius,max_radius],'Sensitivity',quality,'Method','TwoStage');
% dsearchm returns the indicies of the closest points in the 2 vectors
% identifies where each centroid has moved between frames 1 and 2
[index,dist] = dsearchn(centres_2,centres_1);
% here we have the distances not in order
% assign the centres from frames 1 and 2 to x and y coordinate variables
x_1{loop} = centres_1(:,1);
x_2{loop} = centres_2(index,1);
y_1{loop} = centres_1(:,2);
y_2{loop} = centres_2(index,2);
% now we compute the translational velocity as s = d/t
vel_x{loop} = (x_2{loop}-x_1{loop})/t; %x velocity using frame 2 - frame 1
vel_y{loop} = (y_2{loop}-y_1{loop})/t; %y velocity using frame 2 - frame 1
vel_res{loop} = sqrt(vel_x{loop}.^2 + vel_y{loop}.^2); %the final velocity vector as a function as its x and y components
% now we can make a overall velocity, by reshaping the array
% for all the columns in 'loop', reshape the array 'griddata' to define, size U, V and RES
U(:,:,loop)=reshape(griddata(x_1{loop},y_1{loop},vel_x{loop},X(:),Y(:)),size(X,1),size(X,2));
V(:,:,loop)=reshape(griddata(x_1{loop},y_1{loop},vel_y{loop},X(:),Y(:)),size(X,1),size(X,2));
RES(:,:,loop)=reshape(griddata(x_1{loop},y_1{loop},vel_res{loop},X(:),Y(:)),size(X,1),size(X,2));
end

0 commentaires
Réponse acceptée
Image Analyst
le 11 Mai 2020
Modifié(e) : Image Analyst
le 11 Mai 2020
You can use regionprops() to find the centers of the black pentagons:
binaryImage = grayImage < someGrayLevel;
binaryImage = imclearborder(binaryImage); % Get rid of surrounding black stuff.
binaryImage = bwareafilt(binaryImage, [100, inf]); % Extract only blobs bigger than 100 pixels.
props = regionprops(binaryImage, 'Centroid', 'Area')
xy = vertcat(props.Centroid)
Adapt as needed.
3 commentaires
Image Analyst
le 12 Mai 2020
I don't know because I have never heard of or used the dsearchn() function, so you know more than me about it now.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Computer Vision with Simulink dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!