Raspberry Pi: Kamerabild mit OpenCV & Python aufnehmen
English
Deutsch
Installieren Sie zunächst OpenCV für Python 3:
install-opencv.sh
sudo apt install python3-opencvHier ist der Code um das Bild aufzunehmen und in image.png zu speichern:
cv-raspicapture.py
#!/usr/bin/env python3
import cv2
video_capture = cv2.VideoCapture(0)
# Erfolg prüfen
if not video_capture.isOpened():
raise Exception("Videogerät konnte nicht geöffnet werden")
# Bild lesen. ret === True bei Erfolg
ret, frame = video_capture.read()
cv2.imwrite('image.png', frame)
# Gerät schließen
video_capture.release()Ausführen mit
cv-raspicapture.sh
python3 cv-raspicapture.pyCheck out similar posts by category:
OpenCV, Python, Raspberry Pi
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow