Exemplo n.º 1
0
    def run_triangulation():
        '''
        global src_points, dst_points




        add 4 corners
        src_points.append([0, 0])
        src_points.append([0, src_img_height-1])
        src_points.append([src_img_width-1, src_img_height-1])
        src_points.append([src_img_width-1, 0])

        dst_points.append([0, 0])
        dst_points.append([0, dst_img_height-1])
        dst_points.append([dst_img_width-1, dst_img_height-1])
        dst_points.append([dst_img_width-1, 0])
        '''
        src_points = [[275, 456], [301, 442], [334, 451], [304, 463], [403, 453], [436, 433], [466, 450], [440, 462], [331, 533], [366, 490], [412, 521], [371, 546], [322, 585], [365, 568], [418, 579], [366, 596], [371, 284], [372, 685], [510, 497], [245, 516], [251, 362], [501, 343], [283, 630], [483, 623], [574, 663], [726, 724], [205, 722], [120, 862], [414, 771], [405, 905], [103, 990], [756, 970], [0, 0], [0, 1023], [767, 1023], [767, 0]]

        print '-'*20
        print src_points

        dst_points = [[216, 95], [226, 84], [234, 96], [221, 106], [264, 109], [280, 94], [295, 108], [282, 118], [207, 134], [218, 123], [237, 136], [217, 148], [203, 158], [216, 154], [253, 164], [217, 173], [275, 51], [237, 211], [343, 160], [181, 145], [212, 77], [349, 94], [197, 194], [310, 196], [377, 225], [378, 301], [178, 240], [147, 306], [275, 245], [269, 296], [132, 344], [373, 366], [0, 0], [0, 412], [549, 412], [549, 0]]

        print '-'*20
        print dst_points

        src_img = Image.open('src.jpg')
        dst_img = Image.open('dst.jpg')

        morph_baby(src_img, dst_img, src_points, dst_points, 0.02)
    def run_triangulation():
        global src_points, dst_points, turn, L_1, E_1, B_1, B_2

        try:
            frame_amount_str = E_1.get()
            frame_amount = int(frame_amount_str)
        except ValueError as e:
            print 'bad frame_amount'
            return

        if turn == 1:
            return

        if len(src_points) == 0:
            return

        L_1.destroy()
        B_1.destroy()
        B_2.destroy()
        E_1.destroy()

        #add 4 corners
        src_points.append([0, 0])
        src_points.append([0, src_img_height - 1])
        src_points.append([src_img_width - 1, src_img_height - 1])
        src_points.append([src_img_width - 1, 0])

        dst_points.append([0, 0])
        dst_points.append([0, dst_img_height - 1])
        dst_points.append([dst_img_width - 1, dst_img_height - 1])
        dst_points.append([dst_img_width - 1, 0])

        print '*' * 20
        print src_points
        src_points = purge_duplicate_points(src_points)
        print src_points

        print '*' * 20
        print dst_points
        dst_points = purge_duplicate_points(dst_points)
        print dst_points

        src_points_to_pass = [i[:] for i in src_points]
        dst_points_to_pass = [i[:] for i in dst_points]

        step = 1.0 / frame_amount

        morph_baby(src_img_file_name, dst_img_file_name, src_points_to_pass,
                   dst_points_to_pass, step, result_folder)

        init_widgets()
Exemplo n.º 3
0
    def run_triangulation():
        global src_points, dst_points

        #add 4 corners
        src_points.append([0, 0])
        src_points.append([0, src_img_height - 1])
        src_points.append([src_img_width - 1, src_img_height - 1])
        src_points.append([src_img_width - 1, 0])

        dst_points.append([0, 0])
        dst_points.append([0, dst_img_height - 1])
        dst_points.append([dst_img_width - 1, dst_img_height - 1])
        dst_points.append([dst_img_width - 1, 0])

        print '-' * 20
        print src_points

        print '-' * 20
        print dst_points

        src_img = Image.open('src.jpg')
        dst_img = Image.open('dst.jpg')

        morph_baby(src_img, dst_img, src_points, dst_points, 0.2)
Exemplo n.º 4
0
    def run_triangulation():
        '''
        global src_points, dst_points, turn

        if turn == 1:
            return

        if len(src_points) == 0:
            return


        #add 4 corners
        src_points.append([0, 0])
        src_points.append([0, src_img_height-1])
        src_points.append([src_img_width-1, src_img_height-1])
        src_points.append([src_img_width-1, 0])

        dst_points.append([0, 0])
        dst_points.append([0, dst_img_height-1])
        dst_points.append([dst_img_width-1, dst_img_height-1])
        dst_points.append([dst_img_width-1, 0])

        
        print '*'*20
        print src_points
        src_points = purge_duplicate_points(src_points)
        print src_points        
        
        print '*'*20
        print dst_points
        dst_points = purge_duplicate_points(dst_points)
        print dst_points

        '''

        src_points = [[303, 445], [436, 447], [350, 531], [384,
                                                           527], [328, 583],
                      [378, 582], [426, 580], [368, 487], [365,
                                                           457], [368, 279],
                      [236, 487], [523, 467], [378, 673], [267,
                                                           599], [494, 601],
                      [264, 347], [485, 334], [369, 347], [368,
                                                           407], [298, 407],
                      [435, 395], [469, 530], [291, 540], [313,
                                                           654], [469, 645],
                      [251, 546], [516, 537], [243, 398], [515,
                                                           390], [448, 300],
                      [297, 309], [617, 673], [728, 703], [749,
                                                           787], [759, 903],
                      [273, 682], [199, 712], [156, 774], [122,
                                                           865], [103, 982],
                      [415, 865], [279, 805], [523, 779], [566, 950],
                      [249, 946], [0, 0], [0, 1023], [767, 1023], [767, 0]]

        dst_points = [[266, 142], [322, 137], [284, 185], [307,
                                                           185], [281, 211],
                      [299, 211], [317, 206], [294, 167], [296,
                                                           153], [292, 56],
                      [237, 146], [369, 137], [301, 240], [260,
                                                           206], [350, 200],
                      [234, 83], [353, 78], [292, 86], [293, 125], [253, 129],
                      [329, 122], [335, 174], [266, 180], [277,
                                                           225], [333, 225],
                      [247, 176], [358, 178], [230, 113], [363, 101],
                      [326, 58], [256, 62], [413, 229], [475, 256], [506, 300],
                      [520, 348], [240, 249], [204, 274], [180,
                                                           305], [174, 336],
                      [175, 375], [321, 327], [257, 293], [389,
                                                           280], [396, 355],
                      [244, 355], [0, 0], [0, 412], [619, 412], [619, 0]]

        src_points_to_pass = [i[:] for i in src_points]
        dst_points_to_pass = [i[:] for i in dst_points]

        src_img = Image.open('src.jpg')
        dst_img = Image.open('dst.jpg')

        morph_baby(src_img, dst_img, src_points_to_pass, dst_points_to_pass,
                   0.2)