AnsweredAssumed Answered

cv2.VideoCapture with onboard CSI Camera OV5640 on iMX6ULEVK

Question asked by Dao Van Toan on Jan 15, 2020
Latest reply on Jan 15, 2020 by Dao Van Toan

Hi NXPs,

My name is Toan. I am using iMX6ULEVK with kernel 4.14.98. Currently, I want to read video from OV5640 camera on python3 with OpenCV by Gstreamer. And I'm using:

camera = cv2.VideoCapture("imxv4l2src device=/dev/video1 ! video/x-raw-yuv format=YUYV, width=1280 , height=720 , framerate=(fraction)30/1 ! appsink")

But I got this error:

Traceback (most recent call last):
  File "streamOV5640.py", line 14, in <module>
    cv2.imshow("Streaming.",frame)
cv2.error: OpenCV(4.0.1) /usr/src/debug/opencv/4.0.1.imx-r0/git/modules/imgproc/src/color.hpp:259: error: (-2:Unspecified error) in function 'cv::CvtHelper<VScn, VDcn, VDepth, sizePolicy>::CvtHelper(cv::InputArray, cv::OutputArray, int) [with VScn = cv::Set<3, 4>; VDcn = cv::Set<3, 4>; VDepth = cv::Set<0, 2, 5>; cv::SizePolicy sizePolicy = (cv::SizePolicy)2; cv::InputArray = const cv::_InputArray&; cv::OutputArray = const cv::_OutputArray&]'
> Invalid number of channels in input image:
>     'VScn::contains(scn)'
> where
>     'scn' is 2

I found that output image is only 2 channels colors:

[[[141 124]
  [142 127]
  [142 124]
  ...

How does its happen ? I never met this case before. Did I miss somethings and how can I fix this ?

Thank you so much,

Toan

Outcomes