small update to scripts

This commit is contained in:
Vladyslav Usenko 2019-09-13 18:05:25 +02:00
parent 6ef6227dc4
commit 71d94219e0
4 changed files with 35 additions and 7 deletions

View File

@ -3,6 +3,7 @@
import sys
import os
import rospy
import argparse
from geometry_msgs.msg import TransformStamped
@ -34,11 +35,18 @@ def listener():
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Record Motion Capture messages from ROS (/vrpn_client/raw_transform).')
parser.add_argument('-d', '--dataset-path', required=True, help="Path to store the result")
args = parser.parse_args()
dataset_path = args.dataset_path
out_file = None
time_offset = None
if not os.path.exists(sys.argv[1]):
os.makedirs(sys.argv[1])
if not os.path.exists(dataset_path):
os.makedirs(dataset_path)
out_file = open(sys.argv[1] + '/data.csv', 'w')
out_file.write('#timestamp [ns], p_RS_R_x [m], p_RS_R_y [m], p_RS_R_z [m], q_RS_w [], q_RS_x [], q_RS_y [], q_RS_z []\n')

View File

@ -6,8 +6,13 @@ import numpy as np
import os
from string import Template
import cv2
import argparse
dataset_path = sys.argv[1]
parser = argparse.ArgumentParser(description='Convert KITTI calibration to basalt and save it int the dataset folder as basalt_calib.json.')
parser.add_argument('-d', '--dataset-path', required=True, help="Path to the dataset in KITTI format")
args = parser.parse_args()
dataset_path = args.dataset_path
print(dataset_path)

View File

@ -4,11 +4,17 @@ import sys
import math
import os
import cv2
import argparse
import numpy as np
from matplotlib import pyplot as plt
dataset_path = sys.argv[1]
parser = argparse.ArgumentParser(description='Response calibration.')
parser.add_argument('-d', '--dataset-path', required=True, help="Path to the dataset in Euroc format")
args = parser.parse_args()
dataset_path = args.dataset_path
print(dataset_path)
@ -23,7 +29,8 @@ imgs = []
# check image data.
for timestamp in timestamps:
path = dataset_path + '/mav0/cam0/data/' + str(timestamp)
img = cv2.imread(dataset_path + '/mav0/cam0/data/' + str(timestamp) + '.webp', cv2.IMREAD_GRAYSCALE)[:,:,0]
img = cv2.imread(dataset_path + '/mav0/cam0/data/' + str(timestamp) + '.webp', cv2.IMREAD_GRAYSCALE)
if len(img.shape) == 3: img = img[:,:,0]
imgs.append(img)
pixel_avgs.append(np.mean(img))
@ -73,9 +80,10 @@ def print_error():
generated_imgs = irradiance[np.newaxis, :, :] * exposures[:, np.newaxis, np.newaxis]
generated_imgs -= inv_resp[imgs]
generated_imgs[imgs == 255] = 0
print(np.sum(generated_imgs**2))
print('Error', np.sum(generated_imgs**2))
for iter in range(5):
print('Iteration', iter)
irradiance = opt_irradiance()
print_error()
inv_resp = opt_inv_resp()

View File

@ -3,10 +3,17 @@
import sys
import math
import os
import argparse
import numpy as np
dataset_path = sys.argv[1]
parser = argparse.ArgumentParser(description='Check the dataset. Report if any images are missing.')
parser.add_argument('-d', '--dataset-path', required=True, help="Path to the dataset in Euroc format")
args = parser.parse_args()
dataset_path = args.dataset_path
print(dataset_path)