Ask Your Question
0

Evaluation of 2 frames after encoding/decoding

asked 2016-01-15 20:56:10 -0500

Cabezon667 gravatar image

Hi everyone,

Another question, I capture 2 frames and then I obtain the absolute error of them:

//// After capturing 2 frames
Mat frame1, frame2;
absdiff(frame1,frame2,error);

Everything ok at this point. But later I need to encoder/decoder the image and the evaluate that result with the first error (for obtain the PSNR for example) imwrite("error.jpeg",error); Mat error2 = imread("error.jpeg");

The problem here is error2 and error1 are different. I tried everything without success, but I cant understand why for example

Mat error3 = error2 - error1; //// Show an error of not equal size of the matrix.

I dont know what yo do. Did someone could help me? Thank you very much.

edit retag flag offensive close merge delete

Comments

1

Can you give some more information? Specifically, what version of OpenCV? What language (C++, Java, Python)? What size does error1 say it is, and what size does error2 say, if you print rows and cols?

Also, if you open error.jpg in an image editing program like paint, what does it say there?

What pixel format are both images? Is one CV_8UC1 and one CV_8UC3?

Tetragramm gravatar imageTetragramm ( 2016-01-15 21:17:25 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-01-15 21:24:24 -0500

Cabezon667 gravatar image

Actually, I found the problem. My problem was when I read the image, i didnt put the '0' in the flag. Then, I tried to change everything to CV_8U and then i found the PSNR.

double psnr1;
Mat error1, error2, frame1,frame2;
frame1 = vframes[1];
frame2 = vframes[2];
absdiff(frame1,frame2,error1);
imwrite("error.jpeg",error1);
error2 = imread("error.jpeg",0);
error1.convertTo(error1, CV_8U);
error2.convertTo(error2, CV_8U);
psnr1 = PSNR(error1,error2);
cout << psnr1 << endl;
waitKey(0);

@Tetragramm thanks for your help, I really appreciate it. You are the best in this forum.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-01-15 20:56:10 -0500

Seen: 95 times

Last updated: Jan 15 '16