Im extracting frames from video and plotting the slope value for the coordinates obtained in each line detected in each frame like below
Am plotting the “slope” value against “frames”.
Extracting frames from video
for k = 1 :240 %no.of frames
%Here in loop am extracting the line from each frame then
[ycoord,xcoord]=find(line);%finding the coordinates of line
Ymax(k)=max(ycoord);
Ymin(k)=min(ycoord);
Xmax(k)=max(xcoord);
Xmin(k)=min(xcoord);
slope(k)=(Ymax(k)-Ymin(k)/Xmax(k)-Xmin(k));
end;
plot(slope,'-ro');%plotting slope values of frames
But when there is no line found in a frame then find(line) is giving empty arrays and there is no slope calculated showing error .
My requirement is when there is no line in the next frame then the slope value should be zero else it should calculate the slope value.
can some one please help on this
I don’t really understand your code, but in general, when find can’t find something, it returns an empty matrix. You can use the
isemptyfunction to test if this is the case and manually setycoordandxcoordto values that won’t cause an error on.isempty() MATLAB Documentation
Hope this helps!