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.

Video colors altered with OpenCV OpenVino

DaveInPA
새로운 기여자 I
5,280 조회수

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 포인트
1 솔루션
Peh_Intel
중재자
5,211 조회수

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

 

원본 게시물의 솔루션 보기

7 응답
Peh_Intel
중재자
5,237 조회수

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 포인트
DaveInPA
새로운 기여자 I
5,229 조회수

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 포인트
Peh_Intel
중재자
5,212 조회수

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
새로운 기여자 I
5,199 조회수

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 포인트
DaveInPA
새로운 기여자 I
5,155 조회수

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

0 포인트
Peh_Intel
중재자
5,096 조회수

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 포인트
DaveInPA
새로운 기여자 I
5,087 조회수
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 포인트
응답