예제 #1
0
 def _load_mask_list(self):
     """Load mask list from mask_list.txt or list masks/ folder."""
     mask_list_file = os.path.join(self.data_path, 'mask_list.txt')
     if os.path.isfile(mask_list_file):
         with io.open_rt(mask_list_file) as fin:
             lines = fin.read().splitlines()
         self._set_mask_list(lines)
     else:
         self._set_mask_path(os.path.join(self.data_path, 'masks'))
예제 #2
0
 def _load_image_list(self):
     """Load image list from image_list.txt or list image/ folder."""
     image_list_file = os.path.join(self.data_path, 'image_list.txt')
     if os.path.isfile(image_list_file):
         with io.open_rt(image_list_file) as fin:
             lines = fin.read().splitlines()
         self._set_image_list(lines)
     else:
         self._set_image_path(os.path.join(self.data_path, 'images'))
예제 #3
0
    def images_with_gps(self):
        with io.open_rt(self._image_list_path()) as csvfile:
            image_reader = csv.reader(
                csvfile,
                delimiter='\t',
                quotechar='"',
                quoting=csv.QUOTE_MINIMAL)

            for image, lat, lon in image_reader:
                yield image, float(lat), float(lon)
예제 #4
0
    def load_ground_control_points(self):
        """Load ground control points.

        It uses reference_lla to convert the coordinates
        to topocentric reference frame.
        """
        exif = {image: self.load_exif(image) for image in self.images()}
        reference = self.load_reference()

        with io.open_rt(self._ground_control_points_file()) as fin:
            return io.read_ground_control_points_list(fin, reference, exif)
예제 #5
0
    def load_exif(self, image):
        """
        Return extracted exif information, as dictionary, usually with fields:

        ================  =====  ===================================
        Field             Type   Description
        ================  =====  ===================================
        width             int    Width of image, in pixels
        height            int    Height of image, in pixels
        focal_prior       float  Focal length (real) / sensor width
        ================  =====  ===================================

        :param image: Image name, with extension (i.e. 123.jpg)
        """
        with io.open_rt(self._exif_file(image)) as fin:
            return json.load(fin)
예제 #6
0
 def _transform_dense_point_cloud(self, data, transformation, output):
     """Apply a transformation to the merged point cloud."""
     A, b = transformation[:3, :3], transformation[:3, 3]
     input_path = os.path.join(data._depthmap_path(), 'merged.ply')
     output_path = os.path.join(data.data_path, output)
     with io.open_rt(input_path) as fin:
         with io.open_wt(output_path) as fout:
             for i, line in enumerate(fin):
                 if i < 13:
                     fout.write(line)
                 else:
                     x, y, z, nx, ny, nz, red, green, blue = line.split()
                     x, y, z = np.dot(A, map(float, [x, y, z])) + b
                     nx, ny, nz = np.dot(A, map(float, [nx, ny, nz]))
                     fout.write(
                         "{} {} {} {} {} {} {} {} {}\n".format(
                             x, y, z, nx, ny, nz, red, green, blue))
예제 #7
0
 def load_tracks_graph(self, filename=None):
     """Return graph (networkx data structure) of tracks"""
     with io.open_rt(self._tracks_graph_file(filename)) as fin:
         return load_tracks_graph(fin)
예제 #8
0
 def load_reconstruction(self, filename=None):
     with io.open_rt(self._reconstruction_file(filename)) as fin:
         reconstructions = io.reconstructions_from_json(io.json_load(fin))
     return reconstructions
예제 #9
0
 def load_undistorted_reconstruction(self):
     filename = os.path.join(self.data_path, "reconstruction.json")
     with io.open_rt(filename) as fin:
         return io.reconstructions_from_json(io.json_load(fin))
예제 #10
0
 def load_undistorted_shot_ids(self):
     filename = os.path.join(self.data_path, "undistorted_shot_ids.json")
     with io.open_rt(filename) as fin:
         return io.json_load(fin)
예제 #11
0
 def load_report(self, path):
     """Load a report file as a string."""
     with io.open_rt(os.path.join(self._report_path(), path)) as fin:
         return fin.read()
예제 #12
0
 def images_with_gps(self):
     with io.open_rt(self._image_list_path()) as csvfile:
         for line in csvfile:
             image, lat, lon = line.split(u"\t")
             yield image, float(lat), float(lon)
예제 #13
0
파일: dataset.py 프로젝트: Avvir/OpenSfM
 def load_match_adjacency_list(self):
     with io.open_rt(self._match_adjacency_list_file()) as fin:
         obj = json.load(fin)
         return obj
예제 #14
0
 def load_camera_models_overrides(self):
     """Load camera models overrides data."""
     with io.open_rt(self._camera_models_overrides_file()) as fin:
         obj = json.load(fin)
         return io.cameras_from_json(obj)
예제 #15
0
 def load_camera_models(self):
     """Return camera models data"""
     with io.open_rt(self._camera_models_file()) as fin:
         obj = json.load(fin)
         return io.cameras_from_json(obj)
예제 #16
0
 def load_camera_models_overrides(self):
     """Load camera models overrides data."""
     with io.open_rt(self._camera_models_overrides_file()) as fin:
         obj = json.load(fin)
         return io.cameras_from_json(obj)
예제 #17
0
 def load_reference_lla(self):
     with io.open_rt(self._reference_lla_path()) as fin:
         return io.json_load(fin)
예제 #18
0
 def load_reconstruction(self, filename=None):
     with io.open_rt(self._reconstruction_file(filename)) as fin:
         reconstructions = io.reconstructions_from_json(io.json_load(fin))
     return reconstructions
예제 #19
0
 def load_exif(self, image):
     """Load pre-extracted image exif metadata."""
     with io.open_rt(self._exif_file(image)) as fin:
         return json.load(fin)
예제 #20
0
 def load_reference_lla(self):
     with io.open_rt(self._reference_lla_path()) as fin:
         return io.json_load(fin)
예제 #21
0
 def load_rig_assignments(self):
     """Return rig assignments  data"""
     with io.open_rt(self._rig_assignments_file()) as fin:
         return json.load(fin)
예제 #22
0
 def load_camera_models(self):
     """Return camera models data"""
     with io.open_rt(self._camera_models_file()) as fin:
         obj = json.load(fin)
         return io.cameras_from_json(obj)
예제 #23
0
파일: dataset.py 프로젝트: Avvir/OpenSfM
 def load_tracks_graph(self, filename=None):
     """Return graph (networkx data structure) of tracks"""
     with io.open_rt(self._tracks_graph_file(filename)) as fin:
         return tracking.load_tracks_graph(fin)
예제 #24
0
 def load_exif_overrides(self):
     """Load EXIF overrides data."""
     with io.open_rt(self._exif_overrides_file()) as fin:
         return json.load(fin)
예제 #25
0
 def images_with_gps(self):
     with io.open_rt(self._image_list_path()) as csvfile:
         for line in csvfile:
             image, lat, lon = line.split(u'\t')
             yield image, float(lat), float(lon)
예제 #26
0
 def load_exif_overrides(self):
     """Load EXIF overrides data."""
     with io.open_rt(self._exif_overrides_file()) as fin:
         return json.load(fin)
예제 #27
0
파일: dataset.py 프로젝트: Avvir/OpenSfM
 def load_report(self, path):
     """Load a report file as a string."""
     with io.open_rt(os.path.join(self._report_path(), path)) as fin:
         return fin.read()
예제 #28
0
import json

from opensfm import context
from opensfm import io

with io.open_rt(context.SENSOR) as f:
    sensor_data = io.json_load(f)

# Convert model types to lower cases for easier query
keys = [k.lower() for k in sensor_data.keys()]
values = sensor_data.values()
sensor_data = dict(zip(keys, values))
예제 #29
0
 def load_rig_models(self):
     """Return rig models data"""
     with io.open_rt(self._rig_models_file()) as fin:
         return json.load(fin)