Slow capture Video from OV5640 via OpenCV i.MX8M Mini

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

Slow capture Video from OV5640 via OpenCV i.MX8M Mini

Contributor II

I tried to catch video from OV5640 via OpenCV at 1920x1080, but i have only 3 fps
My python code:



import cv2
import numpy as np

pipeline = 'v4l2src device=/dev/video0 ! video/x-raw, framerate=30/1,width=1920,height=1080 ! videoconvert ! appsink'

camera = cv2.VideoCapture(pipeline, cv2.CAP_GSTREAMER)

while True:
    success, frame =

    if(success == True):
        cv2.imshow("Image", frame)

    if cv2.waitKey(1) == 27:




If i print this comand in terminal capture works fine:



gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw, framerate=30/1,width=1920,height=1080 ! videoconvert ! waylandsink



How to make opencv capture a picture via gstreamer at 30 fps?

And I also found an interesting fact that if you take an image through v4l2 then everything works fine (at 30 fps) but only in 640x480 resolution:



cv2.VideoCapture(0 cv2.CAP_V4L2)



If I try to change it this way:



camera.set(cv2.CAP_PROP_FRAME_WIDTH, 1920)
camera.set(cv2.CAP_PROP_FRAME_HEIGHT, 1080)



the program not work with the following message in debuger:



[ WARN:0] global /usr/src/debug/opencv/4.5.2.imx-r0/git/modules/videoio/src/cap_v4l.cpp (1001) tryIoctl VIDEOIO(V4L2:/dev/video0): select() timeout.



Resolution changed, but not work
Info from terminal via v4l2-ctl -d /dev/video0 --all:



Format Video Capture:
        Width/Height      : 1920/1080
        Pixel Format      : ''
        Field             : None
        Bytes per Line    : 0
        Size Image        : 4147200
        Colorspace        : Default
        Transfer Function : Default (maps to Rec. 709)
        YCbCr/HSV Encoding: Default (maps to ITU-R 601)
        Quantization      : Default (maps to Full Range)



And I also noticed that when I run this comand:



gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw, framerate=30/1,width=640,height=480  ! waylandsink



it opens in full screen, i
.e. resize to 1920x1080 and the image is displayed at 20-25 fps, if I resize through opencv then fps drops from 30 frames to 10-15


What do I need in the end.
1. Get 30 fps when reading 1920х1080 through opencv.
2. Get 640x480 30fps resize up to 1920x1080 via nxp and read it in opencv

Please help!

Labels (1)
0 Kudos
1 Reply