Commit 1695f357 authored by Clément Pinard's avatar Clément Pinard
Browse files

add pointcloud_sor

 * add videos splitting when they are too long
 * add already coputed groundtruth index
 * add point cloud densening by colmap
 * use matrix until the end instead of mlp files : thanks to this, the matrix can be modified manually with a custom point cloud registration
parent fab56cc2
......@@ -16,7 +16,7 @@ parser.add_argument('--database', metavar='DB', required=True,
help='path to colmap database file, to get the image ids right')
def add_to_db(db_path, metadata_path, frame_list_path, **env):
def add_to_db(db_path, metadata_path, frame_list_path, input_frame_ids=None, **env):
metadata = pd.read_csv(metadata_path)
database = db.COLMAPDatabase.connect(db_path)
......@@ -26,8 +26,11 @@ def add_to_db(db_path, metadata_path, frame_list_path, **env):
with open(frame_list_path, "r") as f:
frame_list = [line[:-1] for line in f.readlines()]
metadata = metadata[metadata["image_path"].isin(frame_list)]
if input_frame_ids:
assert(len(metadata) == len(input_frame_ids))
metadata["input_frame_id"] = input_frame_ids
for image_id, row in tqdm(metadata.iterrows(), total=len(metadata)):
for _, row in tqdm(metadata.iterrows(), total=len(metadata)):
image_path = row["image_path"]
camera_id = row["camera_id"]
if row["location_valid"]:
......@@ -35,12 +38,14 @@ def add_to_db(db_path, metadata_path, frame_list_path, **env):
else:
frame_gps = np.full(3, np.NaN)
try:
frame_ids.append(database.add_image(image_path, int(camera_id), prior_t=frame_gps))
input_id = row["input_frame_id"] if input_frame_ids else None
frame_ids.append(database.add_image(image_path, int(camera_id), prior_t=frame_gps, image_id=input_id))
except IntegrityError:
sql_string = "SELECT camera_id FROM images WHERE name='{}'".format(image_path)
row = next(database.execute(sql_string))
existing_camera_id = row[0]
sql_string = "SELECT camera_id, image_id FROM images WHERE name='{}'".format(image_path)
sql_output = next(database.execute(sql_string))
existing_camera_id = sql_output[0]
assert(existing_camera_id == camera_id)
frame_ids.append(sql_output[1])
database.commit()
database.close()
return frame_ids
......
......@@ -14,9 +14,9 @@ parser.add_argument('--output_format', choices=['.txt', '.bin'], default='.txt')
parser.add_argument('--metadata_path', metavar="CSV", type=Path)
def extract_video(input_model, output_model, video_metadata_path, output_format='.bin'):
cameras = rm.read_cameras_binary(input_model / "cameras.bin")
images = rm.read_images_binary(input_model / "images.bin")
def extract_video(input, output, video_metadata_path, output_format='.bin'):
cameras = rm.read_cameras_binary(input / "cameras.bin")
images = rm.read_images_binary(input / "images.bin")
images_per_name = {}
video_metadata = pd.read_csv(video_metadata_path)
image_names = video_metadata["image_path"].values
......@@ -28,7 +28,7 @@ def extract_video(input_model, output_model, video_metadata_path, output_format=
camera_ids = video_metadata["camera_id"].unique()
output_cameras = {cid: cameras[cid] for cid in camera_ids if cid in cameras.keys()}
rm.write_model(output_cameras, images_per_name, {}, output_model, output_format)
rm.write_model(output_cameras, images_per_name, {}, output, output_format)
return len(images_per_name) > 1
......
......@@ -78,6 +78,8 @@ def process_folder(folder_to_process, image_path, mask_path, pic_ext, verbose=Fa
to_process = []
if to_process:
extract_sky_mask(network, to_process, mask_folder)
del network
torch.cuda.empty_cache()
parser = ArgumentParser(description='sky mask generator using ENet trained on cityscapes',
......
......@@ -29,7 +29,6 @@ def load_and_convert(input_file, output_folder, verbose=False):
*(cloud.centroid/1000)))
output_centroid = cloud.centroid
print(cloud.centroid)
np.savetxt(txt_path, output_centroid)
xyz = cloud.points[['x', 'y', 'z']]
......
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
from wrappers import Colmap, FFMpeg, PDraw, ETH3D, PCLUtil
from global_options import add_global_options
from colmap_util.read_model import read_images_text
from pyproj import Proj
from edit_exif import get_gps_location
import meshlab_xml_writer as mxw
......@@ -15,21 +15,25 @@ import pandas as pd
import las2ply
import rawpy
import imageio
import tempfile
global_steps = ["Point Cloud Preparation",
"Pictures preparation",
"Extracting Videos and selecting optimal frames for a thorough scan",
"First thorough photogrammetry",
"Alignment of photogrammetric reconstruction with Lidar point cloud",
"Occlusion Mesh computing"]
pre_vid_steps = ["Full video extraction",
"Sky mask generation",
"Complete photogrammetry with video at 1 fps",
"Localizing remaining frames",
"Creating Ground truth data",
"Create video with GT vizualisation",
"Convert to KITTI format"]
"Occlusion Mesh computing",
"Video localization",
"Ground Truth creation"]
per_vid_steps_1 = ["Full video extraction",
"Sky mask generation",
"Complete photogrammetry with video at 1 fps",
"Localizing remaining frames",
"Re-Alignment of triangulated points with Lidar point cloud"]
per_vid_steps_2 = ["Creating Ground truth data",
"Create video with GT vizualisation",
"Convert to KITTI format"]
parser = ArgumentParser(description='Main pipeline, from LIDAR pictures and videos to GT depth enabled videos',
formatter_class=ArgumentDefaultsHelpFormatter)
......@@ -48,13 +52,16 @@ main_parser.add_argument('-v', '--verbose', action="count", default=0)
main_parser.add_argument('--vid_ext', nargs='+', default=[".mp4", ".MP4"])
main_parser.add_argument('--pic_ext', nargs='+', default=[".jpg", ".JPG", ".png", ".PNG"])
main_parser.add_argument('--raw_ext', nargs='+', default=[".ARW", ".NEF", ".DNG"])
main_parser.add_argument('--dense', action="store_true")
main_parser.add_argument('--fine_sift_features', action="store_true")
main_parser.add_argument('--triangulate', action="store_true")
main_parser.add_argument('--save_space', action="store_true")
main_parser.add_argument('--add_new_videos', action="store_true")
main_parser.add_argument('--resume_work', action="store_true")
pcp_parser = parser.add_argument_group("PointCLoud preparation")
pcp_parser.add_argument("--pointcloud_resolution", default=0.1, type=float)
pcp_parser.add_argument("--SOR", default=[6, 2], nargs=2, type=int)
pcp_parser.add_argument("--SOR", default=[10, 6], nargs=2, type=int)
ve_parser = parser.add_argument_group("Video extractor")
ve_parser.add_argument('--total_frames', default=500, type=int)
......@@ -62,6 +69,8 @@ ve_parser.add_argument('--orientation_weight', default=1, type=float)
ve_parser.add_argument('--resolution_weight', default=1, type=float)
ve_parser.add_argument('--num_neighbours', default=10, type=int)
ve_parser.add_argument('--system', default="epsg:2154")
ve_parser.add_argument('--lowfps', default=1, type=int)
ve_parser.add_argument('--max_sequence_length', default=4000, type=int)
exec_parser = parser.add_argument_group("Executable files")
exec_parser.add_argument('--log', default=None, type=Path)
......@@ -89,31 +98,31 @@ def print_workflow():
print("{}:\t{}".format(i, s))
print("Per video steps :")
for i, s in enumerate(pre_vid_steps):
for i, s in enumerate(per_vid_steps_1):
print("\t{}:\t{}".format(i, s))
for i, s in enumerate(per_vid_steps_2):
print("\t{}:\t{}".format(i, s))
def print_step(step_number, step_name):
print("=================")
print("Step {}".format(step_number + 1))
print("\n\n=================")
print("Step {}".format(step_number))
print(step_name)
print("=================")
def convert_point_cloud(pointclouds, lidar_path, verbose, eth3d, pcl_util, pointcloud_resolution, save_space, **env):
def prepare_point_clouds(pointclouds, lidar_path, verbose, eth3d, pcl_util, SOR, pointcloud_resolution, save_space, **env):
converted_clouds = []
centroids = []
output_centroid = None
for pc in pointclouds:
ply, centroid = las2ply.load_and_convert(input_file=pc,
output_folder=lidar_path,
verbose=verbose >= 1)
centroids.append(centroid)
eth3d.clean_pointcloud(ply, filter=(6, 2))
pcl_util.subsample(input_file=ply + ".inliers.ply", output_file=ply.stripext() + "_subsampled.ply", resolution=pointcloud_resolution)
if save_space:
(ply + ".inliers.ply").remove()
(ply + ".outliers.ply").remove()
ply.remove()
if pc.ext[1:].upper() == "LAS":
if output_centroid is None:
output_centroid = centroid
pcl_util.filter_cloud(input_file=ply, output_file=ply.stripext() + "_filtered.ply", knn=SOR[0], std=SOR[1])
pcl_util.subsample(input_file=ply.stripext() + "_filtered.ply", output_file=ply.stripext() + "_subsampled.ply", resolution=pointcloud_resolution)
converted_clouds.append(ply.stripext() + "_subsampled.ply")
temp_mlp = env["workspace"] / "lidar_unaligned.mlp"
......@@ -123,7 +132,7 @@ def convert_point_cloud(pointclouds, lidar_path, verbose, eth3d, pcl_util, point
else:
temp_mlp.move(env["lidar_mlp"])
return converted_clouds, centroids[0]
return converted_clouds, output_centroid
def extract_gps_and_path(existing_pictures, image_path, system, centroid, **env):
......@@ -198,6 +207,8 @@ def prepare_workspace(path, env):
env["occlusion_mlp"] = env["lidar_path"] / "occlusions.mlp"
env["splats_mlp"] = env["lidar_path"] / "splats.mlp"
env["georefrecon_ply"] = env["georef_recon"] / "georef_reconstruction.ply"
env["matrix_path"] = env["workspace"] / "matrix_thorough.txt"
env["indexed_vocab_tree"] = env["workspace"] / "vocab_tree_thorough.bin"
def main():
......@@ -231,29 +242,28 @@ def main():
ply_files = (args.input_folder/"Lidar").files("*.ply")
input_pointclouds = las_files + ply_files
env["videos_list"] = sum((list((args.input_folder/"Videos").walkfiles('*{}'.format(ext))) for ext in args.vid_ext), [])
i_global_steps = enumerate(global_steps)
i, s = next(i_global_steps)
if i + 1 not in args.skip_step:
print_step(i, s)
env["pointclouds"], env["centroid"] = convert_point_cloud(input_pointclouds, **env)
i = 1
if i not in args.skip_step:
print_step(i, "Point Cloud Preparation")
env["pointclouds"], env["centroid"] = prepare_point_clouds(input_pointclouds, **env)
else:
env["pointclouds"] = env["lidar_path"].files("*inliers.ply")
centroid_path = sorted(env["lidar_path"].files("*_centroid.txt"))[0]
env["centroid"] = np.loadtxt(centroid_path)
i, s = next(i_global_steps)
if i + 1 not in args.skip_step:
print_step(i, s)
i += 1
if i not in args.skip_step:
print_step(i, "Pictures preparation")
env["existing_pictures"] = extract_pictures_to_workspace(**env)
else:
env["existing_pictures"] = sum((list(env["image_path"].walkfiles('*{}'.format(ext))) for ext in env["pic_ext"]), [])
i, s = next(i_global_steps)
if i + 1 not in args.skip_step:
print_step(i, s)
i += 1
if i not in args.skip_step:
print_step(i, "Extracting Videos and selecting optimal frames for a thorough scan")
existing_georef = extract_gps_and_path(**env)
path_lists, env["videos_output_folders"] = extract_videos_to_workspace(**env)
path_lists, env["videos_output_folders"] = extract_videos_to_workspace(fps=args.lowfps, **env)
if path_lists is not None:
with open(env["video_frame_list_thorough"], "w") as f:
f.write("\n".join(path_lists["thorough"]["frames"]))
......@@ -268,8 +278,9 @@ def main():
f.write("\n".join(existing_georef) + "\n")
f.write("\n".join(path_lists["thorough"]["georef"]) + "\n")
f.write("\n".join(path_lists[v]["georef_lowfps"]) + "\n")
with open(video_folder / "full.txt", "w") as f:
f.write("\n".join(path_lists[v]["frames_full"]) + "\n")
for j, l in enumerate(path_lists[v]["frames_full"]):
with open(video_folder / "full_{}.txt".format(i), "w") as f:
f.write("\n".join(l) + "\n")
else:
env["videos_output_folders"] = {}
by_name = {v.namebase: v for v in env["videos_list"]}
......@@ -278,158 +289,226 @@ def main():
if video_name in by_name.keys():
env["videos_output_folders"][by_name[video_name]] = folder
i, s = next(i_global_steps)
if i + 1 not in args.skip_step:
print_step(i, s)
i += 1
if i not in args.skip_step:
print_step(i, "First thorough photogrammetry")
gsm.process_folder(folder_to_process=env["video_path"], **env)
colmap.extract_features(image_list=env["video_frame_list_thorough"], fine=args.fine_sift_features)
colmap.index_images(vocab_tree_output=env["indexed_vocab_tree"], vocab_tree_input=args.vocab_tree)
colmap.match()
colmap.map(output_model=env["thorough_recon"].parent)
colmap.map(output=env["thorough_recon"].parent)
i, s = next(i_global_steps)
if i + 1 not in args.skip_step:
print_step(i, s)
i += 1
if i not in args.skip_step:
print_step(i, "Alignment of photogrammetric reconstruction with Lidar point cloud")
colmap.align_model(output_model=env["georef_recon"],
input_model=env["thorough_recon"],
colmap.align_model(output=env["georef_recon"],
input=env["thorough_recon"],
ref_images=env["georef_frames_list"])
if args.dense:
print_step("{} (bis)".format(i), "Point cloud densificitation")
dense_workspace = env["thorough_recon"]/"dense"
colmap.undistort(input=env["georef_recon"], output=dense_workspace)
colmap.dense_stereo(workspace=dense_workspace)
colmap.stereo_fusion(workspace=dense_workspace, output=env["georefrecon_ply"])
else:
colmap.export_model(output=env["georefrecon_ply"],
input=env["georef_recon"])
colmap.export_model(output_ply=env["georefrecon_ply"],
input_model=env["georef_recon"])
i, s = next(i_global_steps)
if i + 1 not in args.skip_step:
print_step(i, s)
i += 1
if i not in args.skip_step:
print_step(i, "Occlusion Mesh computing")
with_normals_path = env["lidar_path"] / "with_normals.ply"
eth3d.compute_normals(with_normals_path, env["lidar_mlp"], neighbor_radius=args.normal_radius)
pcl_util.triangulate_mesh(env["occlusion_ply"], with_normals_path, resolution=args.mesh_resolution)
eth3d.create_splats(env["splats_ply"], with_normals_path, env["occlusion_ply"], threshold=args.splat_threshold)
matrix_path = env["workspace"] / "matrix_thorough.txt"
pcl_util.register_reconstruction(georef=env["georefrecon_ply"],
lidar=with_normals_path,
output_matrix=matrix_path,
output_cloud=env["lidar_ply"],
output_matrix=env["matrix_path"],
max_distance=10)
matrix = np.fromfile(matrix_path, sep=" ").reshape(4, 4)
mxw.apply_transform_to_project(env["lidar_mlp"], env["aligned_mlp"], matrix)
mxw.create_project(env["occlusion_mlp"], [env["occlusion_ply"]], transforms=[matrix])
mxw.create_project(env["splats_mlp"], [env["splats_ply"]], transforms=[matrix])
for v in env["videos_list"]:
i_pv_steps = enumerate(pre_vid_steps)
print("Now working on video {}".format(v))
if env["matrix_path"].isfile():
matrix = np.linalg.inv(np.fromfile(env["matrix_path"], sep=" ").reshape(4, 4))
else:
print("Error, no registration matrix can be found")
matrix = np.eye(4)
mxw.apply_transform_to_project(env["lidar_mlp"], env["aligned_mlp"], matrix)
mxw.create_project(env["occlusion_mlp"], [env["occlusion_ply"]], transforms=[matrix])
mxw.create_project(env["splats_mlp"], [env["splats_ply"]], transforms=[matrix])
i += 1
if i not in args.skip_step:
print_step(i, "Video localization")
for j, v in enumerate(env["videos_list"]):
print(v)
current_video_folder = env["videos_output_folders"][v]
thorough_db = args.workspace / "thorough_scan.db"
lowfps_db = current_video_folder / "video_low_fps.db"
current_metadata = current_video_folder / "metadata.csv"
map_image_list_path = current_video_folder / "to_scan.txt"
full_image_list_path = current_video_folder.files("full*.txt")
full_dbs = [current_video_folder / fp.namebase + ".db" for fp in full_image_list_path]
video_output_model = env["video_recon"] / v.namebase
chunk_output_models = [video_output_model / "chunk_{}".format(index) for index in range(len(full_image_list_path))]
final_output_model = video_output_model / "final"
# Perform checks if it has not already been computed
if args.resume_work and final_output_model.isdir():
print("already done")
continue
i_pv = 1
print("Now working on video {} [{}/{}]".format(v, j + 1, len(env["videos_list"])))
thorough_db.copy(lowfps_db)
colmap.db = lowfps_db
print_step(i_pv, "Full video extraction")
if args.save_space:
existing_images = list(current_video_folder.files())
ffmpeg.extract_images(v, current_video_folder)
else:
print("Already Done.")
i_pv += 1
print_step(i_pv, "Sky mask generation")
gsm.process_folder(folder_to_process=current_video_folder, **env)
i_pv += 1
print_step(i_pv, "Complete photogrammetry with video at {} fps".format(args.lowfps))
avtd.add_to_db(lowfps_db, current_metadata, map_image_list_path)
colmap.extract_features(image_list=map_image_list_path, fine=args.fine_sift_features)
colmap.match(method="sequential", vocab_tree=env["indexed_vocab_tree"])
video_output_model.makedirs_p()
colmap.map(output=video_output_model, input=env["georef_recon"])
# when colmap map is called, the model is normalized so we have georegister it again
colmap.align_model(output=video_output_model,
input=video_output_model,
ref_images=env["georef_frames_list"])
i_pv += 1
print_step(i_pv, "Localizing remaining frames")
# get image_ids in a fake database with all the chunks
frame_ids_per_chunk = []
temp_db = Path(tempfile.NamedTemporaryFile().name)
lowfps_db.copy(temp_db)
for list_path in full_image_list_path:
frame_ids_per_chunk.append(avtd.add_to_db(temp_db, current_metadata, frame_list_path=list_path))
for k, (list_path, full_db, chunk_output_model, frame_ids) in enumerate(zip(full_image_list_path,
full_dbs,
chunk_output_models,
frame_ids_per_chunk)):
print("Localizing Chunk {}/{}".format(k + 1, len(full_dbs)))
chunk_output_model.makedirs_p()
lowfps_db.copy(full_db)
colmap.db = full_db
avtd.add_to_db(full_db, current_metadata, frame_list_path=list_path, input_frame_ids=frame_ids)
colmap.extract_features(image_list=list_path, fine=args.fine_sift_features)
colmap.match(method="sequential", vocab_tree=env["indexed_vocab_tree"])
colmap.register_images(output=chunk_output_model, input=video_output_model)
colmap.adjust_bundle(output=chunk_output_model, input=chunk_output_model)
for chunk in chunk_output_models:
colmap.merge_models(output=video_output_model, input1=video_output_model, input2=chunk)
final_output_model.makedirs_p()
empty = not evfm.extract_video(input=video_output_model,
output=final_output_model,
video_metadata_path=current_metadata,
output_format=".bin" if args.triangulate else ".txt")
if empty:
print("Error, empty localization, will try map from video")
continue
# colmap.db = lowfps_db
# colmap.map(output_model=video_output_model, start_frame_id=added_frames[int(len(added_frames)/2)])
# colmap.align_model(output_model=video_output_model,
# input_model=video_output_model / "0",
# ref_images=current_video_folder / "georef.txt")
# colmap.db = full_db
# colmap.register_images(output_model=video_output_model, input_model=video_output_model)
# colmap.adjust_bundle(output_model=video_output_model, input_model=video_output_model)
# empty = not evfm.extract_video(input_model=video_output_model,
# output_model=final_output_model,
# video_metadata_path=current_metadata,
# output_format=".txt")
# if empty:
# print("Error could not map anything, aborting this video")
# continue
if args.triangulate:
i_pv += 1
print_step(i, "Re-Alignment of triangulated points with Lidar point cloud")
colmap.triangulate_points(final_output_model, final_output_model)
colmap.export_model(final_output_model, final_output_model, output_type="TXT")
ply_name = final_output_model / "georef_{}.ply".format(v.namebase)
matrix_name = final_output_model / "georef_maxtrix_{}.txt".format(v.namebase)
colmap.export_model(ply_name, final_output_model, output_type="PLY")
pcl_util.register_reconstruction(georef=ply_name, lidar=env["lidar_ply"],
output_matrix=matrix_name, output_cloud=env["lidar_ply"],
max_distance=10)
matrix = np.fromfile(matrix_name, sep=" ").reshape(4, 4)
output_images_folder = args.output_folder / "Images" / v.namebase
output_images_folder.makedirs_p()
current_video_folder.merge_tree(output_images_folder)
if args.save_space:
for file in current_video_folder.files():
if file not in existing_images:
file.remove()
for j, v in enumerate(env["videos_list"]):
output_images_folder = args.output_folder / "Images" / v.namebase
current_video_folder = env["videos_output_folders"][v]
thorough_db = args.workspace / "thorough_scan.db"
lowfps_db = current_video_folder / "video1fps.db"
full_db = current_video_folder / "video_full.db"
current_metadata = current_video_folder / "metadata.csv"
thorough_db.copy(lowfps_db)
map_image_list_path = current_video_folder / "to_scan.txt"
full_image_list_path = current_video_folder / "full.txt"
colmap.db = lowfps_db
i, s = next(i_pv_steps)
print_step(i, s)
if args.save_space:
existing_images = list(current_video_folder.files())
ffmpeg.extract_images(v, current_video_folder)
else:
print("Already Done.")
i, s = next(i_pv_steps)
print_step(i, s)
gsm.process_folder(folder_to_process=current_video_folder, **env)
i, s = next(i_pv_steps)
print_step(i, s)
added_frames = avtd.add_to_db(lowfps_db, current_metadata, map_image_list_path)
colmap.extract_features(image_list=map_image_list_path, fine=args.fine_sift_features)
colmap.match(method="sequential", vocab_tree=args.vocab_tree)
video_output_model = env["video_recon"] / v.namebase
video_output_model.makedirs_p()
colmap.map(output_model=video_output_model, input_model=env["georef_recon"])
# when colmap map is called, the model is normalized so we have georegister it again
colmap.align_model(output_model=video_output_model,
input_model=video_output_model,
ref_images=env["georef_frames_list"])
i, s = next(i_pv_steps)
print_step(i, s)
lowfps_db.copy(full_db)
colmap.db = full_db
avtd.add_to_db(full_db, current_metadata, frame_list_path=None)
colmap.extract_features(image_list=full_image_list_path, fine=args.fine_sift_features)
colmap.match(method="sequential", vocab_tree=args.vocab_tree)
colmap.register_images(output_model=video_output_model, input_model=video_output_model)
colmap.adjust_bundle(output_model=video_output_model, input_model=video_output_model)
final_output_model = video_output_model / "final"
final_output_model.makedirs_p()
empty = not evfm.extract_video(input_model=video_output_model,
output_model=final_output_model,
video_metadata_path=current_metadata,
output_format=".bin")
if empty:
print("Error, empty localization, will try map from video")
colmap.db = lowfps_db
colmap.map(output_model=video_output_model, start_frame_id=added_frames[0])
colmap.align_model(output_model=video_output_model,
input_model=video_output_model / "0",
ref_images=current_video_folder / "georef.txt")
colmap.db = full_db
colmap.register_images(output_model=video_output_model, input_model=video_output_model)
colmap.adjust_bundle(output_model=video_output_model, input_model=video_output_model)
empty = not evfm.extract_video(input_model=video_output_model,
output_model=final_output_model,
video_metadata_path=current_metadata,
output_format=".bin")
i, s = next(i_pv_steps)
print_step(i, s)
colmap.triangulate_points(final_output_model, final_output_model)
colmap.export_model(final_output_model, final_output_model, output_type="TXT")
ply_name = final_output_model / "georef_{}.ply".format(v.namebase)
matrix_name = final_output_model / "georef_maxtrix_{}.txt".format(v.namebase)
colmap.export_model(ply_name, final_output_model, output_type="PLY")
pcl_util.register_reconstruction(georef=ply_name,
lidar=env["lidar_ply"],
output_matrix=matrix_name,
output_cloud=env["lidar_ply"],
max_distance=10)
matrix = np.fromfile(matrix_name, sep=" ").reshape(4, 4)
model_length = len(read_images_text(final_output_model / "images.txt"))
if model_length < 2:
continue
final_lidar = final_output_model / "aligned_lidar.mlp"
final_occlusions = final_output_model / "occlusions.mlp"
final_splats = final_output_model / "splats.mlp"
mxw.apply_transform_to_project(env["aligned_mlp"], final_lidar, matrix)
mxw.apply_transform_to_project(env["occlusion_mlp"], final_occlusions, matrix)
mxw.apply_transform_to_project(env["splats_mlp"], final_splats, matrix)
specific_matrix_path = final_output_model / "matrix.txt"
if specific_matrix_path.isfile():
current_matrix = np.linalg.inv(np.fromfile(specific_matrix_path, sep=" ").reshape(4, 4))
else:
current_matrix = matrix
i, s = next(i_pv_steps)
print_step(i, s)
output_images_folder = args.output_folder / "Images" / v.namebase
output_images_folder.makedirs_p()
current_video_folder.merge_tree(output_images_folder)
mxw.apply_transform_to_project(env["lidar_mlp"], final_lidar, current_matrix)
mxw.create_project(final_occlusions, [env["occlusion_ply"]], transforms=[current_matrix])
mxw.create_project(final_splats, [env["splats_ply"]], transforms=[current_matrix])
output_vizualisation_folder = args.output_folder / "video" / v.namebase
if args.resume_work and output_vizualisation_folder.isdir():
continue
print("Creating GT on video {} [{}/{}]".format(v, j+1, len(env["videos_list"])))
i_pv = 0
i_pv += 1
print_step(i, "Creating Ground truth data with ETH3D")
eth3d.create_ground_truth(final_lidar, final_occlusions,
final_splats, final_output_model,
# eth3d.create_ground_truth(final_lidar, final_occlusions,
# final_splats, final_output_model,
# args.output_folder)
eth3d.create_ground_truth(env["aligned_mlp"], env["occlusion_mlp"],
env["splats_mlp"], final_output_model,
args.output_folder)
output_vizualisation_folder = args.output_folder / "video" / v.namebase
output_vizualisation_folder.makedirs_p()
i_pv += 1