Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

This is the code. The output its not what I wanted:

   int main(int argc,char ** argv)
{
  VideoCapture cap(0);
  if (!cap.isOpened()) {
    cerr << "ERROR: Unable to open the camera" << endl;
    return 0;
  }

  Mat frame1, frame2, frame3, frame4, frame5;
  Mat x1, x2, x3, x4, x5;

    cap >> frame1;
    usleep(3333); 
    cap >> frame2;
    usleep(3333); 
    cap >> frame3;
    usleep(3333); 
    cap >> frame4;  
    usleep(3333); 
    cap >> frame5;


frame1.convertTo(x1, CV_32S);
frame2.convertTo(x2, CV_32S);
frame3.convertTo(x3, CV_32S);
frame4.convertTo(x4, CV_32S);
frame5.convertTo(x5, CV_32S);


Mat y; 

y=0.33*x1 -0.67*x1+0.33*x2+ 0.14*x1-0.67*x2+0.33*x3 + 0.24*x1+0.14*x2-0.67*x3+0.33*x4 + 0.07*x1+0.24*x2+0.14*x3-0.67*x4+0.33*x5 -0.05*x1+0.07*x2+0.24*x3+0.14*x4-0.67*x5 - 0.05*x2+0.07*x3+0.24*x4+0.14*x5 -0.05*x3+0.07*x4+0.24*x5 - 0.05*x4+0.07*x5 - 0.05*x5; 

Mat output;

y.convertTo(output, CV_8U); 

vector<int> compression_params;
compression_params.push_back(IMWRITE_PNG_COMPRESSION);
compression_params.push_back(1);  //este valor es la compresión cuanto más alto más comprimido
imwrite("outputFilter.png", output, compression_params);
imwrite("outputWitoutFilter.png", frame1, compression_params);

And this is the image with the filter

image description

And this is the image without the filter

image description

But as It cant get and proceed the frames in continuos way and there is more than 5 discrete value in the impulse response the filter doesnt work. I will have to use the more simple filter

x1- x2