I have about 300 images which I want to process in a loop. In every iteration I want to compare an image with an image from the previous loop.
I am trying to hold the current image in:
fIplImageHeader
The image from the previous iteration is stored in:
lastFIplImageHeader
This is how I am doing it and it is giving me an exception:
for ( int i = 0; i < 300; i++ )
{
// get the path to an image (images are named 0.jpg, 1.jpg etc)
// filePath.c_str() contains the path to an image
// load the current image to an IplImage object
IplImage* fIplImageHeader = cvLoadImage( filePath.c_str() );
// create a header for te previous image
IplImage* lastFIplImageHeader = cvCreateImageHeader(
cvSize( fIplImageHeader->width, fIplImageHeader->height ),
fIplImageHeader->depth, fIplImageHeader->nChannels
);
if ( NULL != lastFIplImageHeader->imageData )
{
// COMPARE IMAGES HERE
// only if we are already in 2nd + iteration
}
// copy the current image to the lastFIplImageHeader
// which will hold it in the next iteration
if ( lastFIplImageHeader )
{
cvReleaseImage( &lastFIplImageHeader );
}
cvCopy(fIplImageHeader , lastFIplImageHeader);
// do stuff
if ( fIplImageHeader )
{
cvReleaseImage( &fIplImageHeader );
}
}
The exception:
First-chance exception at 0x753cb727 in Client.exe: Microsoft C++ exception: cv::Exception at memory location 0x0036ef5c..
Unhandled exception at 0x753cb727 in Client.exe: Microsoft C++ exception: cv::Exception at memory location 0x0036ef5c..