Video Seize Machine Error on OpenCV python Raspberry Pi

So i used to be making an attempt to file footage from my usb webcam however i saved geting the error [ WARN:0] world /tmp/pip-wheel-q9vz0pjg/opencv-contrib-python_40a59bd831de4dd7b8677ff65e12c69e/opencv/modules/videoio/src/cap_v4l.cpp (893) open VIDEOIO(V4L2:/dev/video13): cannot open digital camera by index. I do know the digital camera works as a result of i used to be streaming the picture to my webserver that can be on the RPi nevertheless it wont work with openCV.

import numpy as np
import cv2

filename="/residence/pi/Paperwork/rpiwbsrvr/v/video.avi"
fps = 24.0
'''640, 480 - 480p
1280, 720 - 720p
1920, 1080 - 1080p
3840, 2160 - 2160p'''


cam = cv2.VideoCapture(0)
cam.set(3, 1280)
cam.set(4, 720)

vid_type = cv2.VideoWriter_fourcc(*'XVID')
vid = cv2.VideoWriter(filename, vid_type, fps, (1280, 720))

whereas(True):
    ret, body = cam.learn()
    vid.write(body)

    #cv2.imshow('body', body)
    if cv2.waitKey(20) & 0xFF == ord('q'):
        break

cam.launch()
vid.launch()
cv2.destroyAllWindows()


Source link

Leave a Reply

Your email address will not be published. Required fields are marked *