Ask Your Question

swk's profile - activity

2014-04-21 01:10:37 -0600 commented answer writing MJPG file by VideoWriter in Visual Studio x64/Release platform

Thank you for your suggestion. In this particular case, floating point comparison or the macro EXPECT_EQ (defined just above the main function) do not play crucial roles, because replacing the "EXPECT_EQ(20.0, current_time);" line with something like "if (fabs(20.0 - current_time) > 0.1) { std::cout << "failed" << std::endl; }" reproduces the problem.

This behaviour is fragile: By replacing the above line with "std::cout << current_time << std::endl;" the program puts out 20 correctly; while by inserting this after the above if statement it puts a very small number close to zero. So I am afraid "writer << blank;" destroys the stack frame.

2014-04-07 06:19:11 -0600 asked a question writing MJPG file by VideoWriter in Visual Studio x64/Release platform

I am trying the following code in Windows 7 pro; Visual Studio 2012 Express with x64/Release configuration using the pre-built OpenCV 2.4.8 and 2.4.5 (x64/vc11). In my environment, EXPECT_EQ fails.

#include "opencv2/opencv.hpp"
void EXPECT_EQ(double a, double b) { if (a != b) { std::cout << "failed" << std::endl; } } 
int main()
{
    double current_time = 0.0;
    cv::Mat blank = cv::Mat::zeros(480, 640, CV_8UC3);
    cv::VideoWriter writer("output.avi", CV_FOURCC('M','J','P','G'),
                           50.0, blank.size(), true);
    current_time += 20.0;
    writer << blank;
    EXPECT_EQ(20.0, current_time);
    return 0;
}

This happens only when I write MJPG format files as far as I tried. The problem does not reproduce if I choose Win32 (x86) or Debug configurations.

Any help or comments are appreciated. Thank you very much in advance.