def worker(): while True: item = q.get() image = np.zeros((frame_height, frame_width)) if item is not None: vertices = item show_img = plot_vertices(np.zeros_like(image), vertices) else: show_img = image # Display the resulting frame cv2.imshow('frame',show_img) # Press Q on keyboard to stop recording if cv2.waitKey(1) & 0xFF == ord('q'): break q.task_done()
def worker(): display_subtitle = "" while True: item = q.get() image = np.zeros((480, 640)) if item is not None: vertices = item show_img = plot_vertices(np.zeros_like(image), vertices) else: show_img = image # Display the resulting frame if not subtitles.empty(): text = subtitles.get() subtitles.task_done() display_subtitle = text cv2.putText(show_img, display_subtitle, bottomLeftCornerOfText, font, fontScale, fontColor, lineType) cv2.imshow('frame', show_img) # Press Q on keyboard to stop recording if cv2.waitKey(1) & 0xFF == ord('q'): break q.task_done()
module_instance.Apply() next_request = module_instance.PostProcess(grpc_flag = False) next_request['frame_info'] = request_input['frame_info'] next_request['route_table'] = request_input['route_table'] next_request['route_index'] = request_input['route_index'] + 1 request_input = next_request if (current_model == "FaceDetector"): print(request_input["bounding_box"]) elif (current_model == "PRNet"): vertices = request_input["vertices"] print(vertices.shape) show_img = plot_vertices(np.zeros_like(image), vertices) cv2.imwrite("tmp-%s.jpg" % str(frame_id).zfill(3), show_img) # output_file.write(show_img) # pass end = time.time() duration = end - start print("duration = %f" % duration) if (frame_id > 5): count += 1 total += duration frame_id += 1 print("on average, it takes %f sec per frame" % (total / count))
prn = PRNet() start_time = time.time() prn.PreProcess(next_request, stub) prn.Apply() final_request = prn.PostProcess(); elapsed_time = time.time() - start_time print('prnet time cost: {}'.format(elapsed_time)) kpt = tensor_util.MakeNdarray(final_request.inputs["prnet_output"]) vertices = tensor_util.MakeNdarray(final_request.inputs["vertices"]) # print(vertices.shape) # print(image.shape) start_time = time.time() out.write(plot_vertices(np.zeros_like(image), vertices)) # tmp = plot_vertices(np.zeros_like(image), vertices) # print(tmp) # cv2.imwrite("output/%s.jpg" % str(useful_result).zfill(3), tmp) elapsed_time = time.time() - start_time # break else: out.write(image) print("In total, there are %d useful results." % useful_result)