Intel® Distribution of OpenVINO™ Toolkit
Community assistance about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all aspects of computer vision-related on Intel® platforms.
6392 Discussions

Video colors altered with OpenCV OpenVino

DaveInPA
New Contributor I
3,098 Views

I got a very simply Python app that reads USB camera and write the output to a file. When I run with an environment that uses the OpenVino build (4.5.3-openvino) the colors get altered on the saved video file. When I run with on the exact same machine with a user that doesn't have the environment variables set for OpenVino (openCV build is 4.5.3) the video output file is as expected.

 

Attached are frames from the OpenVino CV build and regular build. When I run my OpenVino version i get the following messages on the screen. I get a lot of these types of messages in my OpenVino applications so not sure if these are just noise or point to the problem.

 

[ WARN:0] global ../opencv/modules/videoio/src/cap_gstreamer.cpp (2057) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module filesink0 reported: Could not open file "VIDEO.avi" for writing.
[ WARN:0] global ../opencv/modules/videoio/src/cap_gstreamer.cpp (2057) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module filesink0 reported: GStreamer error: state change failed and some element failed to post a proper error message with the reason for the failure.
[ WARN:0] global ../opencv/modules/videoio/src/cap_gstreamer.cpp (1847) open OpenCV | GStreamer warning: GStreamer: cannot put pipeline to play

[ERROR:0] global ../opencv/modules/videoio/src/cap.cpp (589) open VIDEOIO(CV_IMAGES): raised OpenCV exception:

OpenCV(4.5.3-openvino) ../opencv/modules/videoio/src/cap_images.cpp:253: error: (-5:Bad argument) CAP_IMAGES: can't find starting number (in the name of file): VIDEO.avi in function 'icvExtractPattern'

[ WARN:0] global ../opencv/modules/videoio/src/cap_gstreamer.cpp (2057) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module filesink0 reported: Could not open file "VIDEO.avi" for writing.
[ WARN:0] global ../opencv/modules/videoio/src/cap_gstreamer.cpp (2057) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module filesink0 reported: GStreamer error: state change failed and some element failed to post a proper error message with the reason for the failure.
[ WARN:0] global ../opencv/modules/videoio/src/cap_gstreamer.cpp (1847) open OpenCV | GStreamer warning: GStreamer: cannot put pipeline to play

[ERROR:0] global ../opencv/modules/videoio/src/cap.cpp (589) open VIDEOIO(CV_IMAGES): raised OpenCV exception:

OpenCV(4.5.3-openvino) ../opencv/modules/videoio/src/cap_images.cpp:253: error: (-5:Bad argument) CAP_IMAGES: can't find starting number (in the name of file): VIDEO.avi in function 'icvExtractPattern'

 

My code is really simple just to recreate the issue...

 

cap = cv2.VideoCapture(0)  
fourcc = cv2.VideoWriter_fourcc( 'm', 'j', 'p', 'g') 
out = cv2.VideoWriter('driveway.avi', fourcc, 20.0, (640, 480))
 
while(True):
   ret, frame = cap.read() 
   out.write(frame)

 

 

0 Kudos
1 Solution
Peh_Intel
Moderator
3,029 Views

Hi Davel,

 

I would like to share my findings with you when running OpenCV on Raspberry Pi 3B.

 

If I run using OpenCV-4.5.2-openvino, the video is generated and the output video is fine.

4.5.2-openvino.png

 

When I run using OpenCV-4.5.3-openvino, I get few similar errors as you, but the video is not generated at all.

4.5.3-openvino_small_letter.png

 

Lastly, if I change the “mjpg” to capital letter and run using OpenCV-4.5.3-openvino again, the video is generated and the output video is fine.

fourcc = cv2.VideoWriter_fourcc(‘M’,’J’,’P’,’G’)

 

 

Regards,

Peh

 

View solution in original post

7 Replies
Peh_Intel
Moderator
3,055 Views

Hi Davel,

 

Thanks for reaching out to us.

 

I’ve validated that the saved video by using OpenCV from OpenVINO™ (4.5.3-openvino) is working fine on Ubuntu 20.04 with Python 3.8.10.

 

Here is my output:

video.jpg

 

Regards,

Peh

 

0 Kudos
DaveInPA
New Contributor I
3,047 Views

Interesting...i don't get those FFMPEG error messages that you have on your console - does that point to anything that would be different between our environments? I've read that some people get color mismatch with FFMPEG and OpenCV. 

 

Im running from Rasberry Pi and i also wonder if that makes a difference...

0 Kudos
Peh_Intel
Moderator
3,030 Views

Hi Davel,

 

I would like to share my findings with you when running OpenCV on Raspberry Pi 3B.

 

If I run using OpenCV-4.5.2-openvino, the video is generated and the output video is fine.

4.5.2-openvino.png

 

When I run using OpenCV-4.5.3-openvino, I get few similar errors as you, but the video is not generated at all.

4.5.3-openvino_small_letter.png

 

Lastly, if I change the “mjpg” to capital letter and run using OpenCV-4.5.3-openvino again, the video is generated and the output video is fine.

fourcc = cv2.VideoWriter_fourcc(‘M’,’J’,’P’,’G’)

 

 

Regards,

Peh

 

DaveInPA
New Contributor I
3,017 Views

Ok thanks - i'm getting the same GSStreamer errors so maybe it has to do with how i am specifying the forecc. I'll work on it but you've confirmed this isn't a bug and it has to be something about my environment or what i'm doing on my end.

0 Kudos
DaveInPA
New Contributor I
2,973 Views

Ok so i changed my fourcc to use upper case letters and for whatever reason that fixed my problem - very strange...

0 Kudos
Peh_Intel
Moderator
2,914 Views

Hi Davel,


Glad to know it works for you also.


Based on the tutorial for saving a video from OpenCV, the fourcc codes should be in capital letter (‘M’,’P’,’J’,’G’). But somehow smaller letter can also work in previous OpenCV version, OpenCV-4.5.2-openvino.


This thread will no longer be monitored since this issue has been resolved. If you need any additional information from Intel, please submit a new question.



Regards,

Peh


0 Kudos
DaveInPA
New Contributor I
2,905 Views
Actually I was wrong - when I run using openvino and openCv I get funny colors. When I run without openvino it works just fine. So must be my environment.

What version of FFMpeg is supported with openvino? Also my app is defaulting to GSStreamer back end. Could I have the wrong version of that by chance? Anything else you can think of in my envinromwnt that could cause this? On my windows I don’t have the issue…
0 Kudos
Reply