opencv icon indicating copy to clipboard operation
opencv copied to clipboard

Issue with saving to video with the opencv patch

Open zhumxcq opened this issue 8 months ago • 1 comments

Applying the opencv changes will cause the following code to fail

std::cout << cv::getBuildInformation() << std::endl;
cv::VideoWriter test_writer;
int fourcc = cv::VideoWriter::fourcc('F', 'F', 'V', '1');  // FFV1 codec (requires FFmpeg build)
test_writer.open("test_video.avi", fourcc, 30, cv::Size(640, 480), true);
cv::Mat frame_in = cv::Mat(480, 640, CV_8UC3);
frame_in = cv::Scalar(255, 122, 0);
test_writer.write(frame_in);
test_writer.write(frame_in);
test_writer.write(frame_in);
test_writer.write(frame_in);
test_writer.write(frame_in);
test_writer.release();

cv::VideoCapture test_reader("test_video.avi");
cv::Mat frame_out;
test_reader >> frame_out;
for (int i = 0; i < 7; ++i) {
	std::cout << "Pixel value row " << i << ": " << frame_out.at<cv::Vec3b>(i, 0) << std::endl;
}

Expected output -> OpenCV 3.4.5 without patch applied Pixel value row 0: [255, 122, 0] Pixel value row 1: [255, 122, 0] Pixel value row 2: [255, 122, 0] Pixel value row 3: [255, 122, 0] Pixel value row 4: [255, 122, 0] Pixel value row 5: [255, 122, 0] Pixel value row 6: [255, 122, 0]

Actual output -> With eCON system patch applied Pixel value row 0: [255, 122, 0] Pixel value row 1: [122, 0, 255] Pixel value row 2: [0, 255, 122] Pixel value row 3: [255, 122, 0] Pixel value row 4: [122, 0, 255] Pixel value row 5: [0, 255, 122] Pixel value row 6: [255, 122, 0]

zhumxcq avatar Jun 11 '25 19:06 zhumxcq

Attached is the commit file to apply the patch to OpenCV

commit-7bdc5b6.txt

3.4.5 8f1356c3c5b16721349582db461a2051653059e8

zhumxcq avatar Jun 11 '25 19:06 zhumxcq