Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

frame difference

I want to do basic frame difference like this :

diff = current frame - previous frame

is this correct way to so this ? I"m not sure how to get current and next frame

#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;
    }

    frame3=frame1.clone();
    frame3=frame3-frame2;

    imshow("Frame Difference",frame3);
    c=waitKey(90);
    if(c==27)
        break;

    imshow("Original Frames",frame1);
    c=waitKey(90);
    if(c==27)           
         break;
    }

  }

frame differencedifference correct method

I want to do basic frame difference like this :

diff = current frame - previous frame

is this correct way to so this ? I"m not sure how to get current and next frame

#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;
    }

    frame3=frame1.clone();
    frame3=frame3-frame2;

    imshow("Frame Difference",frame3);
    c=waitKey(90);
    if(c==27)
        break;

    imshow("Original Frames",frame1);
    c=waitKey(90);
    if(c==27)           
         break;
    }

  }
click to hide/show revision 3
retagged

frame difference correct method

I want to do basic frame difference like this :

diff = current frame - previous frame

is this correct way to so this ? I"m not sure how to get current and next frame

#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;
    }

    frame3=frame1.clone();
    frame3=frame3-frame2;

    imshow("Frame Difference",frame3);
    c=waitKey(90);
    if(c==27)
        break;

    imshow("Original Frames",frame1);
    c=waitKey(90);
    if(c==27)           
         break;
    }

  }
click to hide/show revision 4
retagged

frame difference correct method

I want to do basic frame difference like this :

diff = current frame - previous frame

is this correct way to so this ? I"m not sure how to get current and next frame

#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;
    }

    frame3=frame1.clone();
    frame3=frame3-frame2;

    imshow("Frame Difference",frame3);
    c=waitKey(90);
    if(c==27)
        break;

    imshow("Original Frames",frame1);
    c=waitKey(90);
    if(c==27)           
         break;
    }

  }

frame difference correct method

I want to do basic frame difference like this :

diff = current frame - previous frame

is this correct way to so this ? I"m not sure how to get current and next frame

#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;
    }

    frame3=frame1.clone();
    frame3=frame3-frame2;

    imshow("Frame Difference",frame3);
    c=waitKey(90);
    if(c==27)
        break;

    imshow("Original Frames",frame1);
    c=waitKey(90);
    if(c==27)           
         break;
    }

  }