def process_frame_consumer(video_path, q, lock, pbar): with lock: print('Starting Consumer => {}'.format(os.getpid())) video = cv2.VideoCapture(video_path) while True: params = q.get() if params == "Done!": break image = video.set(cv2.CAP_PROP_POS_FRAMES, params[0].id) extract_body(image, *params) with lock: pbar.update(1) video.release() with lock: print(' Exit Consumer => {}'.format(os.getpid())) return
def _extract_bodies_images(image, frame_data, width=None, height=None, cX=None, cY=None, suppression=False, min_parts=-1): if width is None: width = Body.width if height is None: height = Body.height if cX is None: cX = Body.cX if cY is None: cY = Body.cY images =list() bodies = list() for body in frame_data: if suppression and not body.valid: continue if len(body) < min_parts: continue cbodyimg = extract_body(image, body, width=width, height=height, cX=cX, cY=cY) images.append(cbodyimg) bodies.append(body) return bodies, np.array(images)
def _image(self, width=None, height=None, cX=None, cY=None, ignore_angle=None, erase_tag=False): if width is None: width = Body.width if height is None: height = Body.height if cX is None: cX = Body.cX if cY is None: cY = Body.cY if ignore_angle is None: ignore_angle = Body.ignore_angle if erase_tag and self.tag is not None: pts = np.array(self.tag["p"]).astype(np.int32) pts = pts.reshape((-1, 1, 2)) frame = cv2.fillPoly(self._frame.image, [pts], (0, 0, 0)) frame = cv2.polylines(frame, [pts], True, (0, 0, 0), 35) else: frame = self._frame.image return extract_body(frame, self, width=width, height=height, cX=cX, cY=cY, ignore_angle=ignore_angle)
def skeleton_image(self): frame = self._frame.image frame = skeleton_drawer(frame, self) return extract_body(frame, self, width=Body.width, height=Body.height, cX=Body.cX, cY=Body.cY)
def process_frame(image, frame, img_folder, file_format): body_info = list() for body in frame: if not body.valid: continue # info = body.info() filename = file_format.format(body.frameid, body.id) body_filename = os.path.join(img_folder, filename) if body.tag is not None: pts = np.array(body.tag["p"]).astype(np.int32) pts = pts.reshape((-1,1,2)) image = cv2.fillPoly(image,[pts], (0,0,0)) image = cv2.polylines(image,[pts],True,(0,0,0),35) # info["filename"] = body_filename # body.save(body_filename, width=width, height=height, cX=cX, cY=cY) im = extract_body(image, body, width=Body.width, height=Body.height, cX=Body.cX, cY=Body.cY) io.imsave(body_filename, im)