cv2.VideoCapture with onboard CSI Camera OV5640 on iMX6ULEVK

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

cv2.VideoCapture with onboard CSI Camera OV5640 on iMX6ULEVK

1,420 Views
toanjunifer
Senior Contributor I

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

Labels (1)
2 Replies

1,208 Views
Bio_TICFSL
NXP TechSupport
NXP TechSupport

Hello Dao,

You must try to run the camera first please try:

camera = cv2.CaptureVideo('/dev/video1')

Regards

1,208 Views
toanjunifer
Senior Contributor I

Hi Bio_TICFSL‌,

Thanks for you response. I tried this but FPS is about 7.5 FPS. It's quite low so I finding other solution. I used gst-launch-1.0 command can reach at 30 FPS. It's so perfect if I get the same thing with OpenCV-Python. DO you have some ideas ?

Thank you so much,

Toan

0 Kudos