The research is based on Tennis and to help umpires to get correct decisions or automate umpires' decisions using image processing.
The most important task of this research is to track the tennis ball.
Two sample videos were taken (Not an actual tennis ground).
`frameLength` is the number of frames.
- Top video (To identify ball is inside or outside.)
- Surface video (To identify the ball when the ball touches the ground.)
`frameLength` is the number of frames.
while(k < frameLength) k=k+1; aFrame = read(sufCam, k); I1 =rgb2gray(aFrame); J=im2double(I1); H1=medfilt2(J,[3,3]); i1=imadjust(H1); ia =i1 >0.98; H0 = read(topCam, k); axes(handles.axes1); imshow(H0); axes(handles.axes2); imshow(H1); [Label,total] = bwlabel(ia,4); for i=1:total if(sum(sum(Label==i)) < 200 ) Label(Label==i)=0; end end Sdata1 = regionprops(Label,'all'); Un=unique(Label); my_max=0.0; for i=2:numel(Un) Roundness=(4*pi*Sdata1(Un(i)).Area)/Sdata1(Un(i)).Perimeter.^2; my_max=max(my_max,Roundness); if(Roundness==my_max) ele=Un(i); end end cen=Sdata1(ele).Centroid; if(k>1 && posy > cen(1,2)) disp(k); disp(cen(1,2)); k=nFrames; %imshow(H1); axes(handles.axes2); imshow(H1); hold on; plot(cen(1,1),cen(1,2),'rx'); g=rgb2gray(H0); j=im2double(g); k=medfilt2(j,[3,3]); i2=imadjust(k); ib =i2 >0.7; [Label,total] = bwlabel(ib,4); for i=1:total if(sum(sum(Label==i)) < 200 ) Label(Label==i)=0; end end Sdata = regionprops(Label,'all'); Un=unique(Label); my_max=0.0; for i=2:numel(Un) Roundness=(4*pi*Sdata(Un(i)).Area)/Sdata(Un(i)).Perimeter.^2; my_max=max(my_max,Roundness); if(Roundness==my_max) ele=Un(i); end end cen2=Sdata(ele).Centroid; axes(handles.axes1); imshow(H0); hold on plot(cen2(1,1),cen2(1,2),'rx'); disp(cen2(1,1)); disp(cen2(1,2)); textLabel = sprintf('X value = %f', cen2(1,1)); set(handles.text5, 'String', textLabel); textLabel = sprintf('Y value = %f', cen2(1,2)); set(handles.text6, 'String', textLabel); global border holdt; border = str2double(get(handles.edit1,'string')); % check whether ball inside or not if(cen2(1,2) < border && holdt ==1) set(handles.text9, 'String', 'IN'); end if(cen2(1,2) < border && holdt ==0) set(handles.text9, 'String', 'OUT'); end if(cen2(1,2) > border && holdt ==0) set(handles.text9, 'String', 'IN'); end if(cen2(1,2) > border && holdt ==1) set(handles.text9, 'String', 'OUT'); end end posy = cen(1,2); textLabel = sprintf('Y value = %f', cen(1,2)); set(handles.text4, 'String', textLabel); disp(cen(1,2)); %disp(cen(1,2)); end