i m trying to implement frame difference method for performing background subtraction. The problem is when i try to show frame difference in a window. I dun get any output[black window].This is the code implemented
#include <highgui.h>
#include <iostream>
using namespace cv;
int main()
{
VideoCapture cap("Camouflage/b%05d.bmp");
if(!cap.isOpened())
{
std::cout<<"failed to open image sequence";
return 1;
}
char c;
Mat frame1, frame2, frame3;
namedWindow("Original Frames",1);
namedWindow("Frame Difference",1);
while(1)
{
cap>>frame1;
if(frame1.empty())
{
std::cout<<"Frame1Message->End of sequence"<<std::endl;
break;
}
cap>>frame2;
if(frame2.empty())
{
std::cout<<"Frame2Message->End of sequence"<<std::endl;
break;
}
// absdiff(frame1,frame2,frame3);
frame3=frame1.clone();
frame3=frame3-frame2;
//imwrite("C:/Users/hp/Desktop/file
imshow("Frame Difference",frame3);
c=waitKey(90);
if(c==27)
break;
imshow("Original Frames",frame1);
c=waitKey(90);
if(c==27)
break;
}
}
can anyone help me out ?.. i m stuck.
UPDATE
VideoCapture
did not work for me so i used cvCapture
.I thought it wont read sequence of images but it worked.This is what i did
CvCapture* capture = cvCreateFileCapture("Camouflage/b%05d.bmp");
The image name could be anything like b00000, b00010, b00001 etc..