horizontal line/break/image shift in video from webcam
Hello, when I move with my webcam quickly, I see these artefacts/image breaks/shifts. I am using vlc v4l2 with /dev/video0 via vlc command line to preview live webcam video. Please, What should I set please to prevent these artefacts?
My sample code:
import cv2
def show_webcam(mirror=False):
cam = cv2.VideoCapture(0)
while True:
ret_val, img = cam.read()
img = cv2.flip(img, 0)
cv2.imshow('my webcam', img)
del(img)
cv2.waitKey(1)
cv2.destroyAllWindows()
def main():
show_webcam(mirror=False)
if __name__ == '__main__':
main()
...and the connection with OpenCV is???
I added code example. No idea if it is specifically opencv related only
Ok. You have a frame syncronization problem, which probably isn't OpenCV related. As you tried it with VLC and you got the same problem.
You can try to change the frame rate of the camera:
cam.set(CV_CAP_PROP_FPS,[some value])
. Maybe it will help.One last comment: don't delete the frame after displaying it.
img
will be simply reused for the next frame.thank you, it really seems to be frame rate problem. I will experiment with it.