def CreateDJICsv(self, rows_list, csv_raw): ''' DJI Drone: Create csv result files for each record ''' QApplication.setOverrideCursor(Qt.WaitCursor) QApplication.processEvents() folder = getVideoFolder(self.video_file) qgsu.createFolderByName(folder, "klv") qgsu.createFolderByName(folder, "csv") self.klv_folder = os.path.join(folder, "klv") out_csv = os.path.join(folder, "csv") for values in rows_list: timestamp = int(time.time() * 1000.0) filename = "_".join(["recording", str(timestamp)]) out_record = os.path.join(out_csv, filename + ".csv") # The column that corresponds to the stop is also removed with open(csv_raw, 'r') as f_input, open(out_record, 'w', newline='') as f_output: csv_input = csv.reader(f_input) csv.writer(f_output).writerows(itertools.islice(csv_input, 0, 1)) csv.writer(f_output).writerows(itertools.islice(csv_input, int(values[0]), int(values[-1]))) self.cmb_telemetry.addItem(filename, out_record) self.bt_createMISB.setEnabled(True) QApplication.restoreOverrideCursor() QApplication.processEvents() return
def CreateDJICsv(self, rows_list, csv_raw, time_list): """ DJI Drone: Create csv result files for each record """ QApplication.setOverrideCursor(Qt.WaitCursor) QApplication.processEvents() folder = getVideoFolder(self.video_file) qgsu.createFolderByName(folder, "klv") qgsu.createFolderByName(folder, "csv") self.klv_folder = os.path.join(folder, "klv") out_csv = os.path.join(folder, "csv") for idx, val in enumerate(rows_list): filename = "_".join(["recording", time_list[idx]]) out_record = os.path.join(out_csv, filename + ".csv") # The column that corresponds to the stop is also removed with open(csv_raw, "r", encoding=encoding) as f_input, open( out_record, "w", newline="", encoding=encoding) as f_output: # Prevent “_csv.Error: line contains NULL byte data = f_input.read() data = data.replace("\x00", "?") csv_input = csv.reader(StringIO(data)) csv.writer(f_output).writerows( itertools.islice(csv_input, 0, 1)) csv.writer(f_output).writerows( itertools.islice(csv_input, int(val[0]), int(val[-1]))) self.cmb_telemetry.addItem(filename, out_record) self.bt_createMISB.setEnabled(True) QApplication.restoreOverrideCursor() QApplication.processEvents() return
def getVideoFolder(video_file): ''' Get or create Video Temporal folder ''' home = os.path.expanduser("~") qgsu.createFolderByName(home, "QGIS_FMV") root, _ = os.path.splitext(os.path.basename(video_file)) homefmv = os.path.join(home, "QGIS_FMV") qgsu.createFolderByName(homefmv, root) return os.path.join(homefmv, root)
def createMosaic(self, value): ''' Function for create Video Mosaic ''' home = os.path.expanduser("~") qgsu.createFolderByName(home, "QGIS_FMV") homefmv = os.path.join(home, "QGIS_FMV") root, ext = os.path.splitext(os.path.basename(self.fileName)) qgsu.createFolderByName(homefmv, root) self.createingMosaic = value # Create Group CreateGroupByName() return
def georeferencingVideo(parent): """ Extract Current Frame Thread """ image = parent.videoWidget.currentFrame() folder = getVideoFolder(parent.fileName) qgsu.createFolderByName(folder, "mosaic") out = os.path.join(folder, "mosaic") position = str(parent.player.position()) taskGeoreferencingVideo = QgsTask.fromFunction('Georeferencing Current Frame Task', GeoreferenceFrame, image=image, output=out, p=position, on_finished=parent.finishedTask, flags=QgsTask.CanCancel) QgsApplication.taskManager().addTask(taskGeoreferencingVideo) return