MCPcopy Index your code
hub / github.com/alievk/avatarify-python / query_cameras

Function query_cameras

afy/camera_selector.py:11–36  ·  view source on GitHub ↗
(n_cams)

Source from the content-addressed store, hash-verified

9
10
11def query_cameras(n_cams):
12 cam_frames = {}
13 cap = None
14 for camid in range(n_cams):
15 log(f"Trying camera with id {camid}")
16 cap = cv2.VideoCapture(camid)
17
18 if not cap.isOpened():
19 log(f"Camera with id {camid} is not available")
20 continue
21
22 ret, frame = cap.read()
23
24 if not ret or frame is None:
25 log(f"Could not read from camera with id {camid}")
26 cap.release()
27 continue
28
29 for i in range(10):
30 ret, frame = cap.read()
31
32 cam_frames[camid] = frame.copy()
33
34 cap.release()
35
36 return cam_frames
37
38
39def make_grid(images, cell_size=(320, 240), cols=2):

Callers 1

camera_selector.pyFile · 0.85

Calls 3

logFunction · 0.90
isOpenedMethod · 0.80
readMethod · 0.80

Tested by

no test coverage detected