Refactor and enhance DA3 and BEN2 debug panels, introduce mesh export functionality
- Renamed DA3 and BEN2 debug panels for clarity and consistency. - Added a new function to draw DA3 input settings to reduce code duplication. - Implemented mesh export functionality, including confidence thresholding and edge filtering. - Updated export format options to include new mesh type and adjusted related properties. - Enhanced job handling to move generated inputs into job root and manage temporary directories. - Improved error handling and file management during export processes. - Added unit tests for new mesh functionality and ensured existing tests cover changes.
This commit is contained in:
@@ -122,6 +122,7 @@ def close_active_job():
|
||||
shutil.rmtree(temporary_path, ignore_errors=True)
|
||||
else:
|
||||
temporary_path.unlink(missing_ok=True)
|
||||
temporary_path.parent.rmdir()
|
||||
except OSError:
|
||||
pass
|
||||
_active_job = None
|
||||
@@ -221,6 +222,12 @@ class RunJob(bpy.types.Operator):
|
||||
self.report({"ERROR"}, str(error))
|
||||
return {"CANCELLED"}
|
||||
|
||||
export_format = ""
|
||||
if self.job_type == RECONSTRUCTION_JOB:
|
||||
export_format = settings.export_format
|
||||
elif self.job_type == IMAGE_DEPTH_JOB:
|
||||
export_format = "mini_npz"
|
||||
|
||||
job = ActiveJob(
|
||||
kind=self.job_type,
|
||||
process=None,
|
||||
@@ -228,11 +235,7 @@ class RunJob(bpy.types.Operator):
|
||||
log_path=log_path,
|
||||
status_path=paths["status"],
|
||||
result_directory=paths["result"],
|
||||
export_format=(
|
||||
settings.export_format if self.job_type == RECONSTRUCTION_JOB
|
||||
else "mini_npz" if self.job_type == IMAGE_DEPTH_JOB
|
||||
else ""
|
||||
),
|
||||
export_format=export_format,
|
||||
source_object_name=self.snapform_source_object_name,
|
||||
depth_data_name=self.snapform_depth_data_name,
|
||||
process_res=self.snapform_process_res,
|
||||
@@ -310,6 +313,21 @@ class RunJob(bpy.types.Operator):
|
||||
|
||||
def _prepare_command(self, _context, settings):
|
||||
paths = runtime.new_job_paths(self.job_type)
|
||||
if (
|
||||
getattr(self, "snapform_delete_input", False)
|
||||
and self.job_type in {
|
||||
IMAGE_DEPTH_JOB,
|
||||
IMAGE_BACKGROUND_JOB,
|
||||
ORIGINAL_BACKGROUND_JOB,
|
||||
ORIGINAL_FRAMES_JOB,
|
||||
}
|
||||
):
|
||||
archived_input = runtime.move_input_into_job(
|
||||
self.snapform_input_path,
|
||||
paths["result"],
|
||||
)
|
||||
self.snapform_input_path = str(archived_input)
|
||||
self.snapform_delete_input = False
|
||||
background_depth_distance = float(
|
||||
getattr(self, "snapform_background_depth_distance", 0.0)
|
||||
)
|
||||
@@ -389,13 +407,14 @@ class RunJob(bpy.types.Operator):
|
||||
),
|
||||
paths,
|
||||
)
|
||||
if self.job_type not in {RECONSTRUCTION_JOB, IMAGE_DEPTH_JOB}:
|
||||
if self.job_type not in {
|
||||
RECONSTRUCTION_JOB,
|
||||
IMAGE_DEPTH_JOB,
|
||||
}:
|
||||
raise RuntimeError(f"Unsupported task type: {self.job_type}")
|
||||
export_format = (
|
||||
"mini_npz"
|
||||
if self.job_type == IMAGE_DEPTH_JOB
|
||||
else settings.export_format
|
||||
)
|
||||
export_format = settings.export_format
|
||||
if self.job_type == IMAGE_DEPTH_JOB:
|
||||
export_format = "mini_npz"
|
||||
use_ray_pose = None
|
||||
process_res = None
|
||||
model_key = selected_model_key(settings, export_format)
|
||||
@@ -614,7 +633,10 @@ class RunJob(bpy.types.Operator):
|
||||
self._redraw_ui(context, force=True)
|
||||
return {"CANCELLED"}
|
||||
|
||||
if job.kind in {RECONSTRUCTION_JOB, BACKGROUND_REMOVAL_JOB}:
|
||||
if job.kind in {
|
||||
RECONSTRUCTION_JOB,
|
||||
BACKGROUND_REMOVAL_JOB,
|
||||
}:
|
||||
try:
|
||||
open_job_directory(job.result_directory)
|
||||
except Exception as open_error:
|
||||
|
||||
Reference in New Issue
Block a user