Live cam
Configuration of a live cam.
Next, we want to configure a live cam connected to the Raspberry. With a cam, there can be multiple applications:
24h live stream of whatever. Exposing a port in the local network should suffice.
Take a picture at a certain point of the day and save it. Then, timelapse can be done.
source:
To use cv2:
Create virtual environment
python3 -m venv venvActivate it
. venv/bin/activateInstall cv2
pip install opencv-pythonInstall extra libs required
sudo apt-get install libatlas-base-devRun following script
import cv2
import time
cap = cv2.VideoCapture(0)
ret, frame = cap.read()
def takePicture():
(grabbed, frame) = cap.read()
showimg = frame
# cv2.imshow('img1', showimg) # display the captured image
cv2.waitKey(2000)
#time.sleep(1) # Wait 300 miliseconds
image = 'test-image.png'
cv2.imwrite(image, frame)
cap.release()
return image
print(takePicture())Play with waitKey(*) to let some seconds to focus light. Also, adjust cam.
Last updated
Was this helpful?