(config, nice=19)
| 76 | |
| 77 | |
| 78 | def hugin_refine(config, nice=19): |
| 79 | pto_path = config.pto_path |
| 80 | output_path = os.path.join(config.scan_dir, f'{config.scan_id}.jpg') |
| 81 | |
| 82 | # Create Hugin project |
| 83 | subprocess.run(['pto_gen', '--projection=2', '--fov=360', '-o', pto_path, *config.imglist], check=True) |
| 84 | |
| 85 | # Apply template |
| 86 | subprocess.run(['pto_template', f'--output={pto_path}', f'--template={config.template_path}', pto_path], check=True) |
| 87 | |
| 88 | # Add control points |
| 89 | subprocess.run(['cpfind', '-o', pto_path, '--multirow', pto_path], check=True) |
| 90 | |
| 91 | # Clean control points |
| 92 | subprocess.run(['cpclean', '-o', pto_path, pto_path], check=True) |
| 93 | |
| 94 | # Find line features |
| 95 | subprocess.run(['linefind', '-o', pto_path, pto_path], check=True) |
| 96 | |
| 97 | # Optimize the project |
| 98 | subprocess.run(['pto_var', '-o', pto_path, '--opt', 'TrX,TrY,TrZ,r,Eev,Ra,Rb,Rc,Rd,Re,!TrX0,!TrY0,!TrZ0,!r0,!Eev0,!Ra1,!Rb1,!Rc1,!Rd1,!Re1', pto_path], check=True) |
| 99 | subprocess.run(['autooptimiser', '-n', '-o', pto_path, pto_path], check=True) |
| 100 | |
| 101 | # Modify resolution of the temporary project file |
| 102 | hugin_modify(pto_path, pto_path, width=config.get("PANO", "PANO_WIDTH")) |
| 103 | |
| 104 | # Start stitching as non-blocking thread with low priority |
| 105 | if config.get("ENABLE_PANO"): |
| 106 | cmd_string = ['nice', '-n', str(nice), 'hugin_executor', '--stitching', f'--prefix={output_path}', pto_path] |
| 107 | process = subprocess.Popen(cmd_string) |
| 108 | |
| 109 | # Wait for the process to finish |
| 110 | process.wait() |
| 111 | |
| 112 | # Check return code if stitching was successful |
| 113 | if process.returncode != 0: |
| 114 | raise Exception(f"Command failed with return code {process.returncode}") |
| 115 | |
| 116 | return output_path |
| 117 | |
| 118 | |
| 119 | def sample_color(img, uv, normalize_color=False): |
nothing calls this directly
no test coverage detected