树莓派USB摄像头拍照与录像

1,088 阅读1分钟

一、fswebcam

sudo apt-get install fswebcam
fswebcam --device /dev/video0 image.jpg
#!/bin/bash

DATE=$(date +"%Y-%m-%d_%H%M")

fswebcam -r 1280x720 --no-banner /home/pi/webcam/$DATE.jpg

二、v4l2rtspserver

Using Docker image

You can start the application using the docker image :

docker run -p 8554:8554 -it mpromonet/v4l2rtspserver

You can expose V4L2 devices from your host using :

The container entry point is the v4l2rtspserver application, then you can :

get the help using :

docker run -it mpromonet/v4l2rtspserver -h

run the container specifying some paramters :

docker run --device=/dev/video0 -p 8554:8554 -it mpromonet/v4l2rtspserver -u "" -H640 -W480

三、vc2

import cv2
 
capture = cv2.VideoCapture(0)
 
while(True):
     
    ret, frame = capture.read()
     
    cv2.imshow('video', frame)
     
    if cv2.waitKey(1) == 27:
        break
 
capture.release()
cv2.destroyAllWindows()

参考:

www.digikey.com/en/maker/bl…

www.raspberrypi.org/documentati…

github.com/mpromonet/v…