Any help on this idea would be greatly appreciated, I have found a weird issue with integrating a USB webcam with a Pi and open CV.
If I request a snap shot from the webcam it gives me a old one, i'm assuming this is a shot from the start of a frame buffer because if I "burn" a few shots first it gives me a much newer less lagging image. [essentially I ask it for images 6 times and only accept the last one]
OpenCv install I used:
Animated_Grim Blog:3 - Raspbery Pi and OpenCv the Easy Way
Webcam :
Logitech C270 but I get the same issue with a cheap generic ebay one.
Pi:
Model 2
I have been using this work around to get upto date images from the usb webcam, but now I have time I would like to find the root issue and speed my loop up considerably.
| Header 1 |
|---|
#!/usr/bin/python
import cv2 cap = cv2.VideoCapture(0)
while(1):
_,frame = cap.read() #Display the first image captured cv2.imshow('Camera_LAG',frame) _,frame = cap.read() _,frame = cap.read() _,frame = cap.read() _,frame = cap.read() _,frame = cap.read() _,frame = cap.read() #Display the 6th image captured cv2.imshow('NO_LAG',frame)
##***Checks If User Has Asked to Leave if cv2.waitKey(33)== 27: break ##************** Clean up everything before leaving *****************##
cap.release() cv2.destroyAllWindows() |
Does anyone have any idea why this is happening, can I somehow request the newest image from the camera because I would like to speed my image processing projects up.
Mike





