Exemplo n.º 1
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")
Exemplo n.º 2
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))
Exemplo n.º 3
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")
Exemplo n.º 4
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)
Exemplo n.º 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")
Exemplo n.º 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)
plot_us = True  # plot urban scene
plot_mp = False  # plot multi pose
plot_vars.input_name = input_name
plot_vars.model_name = model_name
plot_vars.model_path = path_img + model_name
plot_vars.input_path = path_img + input_name
plot_vars.write_img = False
global crop
global correction
crop = True
correction = True

logger.debug("---Starting pose matching --")
if include_keypoints:
    model_pose_features = common.parse_JSON_multi_person(
        path_json + model_name.split('.')[0] + '_keypoints' +
        '.json')  # + '_keypoints'
    input_pose_features = common.parse_JSON_multi_person(
        path_json + input_name.split('.')[0] + '_keypoints' + '.json')
else:
    model_pose_features = common.parse_JSON_multi_person(
        path_json + model_name.split('.')[0].replace('fotos', 'json') +
        '.json')  # + '_keypoints'
    input_pose_features = common.parse_JSON_multi_person(
        path_json + input_name.split('.')[0].replace('fotos', 'json') +
        '.json')

result_whole = matching.match_whole(model_pose_features, input_pose_features,
                                    detector, matcher, model_image,
                                    input_image, plot_us, plot_mp)
Exemplo n.º 8
0
        diff = np.abs(A - B)
        new_distance = dist(A, B)
        new_distance = ((diff[0])**2 + diff[1]**2)**0.5

        if new_distance > distance:
            distance = new_distance
            biggest = id

        id = id + 1

    return biggest


# test_file = path + "testje.json"
# poses = common.parse_JSON_multi_person(test_file)
# filter_poses(poses, test_file)

f = []
for (dirpath, dirnames, filenames) in walk(path):
    f.extend(filenames)
    break

print(f)
for f_name in f:
    poses = common.parse_JSON_multi_person(path + f_name)
    lenght = len(poses)

    if lenght > 1:
        filter_poses(poses, path + f_name)
logger.info('using ' + feature_name )

plot = True
include_keypoints = False

for i in range(start_counter, end_counter+1):

    model_image = cv2.imread(path_img + model_name + str(i) + img_type, cv2.IMREAD_GRAYSCALE)
    if model_image is None:
        logger.info('Failed to load fn1: %s', model_name + str(i) + img_type)
        continue
        #sys.exit(1)

    #model_pose_features = common.parse_JSON_single_person(path_json + model_name + str(i) + '_keypoints' + '.json')  # + '_keypoints'
    if include_keypoints:
        model_pose_features = common.parse_JSON_multi_person(path_json + model_name + str(i) + '_keypoints' + '.json')  # + '_keypoints'
    else:
        model_pose_features = common.parse_JSON_multi_person(
            path_json + model_name + str(i) + '.json')  # + '_keypoints'

    intermediate_result = {}

    for j in range(start_counter, end_counter+1):
        logger.info("@@@@@@ Matching model(%d) with input(%d) @@@@@@@@@", i, j)
        if i == j:
            logger.info("--> Skip: don't compare the same image")
            continue  # don't compare the same image

        input_image = cv2.imread(path_img + input_name + str(j) + img_type, cv2.IMREAD_GRAYSCALE)
        if input_image is None:
            logger.info('Failed to load fn2:', input_name + str(j) + img_type)
Exemplo n.º 10
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()