First of all, i’d like to say thank you for your previous solving of blue raw.

opencv preview is lagging about 2 seconde on preview i have a lag of about 2s with logitech webcam C920

I try this script in python without lagging:

import numpy as np
import cv2

cap = cv2.VideoCapture(0)

while(True):
    # Capture frame-by-frame
    ret, frame = cap.read()


    # Display the resulting frame
    cv2.imshow('frame',frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()

Steps to reproduce the bug

  1. take a photo
  2. preview is late about 2-3 sec
  3. See error.

Is alpha or resizing, can cause this delay? Is it possible to downsample preview to erase latency?

Environment

  • OS [Raspbian Buster]
  • Camera [Logitech C920]
  • Pibooth version [1.1.4]

Thanks

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:15 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
JFK344commented, Feb 8, 2022

In my case the camera was not using the right codec. I used this command to get all the available Codecs.

v4l2-ctl --list-formats-ext

my camera used YUYV which was capable of 6 fps at 1920x1080.

Changed the settings to cam.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter.fourcc('M','J','P','G')) whichs had NO result eighter.

insted of accesssing the camer by index i used reversingCam = cv2.VideoCapture("/dev/video0") which made things working.

heres my whole Code:

import cv2
  
reversingCam = cv2.VideoCapture("/dev/video0")
reversingCam.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter.fourcc('M','J','P','G'))
reversingCam.set(3, 1280)
reversingCam.set(4, 720)

reversingCam.set(cv2.CAP_PROP_BUFFERSIZE, 1)

while(True):
    ret, frame = reversingCam.read()
    
    cv2.imshow('frame', frame)

    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

reversingCam.release()
cv2.destroyAllWindows()
0reactions
anxuaecommented, May 7, 2021

OpenCV camera improved in pibooth v2.0.2

Please re-open the issue if you are still facing to the same issue.

BR anxuae

Read more comments on GitHub >

github_iconTop Results From Across the Web

OpenCV VideoCapture lag due to the capture buffer
In a nutshell: the time needed to query a frame is measured; if it is too low, it means the frame was read...
Read more >
My video preview is lagging so bad, what's the problem?
Hello, I have problem that my video preview from cv2 is lagging around 2 fps even my webcam has 30 fps specification.
Read more >
OpenCV camera lag - Jetson Nano - NVIDIA Developer Forums
Someone knows why there's that lag in OpenCV, and how can I solve that? I need to show both cameras at once. NV...
Read more >
Fixing opencv lag - Programming - Chief Delphi
We did our image processing in python using OpenCV in a single thread, and didn't have any lag problems. Here are some thoughts...
Read more >
How to get rid the lag of webcam when using opencv? - Reddit
My project has a face recognition, but my web cam is lag. I already fix the lag when I am coding in my...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found