Using an if statement to monitor image tracking and want to return to back to the User input when the if statement is met

1 view (last 30 days)
Helo,
I am currently writing code for a program that loads in a video file and tracks a blue and green dot in the video. I have the program prompt the user to zoom in on a selected area of the video by displaying the first frame of the video and using ginput. I then have the user select a region of pixels to track again by using ginput. This serves to calculate the area of same pixels to track. (i.e. if the area of the box created from the 2 clicks in ginput is 130, it will track a grouping of pixels that is of size 130). If during the video the grouping of pixels cannot be tracked, I have the position recorded as NaN. To monitor the efficiency of the tracking, I sum the number of NaN's for each dot and I have an if statement that will break the code if the sum of NaN's reaches a certain amount. Instead of having the code break, I want to have the program stop and prompt the user to reselect the pixel size and then the code redoes the tracking. I cannot currently figure out how to do this. Any help would be greatly appreciated. Snippets of the code are shown below to make this more clear. (The if statement is inside of a for loop that goes through and evaluates the video frame by frame)
warndlg('Select Region to Zoom', 'Zoom Area', 'warn')
pause(2);
[col,row] = ginput(2);
.
.
.
nofind = sum(isnan(coord(:,[2 4]))) %Sums the number of times that the tracking program cannot track the dot
if nofind(1,1)>=120 % Tracks the No finds for the green dot
warndlg('Pixel Region too large. Please try again', 'ERROR', 'warn')
break
elseif nofind(1,2)>=200 % Tracks the no finds for the blue dot
warndlg('Pixel Region too large. Please try again', 'ERROR', 'warn')
break
end
Thanks a bunch,
James

Answers (0)

Categories

Find more on Visual Exploration in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!