def run(self, outputs={}): start_time = system.now_raw() log.ODM_INFO('Running %s stage' % self.name) self.process(self.args, outputs) # The tree variable should always be populated at this point if outputs.get('tree') is None: raise Exception( "Assert violation: tree variable is missing from outputs dictionary." ) if self.args.time: system.benchmark(start_time, outputs['tree'].benchmarking, self.name) log.ODM_INFO('Finished %s stage' % self.name) self.update_progress_end() # Last stage? if self.args.end_with == self.name or self.args.rerun == self.name: log.ODM_INFO("No more stages to run") return # Run next stage? elif self.next_stage is not None: self.next_stage.run(outputs)
def georeference_with_gcp(self, gcp_file, output_coords_file, output_gcp_file, rerun=False): if not io.file_exists(output_coords_file) or not io.file_exists( output_gcp_file) or rerun: gcp = GCPFile(gcp_file) if gcp.exists(): # Create coords file, we'll be using this later # during georeferencing with open(output_coords_file, 'w') as f: coords_header = gcp.wgs84_utm_zone() f.write(coords_header + "\n") log.ODM_DEBUG("Generated coords file from GCP: %s" % coords_header) # Convert GCP file to a UTM projection since the rest of the pipeline # does not handle other SRS well. rejected_entries = [] utm_gcp = GCPFile( gcp.create_utm_copy( output_gcp_file, filenames=[p.filename for p in self.photos], rejected_entries=rejected_entries, include_extras=False)) if not utm_gcp.exists(): raise RuntimeError( "Could not project GCP file to UTM. Please double check your GCP file for mistakes." ) for re in rejected_entries: log.ODM_WARNING("GCP line ignored (image not found): %s" % str(re)) if utm_gcp.entries_count() > 0: log.ODM_INFO( "%s GCP points will be used for georeferencing" % utm_gcp.entries_count()) else: raise RuntimeError( "A GCP file was provided, but no valid GCP entries could be used. Note that the GCP file is case sensitive (\".JPG\" is not the same as \".jpg\")." ) self.gcp = utm_gcp else: log.ODM_WARNING("GCP file does not exist: %s" % gcp_file) return else: log.ODM_INFO("Coordinates file already exist: %s" % output_coords_file) log.ODM_INFO("GCP file already exist: %s" % output_gcp_file) self.gcp = GCPFile(output_gcp_file) self.georef = ODM_GeoRef.FromCoordsFile(output_coords_file) return self.georef
def run_tasks(self): # curr_task = self.tasks['resize'] # self.tasks['resize'] for id in range(self.initial_task_id, self.final_task_id + 1): # catch task with current id task = self.tasks[str(id)] # update task tracking log.ODM_INFO('Running task %s: %s' % (task.id, task.name)) self.current_task_id = task.id # run task task.state = task.run() if task.state == 2: log.ODM_INFO('Succeeded task %s: %s - %s' % (task.id, task.name, system.now())) else: log.ODM_ERROR('Aborted task %s: %s' % (task.id, task.name))
def georeference_with_gps(self, images_path, output_coords_file, rerun=False): try: if not io.file_exists(output_coords_file) or rerun: location.extract_utm_coords(self.photos, images_path, output_coords_file) else: log.ODM_INFO("Coordinates file already exist: %s" % output_coords_file) self.georef = ODM_GeoRef.FromCoordsFile(output_coords_file) except: log.ODM_WARNING('Could not generate coordinates file. The orthophoto will not be georeferenced.') self.gcp = GCPFile(None) return self.georef