How to read video from OV5640 camera on OpenCV Python 3?

cancel
Showing results for 
Search instead for 
Did you mean: 

How to read video from OV5640 camera on OpenCV Python 3?

388 Views
Senior Contributor I

Hi NXPs, 

My name is Toan. I just bought a new OV5640 camera which compatible with iMX6ULEVK(I am using this board). I can display preview video(approx 30 fps) , capture image and record video(640x480 is 15 fps) with gstreamer command. Now I wanna read video from Python 3 and image processing with OpenCV. I am using:

camera = cv2.CaptureVideo('/dev/video1') but fps is only 7.5 instead of 30 fps like gstreamer command. I tried with camera = cv2.CaptureVideo(1) but not working.

I also try to install v4l2capture but not compatible with python 3. 

So what should I do now(except using v4l2capture ).

Thank you very much, 

Toan

Labels (1)
6 Replies

70 Views
Contributor I

To capture a video in Python, use the cv2 VideoCapture class, and then create an object of VideoCapture. VideoCapture has the device index or the name of a video file. The device index is just an integer to define a which Camera. If we pass 0, then it is for the first or primary camera, 1 for the second camera so on. We capture the video frame by frame.

OpenCV is the computer vision library that contains various methods to perform operations on Images or videos.

OpenCV library can be used to perform multiple operations on videos. Python OpenCV library provides a cv2 VideoCapture class. Let’s understand this better.

OpenCV allows a candid interface to capture live stream with the Camera (webcam).

We need to create an object of VideoCapture class to capture a video. It accepts either a device index or the name of a video file.

A number which is specifying to the Camera is called device index. We can select a Camera bypassing the O or 1 as an argument. After that, we can capture the video frame-by-frame.

0 Kudos

70 Views
NXP TechSupport
NXP TechSupport

Hi Toan

unfortunately i.MX6UL does not have gpu and hardware support for OpenCV,

so it is not supported in nxp linux releases. One can try it in software following

OpenCV Python tutorials:

OpenCV-Python Tutorials — OpenCV-Python Tutorials 1 documentation 

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

70 Views
Senior Contributor I

Hi igorpadykov‌,

I updated my answer with more details. Please help me !

Thank you so much,

Toan

0 Kudos

70 Views
NXP TechSupport
NXP TechSupport

Hi Toan

 

if you have project requiring this feature may be suggested to proceed with

extended support of Commercial Support and Engineering Services | NXP 

 

Best regards
igor

70 Views
Senior Contributor I

Hi igorpadykov‌,

Thank you for your response !

Best regards,

Toan

0 Kudos

70 Views
Senior Contributor I

Hi igorpadykov‌,

Can we have some trick to read video streaming from OV5640 camera ? I have some informations:

  • OV5640 read with gst-launch-1.0: 29 FPS (Almost absolutely)
  • OV5640 read with cv2.VideoCapture("/dev/video2"): 7 - 8 FPS
  • UV Camera read with gst-launch-1.0: 11-14 FPS (14 FPS with a little motion)
  • UV Camera read with cv2.VideoCapture("/dev/video2"): 17-24 FPS (24 FPS with a little motion)

My goal is stream video with OV5640 at 24 FPS on Python with OpenCV. I think possible but I have not found it yet. May you help me ?

Best regards,

Toan

0 Kudos