def initialize_webcam(self):
""" Initialize camera and screenwidth and screenheight.
"""
device = 'raspberry' if 'raspberrypi' in os.uname() else None
self.raspberry = True if 'raspberry' == device else False
if self.piCam:
camera = self.setup_picamera()
self.piCamera = camera
return
cam = cv2.VideoCapture(0)
frame = None
while frame is None:
try:
_, frame = cam.read()
# Update class variables.
self.screenheight, self.screenwidth = frame.shape[:2]
cam.set(3, self.screenwidth)
cam.set(4, self.screenheight)
except:
pass
self.cam = cam
return
评论列表
文章目录