コード例 #1
0
def check_matches(pose):
    global eucl_dis_tresh_torso
    global rotation_tresh_torso
    global eucl_dis_tresh_legs
    global rotation_tresh_legs
    global eucld_dis_shoulders_tresh

    eucl_dis_tresh_torso= 0.18
    rotation_tresh_torso= 19
    eucl_dis_tresh_legs= 0.058
    rotation_tresh_legs= 24
    eucld_dis_shoulders_tresh= 0.125
    path = poses+pose
    model = path+"/json/"+pose+".json"
    #pose = "1"
    #path = '/media/jochen/2FCA69D53AB1BFF41/dataset/poses/pose'+pose
    #model = path+"/json/0.json"
    model_features = common.parse_JSON_multi_person(model)

    true_positive =0
    false_positive =0
    true_negative =0
    false_negative =0

    for json in glob.iglob(path+"/json/*.json"):
        #print (json)
        input_features = common.parse_JSON_multi_person(json)
        (result, error_score, input_transform,something) = multiperson.match(model_features, input_features, True)
        if result == True:
            true_positive = true_positive +1
        else:
            false_negative = false_negative +1
            print ("error at: "+json)

    for json in glob.iglob(path+"/jsonfout/*.json"):
        #print (json)
        input_features = common.parse_JSON_multi_person(json)
        (result, error_score, input_transform,something) = multiperson.match(model_features, input_features, True)
        if result == True:
            false_positive = false_positive +1
            print ("error at: "+json)
        else:
            true_negative = true_negative +1

    precision = 0
    recall =0
    if (true_positive+false_positive) !=0:
        precision = true_positive / (true_positive+false_positive)
    if  (true_positive+false_negative) !=0:
        recall = true_positive / (true_positive+false_negative)

    #******** print small raport ******************

    print ("*************raport of pose "+pose+" ****************")
    print ("true_positive: " + str(true_positive))
    print ("false_positive: "+ str(false_positive))
    print ("true_negative: " + str(true_negative))
    print ("false_negative: "+ str(false_negative))
    print ("recall: "+ str(recall))
    print ("precision: "+ str(precision))
コード例 #2
0
def calculate_pr(pose):
    path = poses+pose
    model = path+"/json/"+pose+".json"
    #pose = "1"
    #path = '/media/jochen/2FCA69D53AB1BFF41/dataset/poses/pose'+pose
    #model = path+"/json/0.json"
    model_features = common.parse_JSON_multi_person(model)

    true_positive =0
    false_positive =0
    true_negative =0
    false_negative =0

    for json in glob.iglob(path+"/json/*.json"):
        #print (json)
        input_features = common.parse_JSON_multi_person(json)
        (result, error_score, input_transform,something) = multiperson.match(model_features, input_features, True)
        if result == True:
            true_positive = true_positive +1
        else:
            false_negative = false_negative +1
            print ("error at: "+json)

    for json in glob.iglob(path+"/jsonfout/*.json"):
        #print (json)
        input_features = common.parse_JSON_multi_person(json)
        (result, error_score, input_transform,something) = multiperson.match(model_features, input_features, True)
        if result == True:
            false_positive = false_positive +1
            print ("error at: "+json)
        else:
            true_negative = true_negative +1

    precision = 0
    recall =0
    if (true_positive+false_positive) !=0:
        precision = true_positive / (true_positive+false_positive)
    if  (true_positive+false_negative) !=0:
        recall = true_positive / (true_positive+false_negative)

    #******** print small raport ******************

    print ("*************raport of pose "+pose+" ****************")
    print ("true_positive: " + str(true_positive))
    print ("false_positive: "+ str(false_positive))
    print ("true_negative: " + str(true_negative))
    print ("false_negative: "+ str(false_negative))
    print ("recall: "+ str(recall))
    print ("precision: "+ str(precision))

    return (precision,recall)
コード例 #3
0
def find_galabal_matches(pose):
    model = galabaljson+pose+".json"
    model_features = common.parse_JSON_multi_person(model)
    count = 0
    os.system("mkdir -p "+galabal+pose)
    os.system("mkdir -p "+galabal+pose+"/json")
    os.system("mkdir -p "+galabal+pose+"/jsonfout")
    os.system("mkdir -p "+galabal+pose+"/fotos")
    os.system("mkdir -p "+galabal+pose+"/fotosfout")
    for json in glob.iglob(galabaljson+"*.json"):
        logger.info(json)
        input_features = common.parse_JSON_multi_person(json)
        (result, error_score, input_transform,something) = multiperson.match(model_features, input_features, normalise=True)
        if result == True:
            place = json.split(".json")[0]
            place = place.split("json/")[1]
            place = place+".json"
            os.system("cp "+json+" "+galabal+pose+"/json/"+place)
            foto = json.split(".json")[0];
            foto = foto.replace("json","fotos")
            foto = foto +".jpg"
            os.system("cp "+foto+" "+galabal+pose+"/fotos/")
            count = count+1
            logger.info("true")
    print ("there are "+str(count)+" matches found")
