MCPcopy
hub / github.com/zju3dv/4K4D / capture

Method capture

easyvolcap/utils/stream_utils.py:71–92  ·  view source on GitHub ↗
(self, save=False)

Source from the content-addressed store, hash-verified

69 cap.release()
70
71 def capture(self, save=False):
72 rets, flag = dotdict(), False
73 while not flag:
74 data = self.queue_imgs.get()
75 rets[data.idx] = data
76 tsps = [data.tsp for data in rets.values()]
77 flag = len(tsps) == self.num_cams
78 flag = flag and (max(tsps) - min(tsps) < 40)
79
80 # Return images
81 imgs = [np.asarray(cv2.cvtColor(rets[i].img, cv2.COLOR_BGR2RGB), dtype=np.float32) for i in range(self.num_cams)]
82
83 # Save images
84 # TODO: whether it is a good idea to save images here
85 if save:
86 for i, img in enumerate(imgs):
87 save_pth = f'{self.save_pth}/{i}'
88 if not os.path.exists(save_pth): os.makedirs(save_pth, exist_ok=True)
89 cv2.imwrite(f'{save_pth}/{self.count:06d}.jpg', img[..., [2, 1, 0]])
90 self.count += 1
91
92 return imgs
93
94 def __del__(self):
95 self.queue_flag.put(True)

Callers 2

markup_to_ansiFunction · 0.80
get_sourcesMethod · 0.80

Calls 3

dotdictClass · 0.90
getMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected