Exemplo n.º 1
0
    def compute_ori(self, cur_data):
        """Compute Orientations """

        total_time = 0.0

        # -------------------------------------------------------------------------
        # Test using the test function
        start_time = time.clock()
        oris = self._test_multibatch(self.graph_ori, cur_data)
        end_time = time.clock()
        compute_time = (end_time - start_time) * 1000.0
        print("Time taken to compute is {} ms".format(
            compute_time
        ))
        total_time += compute_time

        # update keypoints and save as new
        start_time = time.clock()
        kps = cur_data["kps"]
        for idxkp in xrange(len(kps)):
            kps[idxkp][IDX_ANGLE] = oris[idxkp] * 180.0 / np.pi % 360.0
            kps[idxkp] = update_affine(kps[idxkp])
        end_time = time.clock()
        update_time = (end_time - start_time) * 1000.0
        print("Time taken to update is {} ms".format(
            update_time
        ))
        total_time += update_time
        print("Total time for orientation is {} ms".format(total_time))
        # save as new keypoints
        return kps, cur_data
Exemplo n.º 2
0
    def _compute_ori(self):
        """Compute Orientations """

        total_time = 0.0

        # Read image
        start_time = time.clock()
        cur_data = self.dataset.load_data()
        end_time = time.clock()
        load_time = (end_time - start_time) * 1000.0

        if self.config.verbose:
            print("Time taken to load patches is {} ms".format(load_time))
        total_time += load_time

        # -------------------------------------------------------------------------
        # Test using the test function
        start_time = time.clock()
        oris = self._test_multibatch(cur_data)
        end_time = time.clock()
        compute_time = (end_time - start_time) * 1000.0

        if self.config.verbose:
            print("Time taken to compute is {} ms".format(compute_time))
        total_time += compute_time

        # update keypoints and save as new
        start_time = time.clock()
        kps = cur_data["kps"]
        for idxkp in xrange(len(kps)):
            kps[idxkp][IDX_ANGLE] = oris[idxkp] * 180.0 / np.pi % 360.0
            kps[idxkp] = update_affine(kps[idxkp])
        end_time = time.clock()
        update_time = (end_time - start_time) * 1000.0

        if self.config.verbose:
            print("Time taken to update is {} ms".format(update_time))
        total_time += update_time

        if self.config.verbose:
            print("Total time for orientation is {} ms".format(total_time))

        # save as new keypoints
        saveKpListToTxt(kps, self.config.test_kp_file,
                        self.config.test_out_file)
Exemplo n.º 3
0
    def _compute_ori(self):
        """Compute Orientations """

        total_time = 0.0
        global_start_time = time.time()

        fail_scene = ['v_feast']
        for scene_name in cst.SCENE_LIST:
            duration = time.time() - global_start_time
            print('****** %s ****** %d:%02d' %
                  (scene_name, duration / 60, duration % 60))
            if not os.path.exists(os.path.join(cst.ORI_DIR, scene_name)):
                os.makedirs(os.path.join(cst.ORI_DIR, scene_name))
            for img_key in range(1, cst.MAX_IMG_NUM + 1):
                print(img_key)
                kp_fn = os.path.join(cst.KP_DIR, scene_name,
                                     '%d_kp.txt' % (img_key))
                img_fn = os.path.join(cst.DATA_DIR, scene_name,
                                      '%d.ppm' % (img_key))
                new_kp_fn = os.path.join(cst.ORI_DIR, scene_name,
                                         '%d_kp.txt' % (img_key))

                if ((scene_name == 'v_feast' and img_key == 6)
                        or (scene_name == 'v_wall' and img_key == 6)):
                    if cst.DATA == 'hpatches':
                        continue
                # Read image
                start_time = time.clock()
                cur_data = self.dataset.my_load_data(img_fn, kp_fn,
                                                     cst.NEW_SIZE)
                end_time = time.clock()
                load_time = (end_time - start_time) * 1000.0
                #print("Time taken to load patches is {} ms".format(
                #    load_time
                #))
                total_time += load_time

                # -------------------------------------------------------------------------
                # Test using the test function
                start_time = time.clock()
                oris = self._test_multibatch(cur_data)
                end_time = time.clock()
                compute_time = (end_time - start_time) * 1000.0
                #print("Time taken to compute is {} ms".format(
                #    compute_time
                #))
                total_time += compute_time

                # update keypoints and save as new
                start_time = time.clock()
                kps = cur_data["kps"]
                for idxkp in xrange(len(kps)):
                    kps[idxkp][IDX_ANGLE] = oris[idxkp] * 180.0 / np.pi % 360.0
                    kps[idxkp] = update_affine(kps[idxkp])
                end_time = time.clock()
                update_time = (end_time - start_time) * 1000.0
                #print("Time taken to update is {} ms".format(
                #    update_time
                #))
                total_time += update_time
                #print("Total time for orientation is {} ms".format(total_time))

                # save as new keypoints
                saveKpListToTxt(kps, kp_fn, new_kp_fn)
Exemplo n.º 4
0
    def _compute_ori(self):
        """Compute Orientations """

        total_time = 0.0
        global_start_time = time.time()

        for scene_name in cst.SCENE_LIST:
            print('scene_name: %s'%scene_name)
            img_dir = '%s/%s/'%(cst.DATA_DIR, scene_name)
            img_list = [ l for l in sorted(os.listdir(img_dir)) if l[-3:]=='png']
            img_num = len(img_list)

            duration = time.time() - global_start_time
            print('****** %s ****** %d:%02d'%(scene_name, duration/60,
                duration%60))
            if not os.path.exists(os.path.join(cst.ORI_DIR, scene_name)):
                os.makedirs(os.path.join(cst.ORI_DIR, scene_name))

            for img_id in range(img_num):
                root_name = '%04d'%img_id

                kp_fn = os.path.join(cst.KP_DIR, scene_name, '%s.txt'%(root_name))
                img_fn = os.path.join(img_dir, '%s.png'%root_name)
                new_kp_fn = os.path.join(cst.ORI_DIR, scene_name, '%s.txt'%(root_name))

                # Read image
                start_time = time.clock()
                cur_data = self.dataset.my_load_data(img_fn, kp_fn, cst.NEW_SIZE)
                end_time = time.clock()
                load_time = (end_time - start_time) * 1000.0
                #print("Time taken to load patches is {} ms".format(
                #    load_time
                #))
                total_time += load_time

                # -------------------------------------------------------------------------
                # Test using the test function
                start_time = time.clock()
                oris = self._test_multibatch(cur_data)
                end_time = time.clock()
                compute_time = (end_time - start_time) * 1000.0
                #print("Time taken to compute is {} ms".format(
                #    compute_time
                #))
                total_time += compute_time

                # update keypoints and save as new
                start_time = time.clock()
                kps = cur_data["kps"]
                for idxkp in xrange(len(kps)):
                    kps[idxkp][IDX_ANGLE] = oris[idxkp] * 180.0 / np.pi % 360.0
                    kps[idxkp] = update_affine(kps[idxkp])
                end_time = time.clock()
                update_time = (end_time - start_time) * 1000.0
                #print("Time taken to update is {} ms".format(
                #    update_time
                #))
                total_time += update_time
                #print("Total time for orientation is {} ms".format(total_time))

                # save as new keypoints
                saveKpListToTxt( kps, kp_fn, new_kp_fn)