Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import cv2
- from base_camera import BaseCamera
- class Camera(BaseCamera):
- video_source = 0
- @staticmethod
- def set_video_source(source):
- Camera.video_source = source
- @staticmethod
- def frames(id): # when I do that I got that error which I mention above
- # I WANT TO RECEIVE THE fid IN THIS FUNCTION and print it here
- print(id) # But I get an error
- camera = cv2.VideoCapture(Camera.video_source)
- if not camera.isOpened():
- raise RuntimeError('Could not start camera.')
- while True:
- # read current frame
- _, img = camera.read()
- # encode as a jpeg image and return it
- yield cv2.imencode('.jpg', img)[1].tobytes()
Advertisement
Add Comment
Please, Sign In to add comment