[PYTHON] Using a webcam with Raspberry Pi

When using in a command Install fswebcam.

sudo apt install fswebcam
fswebcam photo.jpg

When using with Python Install opencv.

/etc/apt/sources.list


deb http://ftp.jaist.ac.jp/raspbian jessie main contrib non-free
deb http://ftp.yz.yamagata-u.ac.jp/pub/linux/raspbian/raspbian/ jessie main cont
rib non-free
sudo apt install libopencv-dev
sudo apt install python-opencv

usb_camera.py


#! /usr/bin/python
# -*- coding: utf-8 -*-
#
#	usb_camera.py
#
#						Jun/06/2017
# --------------------------------------------------------------------
import sys
import cv2
#
sys.stderr.write("***start***\n")
#
cc = cv2.VideoCapture(0)
#
rr, img = cc.read()
cv2.imwrite('photo.jpg', img)
#
sys.stderr.write("***End***\n")
# --------------------------------------------------------------------

Recommended Posts

Using a webcam with Raspberry Pi
Make a wash-drying timer with a Raspberry Pi
Operate an oscilloscope with a Raspberry Pi
GPGPU with Raspberry Pi
DigitalSignage with Raspberry Pi
Control the motor with a motor driver using python on Raspberry Pi 3!
[Note] Using 16x2-digit character LCD (1602A) from Python with Raspberry Pi
Try using a QR code on a Raspberry Pi
Create a visitor notification system using Raspberry Pi
Detect analog signals with A / D converter using python on Raspberry Pi 3!
Indoor monitoring using Raspberry Pi
Mutter plants with Raspberry Pi
Using a printer with Debian 10
Create a color sensor using a Raspberry Pi and a camera
Using the digital illuminance sensor TSL2561 with Raspberry Pi
Using Akizuki Denshi's 4WD car FT-MC-004 with Raspberry Pi
A memorandum when making a surveillance camera with Raspberry Pi
[Raspberry Pi] Stepping motor control with Raspberry Pi
Use vl53l0x with Raspberry Pi (python)
Servo motor control with Raspberry Pi
USB over ethernet using Raspberry pi
Serial communication with Raspberry Pi + PySerial
Detect "temperature (using A / D converter)" using python on Raspberry Pi 3!
OS setup with Raspberry Pi Imager
Try using ArUco on Raspberry Pi
I made a resource monitor for Raspberry Pi with a spreadsheet
Try L Chika with raspberry pi
I tried using the DS18B20 temperature sensor with Raspberry Pi
I tried to automate [a certain task] using Raspberry Pi
getrpimodel: Recognize Raspberry Pi model (A, B, B +, B2, B3, etc) with python
Try moving 3 servos with Raspberry Pi
I made a surveillance camera with my first Raspberry PI.
Creating a temperature / humidity monitor with Raspberry Pi (pigpio version)
I tried to make a motion detection surveillance camera with OpenCV using a WEB camera with Raspberry Pi
Let's make a cycle computer with Raspberry Pi Zero (W, WH)
I made a web server with Raspberry Pi to watch anime
Make a simple CO2 incubator using Raspberry PI and CO2 sensor (MH-Z14A)
Make a Kanji display compass with Raspberry Pi and Sense Hat
Measure SIM signal strength with Raspberry Pi
Pet monitoring with Rekognition and Raspberry pi
[Raspberry Pi] Add a thermometer and a hygrometer
Detect "brightness" using python on Raspberry Pi 3!
Hello World with Raspberry Pi + Minecraft Pi Edition
Make Raspberry Pi speak Japanese using OpenJtalk
[Easy] AI automatic recognition with a webcam!
Get BITCOIN LTP information with Raspberry PI
Try fishing for smelt with Raspberry Pi
Improved motion sensor made with Raspberry Pi
Try Object detection with Raspberry Pi 4 + Coral
Run servomotor on Raspberry Pi 3 using python
Power SG-90 servo motor with raspberry pi
Working with sensors on Mathematica on Raspberry Pi
Equipped with a card function using payjp
Infer Custom Vision model with Raspberry Pi
Detect temperature using python on Raspberry Pi 3!
Inkbird IBS-TH1 value logged with Raspberry Pi
Working with GPS on Raspberry Pi 3 Python
How to upload a file to Cloud Storage using Python [Make a fixed point camera with Raspberry PI # 1]
A memo to simply use the illuminance sensor TSL2561 with Raspberry Pi 2
[Electronic work] I made a Suica touch sound detector with Raspberry Pi
Make a wireless LAN Ethernet converter and simple router with Raspberry Pi