Skip to content

how can read the video frame faster #868

@gjlong

Description

@gjlong

Dear author,
I used the opencv-python 4.7.0.72 in the raspberry 3b+.But the cap.read() function has a long time in each frame when I want to read the CSI camera in 1080p,30fps.
It takes about 0.1s-0.2s in the frame.

the code is:

cap=cv2.VideoCapture(0)
      cap.set(3, 1920)
      cap.set(4, 1080)
      cap.set(5, 30)
      cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc(*"MJPG"))
      time.sleep(2)

while (cap.isOpened()):
        start=time.time()
        ret, frame = cap.read()
        end=time.time()
        print(end-start)

Is my code has some wrong?
please tell me how can fix it.
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions