Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Trigger laptop camera
import cv2
import matplotlib.pyplot as plt
class LaptopCamera:
def __init__(self, cam_id=0):
self.cam_id = cam_id
# There must be some "lazy" way to initialize it
self.cap = cv2.VideoCapture(cam_id)
self.cap.release()
self.image = None
def stage(self):
...
def trigger(self):
self.cap.open(self.cam_id)
self.image = self.cap.read()[1]
self.cap.release()
def unstage(self):
...
def show(self):
plt.imshow(self.image)
plt.show()
if __name__ == '__main__':
lc = LaptopCamera()
lc.trigger()
lc.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.