コード例 #4
0
def check_galabal_matches(pose):
    model = galabal+pose+"/json/"+pose+".json"
    model_features = common.parse_JSON_multi_person(model)
    count =0
    for json in glob.iglob(galabal+pose+"/json/*.json"):
        logger.info(json)
        input_features = common.parse_JSON_multi_person(json)
        (result, error_score, input_transform,something) = multiperson.match(model_features, input_features, normalise=True)
        if result == False:
            count = count +1
            print ("error at: "+json)
    print (str(count)+" foto's werden niet meer herkend")
コード例 #5
0
def find_matches_with(pose):

    global eucl_dis_tresh_torso
    global rotation_tresh_torso
    global eucl_dis_tresh_legs
    global rotation_tresh_legs
    global eucld_dis_shoulders_tresh

    eucl_dis_tresh_torso= 0.18
    rotation_tresh_torso= 19
    eucl_dis_tresh_legs= 0.058
    rotation_tresh_legs= 24
    eucld_dis_shoulders_tresh= 0.125
    if len(pose) == 5 and pose.isdigit():
        model = data+pose+"_keypoints.json"
        model_features = common.parse_JSON_multi_person(model)
        count = 0
        os.system("mkdir -p "+poses+pose)
        os.system("mkdir -p "+poses+pose+"/json")
        os.system("mkdir -p "+poses+pose+"/jsonfout")
        os.system("mkdir -p "+poses+pose+"/fotos")
        os.system("mkdir -p "+poses+pose+"/fotosfout")
        for json in glob.iglob(data+"*_keypoints.json"):
            logger.info(json)
            input_features = common.parse_JSON_multi_person(json)
            (result, error_score, input_transform,something) = multiperson.match(model_features, input_features, normalise=True)
            if result == True:
                place = json.split("_keypoints")[0]
                place = place.split("json/")[1]
                place = place+".json"
                os.system("cp "+json+" "+poses+pose+"/json/"+place)
                foto = json.split("_keypoints")[0];
                foto = foto.replace("json","fotos")
                foto = foto +".jpg"
                os.system("cp "+foto+" "+poses+pose+"/fotos/")
                count = count+1
                logger.info("true")
        print ("there are "+str(count)+" matches found")

    else:
        print ("find_matches_with has wrong input")
コード例 #6
0
def test_script():
    pose = "00100"
    model = poses+pose+"/json/"+pose+".json"
    model_features = common.parse_JSON_multi_person(model)
    input = poses+pose+"/json/01179.json"

    global eucl_dis_tresh_torso
    global rotation_tresh_torso
    global eucl_dis_tresh_legs
    global rotation_tresh_legs
    global eucld_dis_shoulders_tresh

    eucl_dis_tresh_torso= 0.18
    rotation_tresh_torso= 19
    eucl_dis_tresh_legs= 0.058
    rotation_tresh_legs= 24
    eucld_dis_shoulders_tresh= 0.125

    input_features = common.parse_JSON_multi_person(input)
    (result, error_score, input_transform,something) = multiperson.match(model_features, input_features, normalise=True)
    print (result)
コード例 #7
0
def findmatch(filename, id):
    os.system(
        "./build/examples/openpose/openpose.bin -write_keypoint_json /home/jochen/fotos/json -image_dir /home/jochen/fotos/processing -write_images /home/jochen/fotos/calculated_poses/ -no_display"
    )
    os.system("mv -v /home/jochen/fotos/processing/* /home/jochen/fotos/poses")
    filename = filename.rsplit('.')[0]
    inputadr = "/home/jochen/fotos/json/" + filename + '_keypoints.json'
    modeladr = "/home/jochen/dataset/poses/pose" + id + "/json/0.json"

    #find matched
    model_features = parse_JSON_single_person(modeladr)
    input_features = parse_JSON_single_person(inputadr)
    (result, error_score,
     input_transform) = multi_person.match(model_features, input_features,
                                           True)

    print("Match or not: ", result)
    with open(inputadr) as json_file:
        json_decoded = json.load(json_file)
        json_decoded['match'] = bool(result)
        return jsonify(json_decoded)
    return json_data  #jsonify(json_data)
