def check_pose_data(pose): model = path + pose + "/json/1.json" model_features = parse_openpose_json.parse_JSON_single_person(model) count = 0 for json in glob.iglob(path + pose + "/json/*"): input_features = parse_openpose_json.parse_JSON_single_person(json) (result, error_score, input_transform) = pose_match.single_person(model_features, input_features, True) if result == False: count = count + 1 return count
def get_score(input_points, model_points, det_view, model_image, input_image): #plt.ion input_features = input_points catch_later = det_view torso_value = 0 #test_pic = cv2.imread("test.jpg") #model_features = get_points(test_pic) match_result, torso_value = pose_match.single_person( model_points, input_features, True) print("->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", torso_value) return torso_value
def sort_pose_from_data(model): model_features = parse_openpose_json.parse_JSON_single_person(model) number = 0 for json in glob.iglob(data + "set*/a/json/*"): input_features = parse_openpose_json.parse_JSON_single_person(json) (result, error_score, input_transform) = pose_match.single_person(model_features, input_features, True) if result == True: number = number + 1 os.system("cp " + json + " " + matched + "/json") foto = json.split("_")[0] foto = foto.replace("json", "image") foto = foto + ".png" os.system("cp " + foto + " " + matched + "/image")
def check_pose_score(pose): count = check_pose_data(pose) model = path + pose + "/json/1.json" model_features = parse_openpose_json.parse_JSON_single_person(model) number = 0 for json in glob.iglob(path + "*/json/*"): if json.split("/json/")[0].split("/poses/")[1] != pose: input_features = parse_openpose_json.parse_JSON_single_person(json) (result, error_score, input_transform) = pose_match.single_person( model_features, input_features, True) if result == True: number = number + 1 os.system("cp " + json + " " + matched + "/json") foto = json.split(".json")[0] foto = foto.replace("json", "fotos") foto = foto + ".png" os.system("cp " + foto + " " + matched + "/image")
def reorder_json_fout(): moved = 0 for i in range(1, 58): pose = "pose" + str(i) for json in glob.iglob(path + pose + "/jsonfout/*"): input_features = parse_openpose_json.parse_JSON_single_person(json) for x in range(1, 58): pose2 = "pose" + str(x) model = path + pose2 + "/json/1.json" model_features = parse_openpose_json.parse_JSON_single_person( model) (result, error_score, input_transform) = pose_match.single_person( model_features, input_features, True) if result == True: os.system("mv " + json + " " + path + pose + "/json/") foto = json.split(".")[0] foto = foto.replace("json", "fotos") foto = foto + ".png" os.system("mv " + foto + " " + path + pose + "/fotos/") moved = moved + 1 print("finished and moved : " + str(moved))
def clean_dataset(): #THRESHOLDS for i in range(1, 9): pose = "pose" + str(i) os.system("mkdir -p " + path + pose + "/fotosfout") os.system("mkdir -p " + path + pose + "/jsonfout") model = path + pose + "/json/0.json" model_features = parse_openpose_json.parse_JSON_single_person(model) count = 0 for json in glob.iglob(path + pose + "/json/*"): count = 0 input_features = parse_openpose_json.parse_JSON_single_person(json) (result, error_score, input_transform) = pose_match.single_person( model_features, input_features, True) if result == False: os.system("mv " + json + " " + path + pose + "/jsonfout/") foto = json.split(".")[0] foto = foto.replace("json", "fotos") foto = foto + ".png" os.system("mv " + foto + " " + path + pose + "/fotosfout/") count = count + 1
json_data_path = 'data/json_data/' images_data_path = 'data/image_data/' json_data_path = 'data/json_data/' images_data_path = 'data/image_data/' model = "coach" input = "right" model_json = json_data_path + model + '.json' input_json = json_data_path + input + '.json' model_image = images_data_path + model + '.png' input_image = images_data_path + input + '.png' model_features = parse_openpose_json.parse_JSON_single_person(model_json) input_features = parse_openpose_json.parse_JSON_single_person(input_json) # model_features = parse_openpose_json.parse_JSON_single_person('data/json_data/foto1.json') # input_features = parse_openpose_json.parse_JSON_single_person('data/json_data/model1.json') match_result = pose_match.single_person(model_features, input_features, True) model_features = parse_openpose_json.parse_JSON_single_person(model_json) input_features = parse_openpose_json.parse_JSON_single_person(input_json) pose_match.plot_single_person(model_features, input_features, model_image, input_image) #plt.show()
def statistics(): for i in range(1, 7): affine_right = 0 affine_rightmissed = 0 affine_wrong = 0 angle_right = 0 angle_rightmissed = 0 angle_wrong = 0 affinev2_right = 0 affinev2_rightmissed = 0 affinev2_wrong = 0 total_jsonfout = 0 pose = "pose" + str(i) model = path + pose + "/json/0.json" model_features = parse_openpose_json.parse_JSON_single_person(model) for json in glob.iglob(path + pose + "/json/*"): input_features = parse_openpose_json.parse_JSON_single_person(json) (result, error_score, input_transform) = pose_match.single_person( model_features, input_features, True) if result == True: affine_right += 1 else: affine_rightmissed += 1 (result, error_score, input_transform) = pose_match.single_person_v2( model_features, input_features, True) if result == True: affinev2_right += 1 else: affinev2_rightmissed += 1 primary_angles = calcAngle.prepareangles(model_features) secondary_angles = calcAngle.prepareangles(input_features) result = calcAngle.succes(primary_angles, secondary_angles) if result == True: angle_right += 1 else: angle_rightmissed += 1 for json in glob.iglob(path + pose + "/jsonfout/*"): input_features = parse_openpose_json.parse_JSON_single_person(json) (result, error_score, input_transform) = pose_match.single_person( model_features, input_features, True) if result == True: affine_wrong += 1 (result, error_score, input_transform) = pose_match.single_person_v2( model_features, input_features, True) if result == True: affinev2_wrong += 1 primary_angles = calcAngle.prepareangles(model_features) secondary_angles = calcAngle.prepareangles(input_features) result = calcAngle.succes(primary_angles, secondary_angles) if result == True: angle_wrong += 1 total_jsonfout += 1 print( "******************************************************************************" )