Added camera test files to test.py

This commit is contained in:
Kieran 2023-11-25 13:03:50 +00:00
parent e735e8358c
commit 53778d1ce0
5 changed files with 31 additions and 1 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

32
test.py
View File

@ -1,2 +1,32 @@
"""
This File tests if a camera is connected and working
It should display a live stream in grayscale
"""
print("Hallo, Welt!")
print("Hallo, Welt 2 !")
import numpy as np
import cv2 as cv
cap = cv.VideoCapture(0)
if not cap.isOpened():
print("Cannot open camera")
exit()
while True:
# Capture frame-by-frame
ret, frame = cap.read()
# if frame is read correctly ret is True
if not ret:
print("Can't receive frame (stream end?). Exiting ...")
break
# Our operations on the frame come here
gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)
# Display the resulting frame
cv.imshow('frame', gray)
if cv.waitKey(1) == ord('q'):
break
# When everything done, release the capture
cap.release()
cv.destroyAllWindows()