コード例 #8
0
def match_whole(model_pose_features,
                input_pose_features,
                detector,
                matcher,
                model_image,
                input_image,
                plot_us=False,
                plot_mp=False):

    result_pose_matching = multi_person.match(model_pose_features,
                                              input_pose_features,
                                              normalise=True,
                                              plot=plot_mp,
                                              input_image=input_image,
                                              model_image=model_image)
    #logger.debug("---Result pose matching: --")
    #logger.debug(result_pose_matching)

    if result_pose_matching.match_bool:
        #logger.debug(result_pose_matching.matching_permutations)
        logger.info("===> Pose matching succes!")

    else:
        logger.info("No matching poses found, so quit URBAN SCENE MATCHING")
        if plot_us or plot_mp:
            f = plt.figure(figsize=(10, 8))
            fs = 10  #fontsize
            markersize = 3
            f.suptitle("No matching poses found, so quit URBAN SCENE MATCHING",
                       fontsize=10)
            plt.subplot(1, 2, 1)
            plt.imshow(np.asarray(input_image), cmap='gray')
            for i in range(0, len(input_pose_features)):
                plt.plot(*zip(*input_pose_features[i]),
                         marker='o',
                         color='blue',
                         label='pose',
                         ls='',
                         ms=markersize - 1)
            plt.title("input: " + plot_vars.input_name + " (" +
                      str(plot_vars.amount_input_persons) + " pers)",
                      fontsize=fs)

            plt.subplot(1, 2, 2)
            plt.imshow(np.asarray(model_image), cmap='gray')
            for i in range(0, len(model_pose_features)):
                plt.plot(*zip(*model_pose_features[i]),
                         marker='o',
                         color='blue',
                         label='pose',
                         ls='',
                         ms=markersize - 1)
            plt.title("model: " + plot_vars.model_name + " (" +
                      str(plot_vars.amount_model_persons) + " pers)",
                      fontsize=fs)

            plot_name = plot_vars.model_name.split(
                ".")[0] + "_" + plot_vars.input_name.split(".")[0] + "_FALSE"
            plt.savefig('./plots/' + plot_name + '.png')
        return (False, False)
        #exit()

    logger.debug("--- Starting urbanscene matching ---")
    # Loop over all found matching comnbinations
    # And order input poses according to matching model poses
    for matching_permuations, result in result_pose_matching.matching_permutations.items(
    ):
        model_poses = result['model']
        input_poses = result['input']
        #logger.debug(model_poses)
        #logger.debug(input_poses)

        model_image_copy = model_image  #TODO make hard copy ??
        input_image_copy = input_image

        error = match_scene_multi(detector, matcher, model_image_copy,
                                  input_image_copy, model_poses, input_poses,
                                  plot_us)
        if error <= thresholds.AFFINE_TRANS_WHOLE_DISTANCE:
            logger.info(
                "===> MATCH! permutation %s  score:%0.4f (thresh ca %0.4f)",
                matching_permuations, round(error, 4),
                thresholds.AFFINE_TRANS_WHOLE_DISTANCE)
            return (True, True)
        else:
            logger.info(
                "===> NO-MATCH! permutation %s  score:%0.4f (thresh ca %0.4f)",
                matching_permuations, round(error, 4),
                thresholds.AFFINE_TRANS_WHOLE_DISTANCE)
            return (True, False)
コード例 #9
0
json_data_path = '../specials/MP_overlapping/'  #'../json_data/'
images_data_path = '../specials/MP_overlapping/'  #'../img/'

json_data_path = '../json_data/'  #'../json_data/'
images_data_path = '../img/'  #'../img/'

#json_data_path = '../json_data/' #'../json_data/'
#images_data_path = '../img/' #'../img/'
'''
-------------------- MULTI PERSON -------------------------------------
'''

model = "3"  # "duo3"  #  "09958" #
input = "kleuter9"  #"duo4"  # "08425"  #
model_json = json_data_path + model + '.json'
input_json = json_data_path + input + '_keypoints.json'
model_image = images_data_path + model + '.png'
input_image = images_data_path + input + '.jpg'
model_features = parse_JSON_multi_person(model_json)
input_features = parse_JSON_multi_person(input_json)

#plot_poses(np.vstack(model_features), np.vstack(input_features), model_image_name=model_image, input_image_name=input_image)
matchresult = match(model_features,
                    input_features,
                    normalise=True,
                    plot=True,
                    model_image=model_image,
                    input_image=input_image)
logger.info("Match result: %s", str(matchresult.match_bool))
plt.show()