Move inference onto the API
This commit is contained in:
@@ -23,13 +23,13 @@ class Camera:
|
||||
self.cap.release()
|
||||
self.cap = None
|
||||
|
||||
def take_photo(self) -> np.ndarray:
|
||||
def take_photo(self) -> bytes:
|
||||
self.open()
|
||||
try:
|
||||
ret, frame = self.cap.read()
|
||||
if not ret:
|
||||
raise RuntimeError("Failed to capture image")
|
||||
return frame
|
||||
return cv2.imencode('.jpg', frame, [int(cv2.IMWRITE_JPEG_QUALITY), 80])[1].tobytes()
|
||||
finally:
|
||||
self.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user