I have an input video : badminton edit 1.wmv. This video contains 228 frames with few frames without badminton court. How to make this code to reject all the frames that doesnt have badminton court? Can anyone solve this? Thanks in advance.

%if true
% code
%end
videoReader = vision.VideoFileReader('badminton edit 1.wmv');
writerObj = VideoWriter('Court Detection Trial.avi','Uncompressed AVI');
while ~isDone(videoReader)
frame = step(videoReader);
I = double(frame);
%colorThresholder(I)
% I = imread('court2.jpg');
M = size(I,1);
N = size(I,2);
T = 1.25; % try with different T values to see how it affects the thresholding
BW = uint8(zeros(M,N));
for i=1:M
for j=1:N
if (I(i,j,2)>T*I(i,j,1)) && (I(i,j,2)>T*I(i,j,3))
BW(i,j) = 255;
end
end
end
BW = im2bw(BW);
BW_filled = imfill(BW,'holes');
dim = size(BW);
col = round(dim(2)/2)-90;
row = min(find(BW(:,col)));
if (row > 0)
boundary = bwtraceboundary(BW,[row, col],'N');
hold on;
plot(boundary(:,2),boundary(:,1),'g','LineWidth',3);
end
open(writerObj)
imshow(BW_filled)
F = getframe(gcf);
writeVideo(writerObj,F);
hold on
end
close(writerObj);

1 Commento

Can you post some frames with the court and without the court? Is the video in color? Does the court have a distinctive color?

Accedi per commentare.

Risposte (0)

Richiesto:

il 8 Lug 2014

Commentato:

il 22 Lug 2014

Community Treasure Hunt

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

Start Hunting!

Translated by