I got a USB-connected webcam for Raspberry Pi. This time, the operation check and the memo of the program.
Click here for the camera to use. Logicool Brio Ultra HD Pro Webcam
$ lsusb
Bus 002 Device006: ID 046d:085e Logitech, Inc.
$ ls /dev/video*
/dev/video0 /dev/video1 /dev/video2 /dev/video3
Was added.
guvcview
.$ sudo apt-get install guvcview
Execute with the following command.
$ guvcview &
It ran, but it didn't work after the first image acquisition. I tried to take a video, but it didn't save well.
fswebcam
.$ sudo apt-get install fswebcam
How to execute
$ fswebcam img.jpg
The captured image is saved as img.jpg
in/home/[username]/
.
Execute the following code.
import numpy as np
import cv2
cap = cv2.VideoCapture(0)
while(True):
ret, frame = cap.read()
cv2.imshow('frame',frame)
key = cv2.waitKey(1)
if key == ord('q'):
break
if key == ord('s'):
path = "/home/kono/image/カメラimage/photo.jpg "
cv2.imwrite(path,frame)
cap.release()
cv2.destroyAllWindows()
Press s
on the keyboard to shoot, and press q
to finish.
The captured image is saved as photo.jpg
in the specified location.
Click here for the reference site. [Raspberry Pi] How to connect a webcam
The operation of the program I wrote is more stable than that of the software. Coin identification issues Do your best.
Recommended Posts