I have a loop which goes through a video with some processing/calculations of the images. I want to save the image in the loop with the highest value from the processing, but I'm struggling a bit with storing the image temporally while the loop finishes.
The images/frames are initialized like this
IplImage* frame = 0;
IplImage* maxframe = 0;
While looping the maxframe is found by
if( currentvalue > maxvalue ) {
maxvalue = currentvalue;
maxframe = frame;
}
I'm aware that what I am storing in the maxframe variable is the same pointer to the frame currently loaded in the frame pointer. When a new frame is loaded into the frame variable, this will also be pointed to by the maxframe pointer. So when I save the image pointed to by maxframe, I save the last image in the loop no matter what its calculated value is.
I have tried a lot of different solutions, but I can't seem to solve this problem. Can anyone help me? :)