def main(): pose = Pose() coordinate_list = [] # importing the module import json # Opening JSON file with open('weights.json') as json_file: weights = json.load(json_file)["weights"] s = sum(weights) weights = [w / s for w in weights] with tf.compat.v1.Session() as sess: model_cfg, model_outputs = posenet.load_model(101, sess) cap = cv2.VideoCapture(args["video"]) i = 1 if cap.isOpened() is False: print("error in opening video") while cap.isOpened(): ret_val, image = cap.read() if ret_val: input_points, input_black_image = pose.getpoints_vis( image, sess, model_cfg, model_outputs) cv2.imwrite('./test_video' + str(i) + '.jpg', input_black_image) input_points = input_points[0:34] # print(input_points) input_new_coords = pose.roi(input_points) input_new_coords = input_new_coords[0:34] input_new_coords = np.asarray(input_new_coords).reshape(17, 2) coordinate_list.append(input_new_coords) i = i + 1 else: break cap.release() coordinate_list = np.array(coordinate_list) # print(coordinate_list) # print(coordinate_list.shape) print("Lookup Table Created") file = open(args["lookup"], 'wb') pickle.dump({ args["activity"]: coordinate_list, "weights": weights }, file)
def main(): a = Pose() b = [] c = {} with tf.compat.v1.Session() as sess: model_cfg, model_outputs = posenet.load_model(101, sess) cap = cv2.VideoCapture(args["video"]) i = 1 if cap.isOpened() is False: print("error in opening video") while cap.isOpened(): ret_val, image = cap.read() if ret_val: image = cv2.resize(image,(372,495)) input_points,input_black_image = a.getpoints_vis(image,sess,model_cfg,model_outputs) input_points = input_points[0:34] print(input_points) input_new_coords = a.roi(input_points) input_new_coords = input_new_coords[0:34] input_new_coords = np.asarray(input_new_coords).reshape(17,2) b.append(input_new_coords) cv2.imshow("black", input_black_image) cv2.waitKey(1) i = i + 1 else: break cap.release() b = np.array(b) cv2.destroyAllWindows print(b) print(b.shape) print("Lookup Table Created") c[args["activity"]] = b f = open(args["lookup"],'wb') pickle.dump(c,f)