PaIRS-UniNa 0.2.10__cp313-cp313-macosx_11_0_universal2.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- PaIRS_UniNa/Calibration_Tab.py +347 -0
- PaIRS_UniNa/Changes.txt +174 -0
- PaIRS_UniNa/Custom_Top.py +303 -0
- PaIRS_UniNa/Explorer.py +3322 -0
- PaIRS_UniNa/FolderLoop.py +562 -0
- PaIRS_UniNa/Input_Tab.py +829 -0
- PaIRS_UniNa/Input_Tab_CalVi.py +787 -0
- PaIRS_UniNa/Input_Tab_tools.py +3026 -0
- PaIRS_UniNa/Log_Tab.py +110 -0
- PaIRS_UniNa/Output_Tab.py +922 -0
- PaIRS_UniNa/PaIRS.py +18 -0
- PaIRS_UniNa/PaIRS_PIV.py +873 -0
- PaIRS_UniNa/PaIRS_pypacks.py +1374 -0
- PaIRS_UniNa/Process_Tab.py +1761 -0
- PaIRS_UniNa/Process_Tab_CalVi.py +313 -0
- PaIRS_UniNa/Process_Tab_Disp.py +170 -0
- PaIRS_UniNa/Process_Tab_Min.py +120 -0
- PaIRS_UniNa/ResizePopup.py +55 -0
- PaIRS_UniNa/SPIVCalHelp.py +155 -0
- PaIRS_UniNa/Saving_tools.py +298 -0
- PaIRS_UniNa/TabTools.py +1413 -0
- PaIRS_UniNa/Vis_Tab.py +2176 -0
- PaIRS_UniNa/Vis_Tab_CalVi.py +982 -0
- PaIRS_UniNa/Whatsnew.py +130 -0
- PaIRS_UniNa/_PaIRS_PIV.so +0 -0
- PaIRS_UniNa/__init__.py +6 -0
- PaIRS_UniNa/__main__.py +45 -0
- PaIRS_UniNa/addwidgets_ps.py +1633 -0
- PaIRS_UniNa/calib.py +1488 -0
- PaIRS_UniNa/calibView.py +833 -0
- PaIRS_UniNa/gPaIRS.py +3957 -0
- PaIRS_UniNa/gPalette.py +189 -0
- PaIRS_UniNa/icons/abort.png +0 -0
- PaIRS_UniNa/icons/about.png +0 -0
- PaIRS_UniNa/icons/align_all.png +0 -0
- PaIRS_UniNa/icons/announcement.png +0 -0
- PaIRS_UniNa/icons/automatic_levels_off.png +0 -0
- PaIRS_UniNa/icons/automatic_levels_on.png +0 -0
- PaIRS_UniNa/icons/automatic_off.png +0 -0
- PaIRS_UniNa/icons/automatic_on.png +0 -0
- PaIRS_UniNa/icons/automatic_size_off.png +0 -0
- PaIRS_UniNa/icons/automatic_size_on.png +0 -0
- PaIRS_UniNa/icons/axes.png +0 -0
- PaIRS_UniNa/icons/background.png +0 -0
- PaIRS_UniNa/icons/background_vectors.png +0 -0
- PaIRS_UniNa/icons/bin_off.png +0 -0
- PaIRS_UniNa/icons/bin_on.png +0 -0
- PaIRS_UniNa/icons/browse_file_c.png +0 -0
- PaIRS_UniNa/icons/browse_folder_c.png +0 -0
- PaIRS_UniNa/icons/brush_cursor.png +0 -0
- PaIRS_UniNa/icons/bugfix.png +0 -0
- PaIRS_UniNa/icons/cal_proc.png +0 -0
- PaIRS_UniNa/icons/cal_proc_off.png +0 -0
- PaIRS_UniNa/icons/cal_step.png +0 -0
- PaIRS_UniNa/icons/cal_step_off.png +0 -0
- PaIRS_UniNa/icons/calibrate.png +0 -0
- PaIRS_UniNa/icons/calibration_logo.png +0 -0
- PaIRS_UniNa/icons/change_folder.png +0 -0
- PaIRS_UniNa/icons/change_folder_off.png +0 -0
- PaIRS_UniNa/icons/checklist.png +0 -0
- PaIRS_UniNa/icons/clean.png +0 -0
- PaIRS_UniNa/icons/clean_run.png +0 -0
- PaIRS_UniNa/icons/close.png +0 -0
- PaIRS_UniNa/icons/close_all.png +0 -0
- PaIRS_UniNa/icons/close_project.png +0 -0
- PaIRS_UniNa/icons/close_workspace.png +0 -0
- PaIRS_UniNa/icons/colormap.png +0 -0
- PaIRS_UniNa/icons/colormaps/Accent.png +0 -0
- PaIRS_UniNa/icons/colormaps/BrBG.png +0 -0
- PaIRS_UniNa/icons/colormaps/Dark2.png +0 -0
- PaIRS_UniNa/icons/colormaps/PRGn.png +0 -0
- PaIRS_UniNa/icons/colormaps/Paired.png +0 -0
- PaIRS_UniNa/icons/colormaps/Pastel1.png +0 -0
- PaIRS_UniNa/icons/colormaps/Pastel2.png +0 -0
- PaIRS_UniNa/icons/colormaps/PiYG.png +0 -0
- PaIRS_UniNa/icons/colormaps/PuOr.png +0 -0
- PaIRS_UniNa/icons/colormaps/RdBu.png +0 -0
- PaIRS_UniNa/icons/colormaps/RdGy.png +0 -0
- PaIRS_UniNa/icons/colormaps/RdYlBu.png +0 -0
- PaIRS_UniNa/icons/colormaps/RdYlGn.png +0 -0
- PaIRS_UniNa/icons/colormaps/Set1.png +0 -0
- PaIRS_UniNa/icons/colormaps/Set2.png +0 -0
- PaIRS_UniNa/icons/colormaps/Set3.png +0 -0
- PaIRS_UniNa/icons/colormaps/Spectral.png +0 -0
- PaIRS_UniNa/icons/colormaps/Wistia.png +0 -0
- PaIRS_UniNa/icons/colormaps/afmhot.png +0 -0
- PaIRS_UniNa/icons/colormaps/autumn.png +0 -0
- PaIRS_UniNa/icons/colormaps/binary.png +0 -0
- PaIRS_UniNa/icons/colormaps/blackVector.png +0 -0
- PaIRS_UniNa/icons/colormaps/blueVector.png +0 -0
- PaIRS_UniNa/icons/colormaps/bone.png +0 -0
- PaIRS_UniNa/icons/colormaps/brg.png +0 -0
- PaIRS_UniNa/icons/colormaps/bwr.png +0 -0
- PaIRS_UniNa/icons/colormaps/cividis.png +0 -0
- PaIRS_UniNa/icons/colormaps/cool.png +0 -0
- PaIRS_UniNa/icons/colormaps/coolwarm.png +0 -0
- PaIRS_UniNa/icons/colormaps/copper.png +0 -0
- PaIRS_UniNa/icons/colormaps/cubehelix.png +0 -0
- PaIRS_UniNa/icons/colormaps/cyanVector.png +0 -0
- PaIRS_UniNa/icons/colormaps/flag.png +0 -0
- PaIRS_UniNa/icons/colormaps/gist_heat.png +0 -0
- PaIRS_UniNa/icons/colormaps/gray.png +0 -0
- PaIRS_UniNa/icons/colormaps/greenVector.png +0 -0
- PaIRS_UniNa/icons/colormaps/hot.png +0 -0
- PaIRS_UniNa/icons/colormaps/hsv.png +0 -0
- PaIRS_UniNa/icons/colormaps/inferno.png +0 -0
- PaIRS_UniNa/icons/colormaps/jet.png +0 -0
- PaIRS_UniNa/icons/colormaps/magentaVector.png +0 -0
- PaIRS_UniNa/icons/colormaps/magma.png +0 -0
- PaIRS_UniNa/icons/colormaps/ocean.png +0 -0
- PaIRS_UniNa/icons/colormaps/pink.png +0 -0
- PaIRS_UniNa/icons/colormaps/plasma.png +0 -0
- PaIRS_UniNa/icons/colormaps/prism.png +0 -0
- PaIRS_UniNa/icons/colormaps/rainbow.png +0 -0
- PaIRS_UniNa/icons/colormaps/redVector.png +0 -0
- PaIRS_UniNa/icons/colormaps/seismic.png +0 -0
- PaIRS_UniNa/icons/colormaps/spring.png +0 -0
- PaIRS_UniNa/icons/colormaps/summer.png +0 -0
- PaIRS_UniNa/icons/colormaps/tab10.png +0 -0
- PaIRS_UniNa/icons/colormaps/tab20.png +0 -0
- PaIRS_UniNa/icons/colormaps/tab20b.png +0 -0
- PaIRS_UniNa/icons/colormaps/tab20c.png +0 -0
- PaIRS_UniNa/icons/colormaps/terrain.png +0 -0
- PaIRS_UniNa/icons/colormaps/twilight.png +0 -0
- PaIRS_UniNa/icons/colormaps/viridis.png +0 -0
- PaIRS_UniNa/icons/colormaps/whiteVector.png +0 -0
- PaIRS_UniNa/icons/colormaps/winter.png +0 -0
- PaIRS_UniNa/icons/colormaps/yellowVector.png +0 -0
- PaIRS_UniNa/icons/common_region.png +0 -0
- PaIRS_UniNa/icons/common_region_off.png +0 -0
- PaIRS_UniNa/icons/completed.png +0 -0
- PaIRS_UniNa/icons/contourf_off.png +0 -0
- PaIRS_UniNa/icons/contourf_on.png +0 -0
- PaIRS_UniNa/icons/copy.png +0 -0
- PaIRS_UniNa/icons/copy_process.png +0 -0
- PaIRS_UniNa/icons/copy_process_off.png +0 -0
- PaIRS_UniNa/icons/copygrid.png +0 -0
- PaIRS_UniNa/icons/cursor_lamp.png +0 -0
- PaIRS_UniNa/icons/cut.png +0 -0
- PaIRS_UniNa/icons/cut_warnings.png +0 -0
- PaIRS_UniNa/icons/darkmode.png +0 -0
- PaIRS_UniNa/icons/debug_run.png +0 -0
- PaIRS_UniNa/icons/delete.png +0 -0
- PaIRS_UniNa/icons/deleteErr.png +0 -0
- PaIRS_UniNa/icons/disp_step.png +0 -0
- PaIRS_UniNa/icons/disp_step_off.png +0 -0
- PaIRS_UniNa/icons/down.png +0 -0
- PaIRS_UniNa/icons/edit_list.png +0 -0
- PaIRS_UniNa/icons/editing.png +0 -0
- PaIRS_UniNa/icons/example_list.png +0 -0
- PaIRS_UniNa/icons/find_all_planes.png +0 -0
- PaIRS_UniNa/icons/find_plane.png +0 -0
- PaIRS_UniNa/icons/flaticon_PaIRS.png +0 -0
- PaIRS_UniNa/icons/flaticon_PaIRS_beta.png +0 -0
- PaIRS_UniNa/icons/flaticon_PaIRS_download.png +0 -0
- PaIRS_UniNa/icons/flaticon_PaIRS_download_warning.png +0 -0
- PaIRS_UniNa/icons/flip_y_off.png +0 -0
- PaIRS_UniNa/icons/flip_y_on.png +0 -0
- PaIRS_UniNa/icons/focusErrr.png +0 -0
- PaIRS_UniNa/icons/folder_loop_cleanup.png +0 -0
- PaIRS_UniNa/icons/folder_loop_cleanup_off.png +0 -0
- PaIRS_UniNa/icons/gear.gif +0 -0
- PaIRS_UniNa/icons/gear.png +0 -0
- PaIRS_UniNa/icons/ger.png +0 -0
- PaIRS_UniNa/icons/greenv.png +0 -0
- PaIRS_UniNa/icons/guide.png +0 -0
- PaIRS_UniNa/icons/icon_CalVi.png +0 -0
- PaIRS_UniNa/icons/icon_PaIRS.png +0 -0
- PaIRS_UniNa/icons/import.png +0 -0
- PaIRS_UniNa/icons/import_set.png +0 -0
- PaIRS_UniNa/icons/information.png +0 -0
- PaIRS_UniNa/icons/information2.png +0 -0
- PaIRS_UniNa/icons/input_logo.png +0 -0
- PaIRS_UniNa/icons/issue.png +0 -0
- PaIRS_UniNa/icons/laser_NTR.png +0 -0
- PaIRS_UniNa/icons/laser_TR_double.png +0 -0
- PaIRS_UniNa/icons/laser_TR_single.png +0 -0
- PaIRS_UniNa/icons/link.png +0 -0
- PaIRS_UniNa/icons/linked.png +0 -0
- PaIRS_UniNa/icons/loaded.png +0 -0
- PaIRS_UniNa/icons/loading_2.gif +0 -0
- PaIRS_UniNa/icons/log_logo.png +0 -0
- PaIRS_UniNa/icons/logo_CalVi.png +0 -0
- PaIRS_UniNa/icons/logo_CalVi_completo.png +0 -0
- PaIRS_UniNa/icons/logo_CalVi_party.png +0 -0
- PaIRS_UniNa/icons/logo_PaIRS.png +0 -0
- PaIRS_UniNa/icons/logo_PaIRS_completo.png +0 -0
- PaIRS_UniNa/icons/logo_PaIRS_download.png +0 -0
- PaIRS_UniNa/icons/logo_PaIRS_party_rect.png +0 -0
- PaIRS_UniNa/icons/logo_PaIRS_rect.png +0 -0
- PaIRS_UniNa/icons/logo_opaco.png +0 -0
- PaIRS_UniNa/icons/mask.png +0 -0
- PaIRS_UniNa/icons/measure.png +0 -0
- PaIRS_UniNa/icons/measure_off.png +0 -0
- PaIRS_UniNa/icons/min_proc.png +0 -0
- PaIRS_UniNa/icons/min_proc_off.png +0 -0
- PaIRS_UniNa/icons/min_step.png +0 -0
- PaIRS_UniNa/icons/min_step_off.png +0 -0
- PaIRS_UniNa/icons/minus.png +0 -0
- PaIRS_UniNa/icons/mirror_u.png +0 -0
- PaIRS_UniNa/icons/mirror_v.png +0 -0
- PaIRS_UniNa/icons/mirror_x.png +0 -0
- PaIRS_UniNa/icons/mirror_y.png +0 -0
- PaIRS_UniNa/icons/mtplt.png +0 -0
- PaIRS_UniNa/icons/new.png +0 -0
- PaIRS_UniNa/icons/new_workspace.png +0 -0
- PaIRS_UniNa/icons/news.png +0 -0
- PaIRS_UniNa/icons/normal_run.png +0 -0
- PaIRS_UniNa/icons/open.png +0 -0
- PaIRS_UniNa/icons/open_image.png +0 -0
- PaIRS_UniNa/icons/open_new_window.png +0 -0
- PaIRS_UniNa/icons/open_result.png +0 -0
- PaIRS_UniNa/icons/open_workspace.png +0 -0
- PaIRS_UniNa/icons/output_logo.png +0 -0
- PaIRS_UniNa/icons/paste_above.png +0 -0
- PaIRS_UniNa/icons/paste_below.png +0 -0
- PaIRS_UniNa/icons/pause.png +0 -0
- PaIRS_UniNa/icons/paused.png +0 -0
- PaIRS_UniNa/icons/pencil_bw.png +0 -0
- PaIRS_UniNa/icons/piv_proc.png +0 -0
- PaIRS_UniNa/icons/piv_proc_off.png +0 -0
- PaIRS_UniNa/icons/piv_step.png +0 -0
- PaIRS_UniNa/icons/piv_step_off.png +0 -0
- PaIRS_UniNa/icons/plane.png +0 -0
- PaIRS_UniNa/icons/play.png +0 -0
- PaIRS_UniNa/icons/plus.png +0 -0
- PaIRS_UniNa/icons/process_logo.png +0 -0
- PaIRS_UniNa/icons/process_loop.png +0 -0
- PaIRS_UniNa/icons/project.png +0 -0
- PaIRS_UniNa/icons/pylog.png +0 -0
- PaIRS_UniNa/icons/python_warning.png +0 -0
- PaIRS_UniNa/icons/queue.png +0 -0
- PaIRS_UniNa/icons/quit.png +0 -0
- PaIRS_UniNa/icons/read.png +0 -0
- PaIRS_UniNa/icons/read_list.png +0 -0
- PaIRS_UniNa/icons/redo.png +0 -0
- PaIRS_UniNa/icons/redx.png +0 -0
- PaIRS_UniNa/icons/reset.png +0 -0
- PaIRS_UniNa/icons/reset_levels.png +0 -0
- PaIRS_UniNa/icons/resize_icon.png +0 -0
- PaIRS_UniNa/icons/restore.png +0 -0
- PaIRS_UniNa/icons/restore_undo.png +0 -0
- PaIRS_UniNa/icons/rotate_clock.png +0 -0
- PaIRS_UniNa/icons/rotate_counter.png +0 -0
- PaIRS_UniNa/icons/rotate_v_clock.png +0 -0
- PaIRS_UniNa/icons/rotate_v_counter.png +0 -0
- PaIRS_UniNa/icons/running.gif +0 -0
- PaIRS_UniNa/icons/running.png +0 -0
- PaIRS_UniNa/icons/running_warn.png +0 -0
- PaIRS_UniNa/icons/sandglass.png +0 -0
- PaIRS_UniNa/icons/save.png +0 -0
- PaIRS_UniNa/icons/save_and_stop.png +0 -0
- PaIRS_UniNa/icons/save_cfg.png +0 -0
- PaIRS_UniNa/icons/saveas.png +0 -0
- PaIRS_UniNa/icons/saveas_workspace.png +0 -0
- PaIRS_UniNa/icons/scale_all.png +0 -0
- PaIRS_UniNa/icons/scale_down.png +0 -0
- PaIRS_UniNa/icons/scale_up.png +0 -0
- PaIRS_UniNa/icons/scan_list.png +0 -0
- PaIRS_UniNa/icons/scan_path.png +0 -0
- PaIRS_UniNa/icons/scan_path_loop.png +0 -0
- PaIRS_UniNa/icons/scan_path_loop_off.png +0 -0
- PaIRS_UniNa/icons/search.png +0 -0
- PaIRS_UniNa/icons/showIW_off.png +0 -0
- PaIRS_UniNa/icons/showIW_on.png +0 -0
- PaIRS_UniNa/icons/show_all.png +0 -0
- PaIRS_UniNa/icons/sort.png +0 -0
- PaIRS_UniNa/icons/sort_reversed.png +0 -0
- PaIRS_UniNa/icons/spiv_proc.png +0 -0
- PaIRS_UniNa/icons/spiv_proc_off.png +0 -0
- PaIRS_UniNa/icons/spiv_setup_no.png +0 -0
- PaIRS_UniNa/icons/spiv_setup_ok.png +0 -0
- PaIRS_UniNa/icons/star.png +0 -0
- PaIRS_UniNa/icons/step_inheritance.png +0 -0
- PaIRS_UniNa/icons/subMIN_off.png +0 -0
- PaIRS_UniNa/icons/subMIN_on.png +0 -0
- PaIRS_UniNa/icons/tom.png +0 -0
- PaIRS_UniNa/icons/trash.png +0 -0
- PaIRS_UniNa/icons/undo.png +0 -0
- PaIRS_UniNa/icons/unedited.png +0 -0
- PaIRS_UniNa/icons/unina_dii.png +0 -0
- PaIRS_UniNa/icons/uninitialized.png +0 -0
- PaIRS_UniNa/icons/unlink.png +0 -0
- PaIRS_UniNa/icons/unwrap_items.png +0 -0
- PaIRS_UniNa/icons/up.png +0 -0
- PaIRS_UniNa/icons/updating_import.gif +0 -0
- PaIRS_UniNa/icons/updating_pairs.gif +0 -0
- PaIRS_UniNa/icons/vectorColor.png +0 -0
- PaIRS_UniNa/icons/vettore.png +0 -0
- PaIRS_UniNa/icons/view.png +0 -0
- PaIRS_UniNa/icons/view_off.png +0 -0
- PaIRS_UniNa/icons/vis_logo.png +0 -0
- PaIRS_UniNa/icons/waiting_circle.png +0 -0
- PaIRS_UniNa/icons/warning.png +0 -0
- PaIRS_UniNa/icons/warning_circle.png +0 -0
- PaIRS_UniNa/icons/window.png +0 -0
- PaIRS_UniNa/icons/workspace.png +0 -0
- PaIRS_UniNa/icons/wrap_items.png +0 -0
- PaIRS_UniNa/icons/write_list.png +0 -0
- PaIRS_UniNa/listLib.py +303 -0
- PaIRS_UniNa/mtfPIV.py +256 -0
- PaIRS_UniNa/parForMulti.py +435 -0
- PaIRS_UniNa/parForWorkers.py +593 -0
- PaIRS_UniNa/pivParFor.py +235 -0
- PaIRS_UniNa/plt_util.py +141 -0
- PaIRS_UniNa/preProcParFor.py +155 -0
- PaIRS_UniNa/procTools.py +1439 -0
- PaIRS_UniNa/readcfg.py +52 -0
- PaIRS_UniNa/rqrdpckgs.txt +9 -0
- PaIRS_UniNa/stereoPivParFor.py +227 -0
- PaIRS_UniNa/tAVarie.py +215 -0
- PaIRS_UniNa/tabSplitter.py +612 -0
- PaIRS_UniNa/ui_Calibration_Tab.py +578 -0
- PaIRS_UniNa/ui_Custom_Top.py +296 -0
- PaIRS_UniNa/ui_Input_Tab.py +1101 -0
- PaIRS_UniNa/ui_Input_Tab_CalVi.py +1283 -0
- PaIRS_UniNa/ui_Log_Tab.py +263 -0
- PaIRS_UniNa/ui_Output_Tab.py +2362 -0
- PaIRS_UniNa/ui_Process_Tab.py +3810 -0
- PaIRS_UniNa/ui_Process_Tab_CalVi.py +1549 -0
- PaIRS_UniNa/ui_Process_Tab_Disp.py +1141 -0
- PaIRS_UniNa/ui_Process_Tab_Min.py +437 -0
- PaIRS_UniNa/ui_ResizePopup.py +204 -0
- PaIRS_UniNa/ui_Vis_Tab.py +1628 -0
- PaIRS_UniNa/ui_Vis_Tab_CalVi.py +1251 -0
- PaIRS_UniNa/ui_Whatsnew.py +132 -0
- PaIRS_UniNa/ui_gPairs.py +877 -0
- PaIRS_UniNa/ui_infoPaIRS.py +551 -0
- PaIRS_UniNa/whatsnew.txt +4 -0
- pairs_unina-0.2.10.dist-info/METADATA +159 -0
- pairs_unina-0.2.10.dist-info/RECORD +333 -0
- pairs_unina-0.2.10.dist-info/WHEEL +5 -0
- pairs_unina-0.2.10.dist-info/top_level.txt +2 -0
PaIRS_UniNa/calib.py
ADDED
|
@@ -0,0 +1,1488 @@
|
|
|
1
|
+
''' helper class for calib'''
|
|
2
|
+
# pylint: disable=pointless-string-statement, too-many-instance-attributes, no-name-in-module, multiple-imports
|
|
3
|
+
# pylint: disable= import-error
|
|
4
|
+
# pylint: disable=multiple-statements
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
import sys #, traceback
|
|
8
|
+
from time import sleep as timesleep
|
|
9
|
+
from typing import Tuple#,Callable
|
|
10
|
+
from enum import Enum
|
|
11
|
+
from time import sleep
|
|
12
|
+
#import faulthandler # per capire da dove vengono gli errori c
|
|
13
|
+
import platform
|
|
14
|
+
|
|
15
|
+
from PIL import Image
|
|
16
|
+
import numpy as np
|
|
17
|
+
|
|
18
|
+
from .tAVarie import pri, PrintTA ,PrintTAPriority
|
|
19
|
+
from .readcfg import readNumCfg, readCfgTag,readNumVecCfg
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
if __package__ or "." in __name__:
|
|
23
|
+
import PaIRS_UniNa.PaIRS_PIV as PaIRS_lib
|
|
24
|
+
from PaIRS_UniNa.PaIRS_PIV import Punto
|
|
25
|
+
from PaIRS_UniNa.PaIRS_PIV import CalFlags
|
|
26
|
+
else:
|
|
27
|
+
if platform.system() == "Darwin":
|
|
28
|
+
sys.path.append('../lib/mac')
|
|
29
|
+
#sys.path.append('../lib')
|
|
30
|
+
else:
|
|
31
|
+
#sys.path.append('PaIRS_PIV')
|
|
32
|
+
sys.path.append('../lib')
|
|
33
|
+
sys.path.append('TpivPython/lib')
|
|
34
|
+
import PaIRS_PIV as PaIRS_lib # type: ignore
|
|
35
|
+
from PaIRS_PIV import Punto # type: ignore
|
|
36
|
+
from PaIRS_PIV import CalFlags # type: ignore
|
|
37
|
+
|
|
38
|
+
# to be deleted
|
|
39
|
+
#import debugpy #nel caso mettere nel thread debugpy.debug_this_thread()
|
|
40
|
+
from .PaIRS_pypacks import Flag_DEBUG_PARPOOL
|
|
41
|
+
#Flag_DEBUG_PARPOOL=1 # pylint: disable=invalid-name
|
|
42
|
+
if Flag_DEBUG_PARPOOL: import debugpy #nel casso mettere nel thread debugpy.debug_this_thread()
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
sleepTimeWorkers=0.2 #for multithreading and other stuff
|
|
46
|
+
FlagReadCfg=True
|
|
47
|
+
PrintTA.flagPriority=PrintTAPriority.veryLow
|
|
48
|
+
# errror codes
|
|
49
|
+
TYPE_ERR_REPEAT=-101 # pylint: disable=invalid-name
|
|
50
|
+
TYPE_ERR_STOP=0 # pylint: disable=invalid-name
|
|
51
|
+
|
|
52
|
+
#for multithreading and other stuff
|
|
53
|
+
SleepTime_Workers=0.1 # pylint: disable=invalid-name
|
|
54
|
+
|
|
55
|
+
class CalibTasks(Enum):
|
|
56
|
+
''' when <=0 no button is created'''
|
|
57
|
+
#stop should be zero so that is is possible to check immediately is no task are running
|
|
58
|
+
stop = 0 # pylint: disable=invalid-name
|
|
59
|
+
findAllPlanes= 1 # pylint: disable=invalid-name
|
|
60
|
+
findCurrentPlane= 2 # pylint: disable=invalid-name
|
|
61
|
+
calibrate=3 # pylint: disable=invalid-name
|
|
62
|
+
savePoints=4 # pylint: disable=invalid-name
|
|
63
|
+
findPlanesFromOrigin=-1 # pylint: disable=invalid-name
|
|
64
|
+
calibTasksText=[
|
|
65
|
+
# the index is relative to the value of CalibTask
|
|
66
|
+
'Stop',
|
|
67
|
+
'Find all' ,
|
|
68
|
+
'Find curr.',
|
|
69
|
+
'Calibrate' ,
|
|
70
|
+
'Save coord.' ,
|
|
71
|
+
'...'
|
|
72
|
+
|
|
73
|
+
]
|
|
74
|
+
''' when not calibrated all the voices are disabled'''
|
|
75
|
+
class CalibFunctions(Enum):
|
|
76
|
+
''' when <=0 only the context menu is added but the button isn't created (negative voices are not disabled)'''
|
|
77
|
+
removeMaxErrPoint= 1 # pylint: disable=invalid-name
|
|
78
|
+
findMaxErrPoint=2 # pylint: disable=invalid-name
|
|
79
|
+
RemovePoint=-3 # pylint: disable=invalid-name
|
|
80
|
+
#findMaxErrPoint1=[3, 4] # pylint: disable=invalid-name
|
|
81
|
+
|
|
82
|
+
calibFunctionsText=[
|
|
83
|
+
# hte index is relative to the value of CalibTask
|
|
84
|
+
'Stop', #not used but needed
|
|
85
|
+
'Delete max.',
|
|
86
|
+
'Focus max.',
|
|
87
|
+
'Apply to all',
|
|
88
|
+
]
|
|
89
|
+
|
|
90
|
+
def loopFun(fun):
|
|
91
|
+
''' loop a function
|
|
92
|
+
if the fun raises exception:
|
|
93
|
+
ValueError as err: if err.args[1]==TYPE_ERR_REPEAT'''
|
|
94
|
+
def wrapper(*args,**kwargs):
|
|
95
|
+
''' wrapper'''
|
|
96
|
+
while True:
|
|
97
|
+
try:
|
|
98
|
+
res=fun(*args,**kwargs)
|
|
99
|
+
except ValueError as err:
|
|
100
|
+
if err.args[1]!=TYPE_ERR_REPEAT:
|
|
101
|
+
raise err
|
|
102
|
+
continue
|
|
103
|
+
break
|
|
104
|
+
return res
|
|
105
|
+
return wrapper
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
class Calib(PaIRS_lib.PyFunOutCalib):
|
|
109
|
+
def __init__(self):
|
|
110
|
+
#super().__init__(mainFun=self.findAllPlanes)
|
|
111
|
+
PaIRS_lib.PyFunOutCalib.__init__(self)
|
|
112
|
+
self.funCalib =PaIRS_lib.getPyFunCalib(self)
|
|
113
|
+
self.pointDesc=['origin ', 'right (along x)','upper (along y)']
|
|
114
|
+
self.inputPoints=[Punto(0,0)]*3 #input points when looking for origin
|
|
115
|
+
self.foundPoints=[Punto(0,0)]*3 #found point near the input points when looking for origin
|
|
116
|
+
self.flagFoundPoints=[False]*3 #flag to be sure that point have been found
|
|
117
|
+
self.cal=PaIRS_lib.Cal()
|
|
118
|
+
self.imgs =[] # Images
|
|
119
|
+
self.ccMask =[] # correlation mask
|
|
120
|
+
self.flagRicerca=0 # 0 stand by 1-3 searching first, second or third point 4 the three point have been found
|
|
121
|
+
|
|
122
|
+
self.plane=self.cal.data.piano=0 # Plane in use
|
|
123
|
+
self.nCams=0 # number of cameras
|
|
124
|
+
self.cams=[] # list of the camera identifiers
|
|
125
|
+
self.nPlanesPerCam=0 # Total number of planes per camera
|
|
126
|
+
self.nPlanes=0 # Total number of planes =nCams*nPlanesPerCam
|
|
127
|
+
self.tipoCal=0 # Calibration type see calibra.h
|
|
128
|
+
# comunication with the view
|
|
129
|
+
self.signals:SignalsCalibWorker=None
|
|
130
|
+
self.ans=0 # Answer from view
|
|
131
|
+
self.pu=Punto(0,0) # Point From view
|
|
132
|
+
self.flagAnsReady=False #True if answer is ready to be read
|
|
133
|
+
self.flagPointReady=False #True if point is ready to be read
|
|
134
|
+
self.flagExitFromView=False #True if exit from View signal
|
|
135
|
+
self.flagFindAllPlanes=False #True if point searching all the planes
|
|
136
|
+
self.cal.flagCalibrated=False # True if the calibration has ended successfully
|
|
137
|
+
# various
|
|
138
|
+
self.cfgName='' # Name of the cfg file comprehensive of path but without extension
|
|
139
|
+
pri.Time.cyan(0,'Init Calib')
|
|
140
|
+
# flags
|
|
141
|
+
self.flagShowMask=True # True to plot the mask #todo maybe in a different window
|
|
142
|
+
self.flagPlotMask=False
|
|
143
|
+
self.strOut=''
|
|
144
|
+
|
|
145
|
+
self.LLim=1
|
|
146
|
+
self.LMax=1
|
|
147
|
+
self.LMin=0
|
|
148
|
+
self.FlagCalibration=False
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def reinitCal(self):
|
|
152
|
+
''' non utilizzata penso di averla messa quando si bloccava in uscita'''
|
|
153
|
+
try:
|
|
154
|
+
del self.cal
|
|
155
|
+
except AttributeError:
|
|
156
|
+
pass
|
|
157
|
+
cal=PaIRS_lib.Cal()
|
|
158
|
+
cal.flagCalibrated=False # True if the calibration has ended successfully
|
|
159
|
+
cal.data.piano=0 # Plane in use
|
|
160
|
+
return cal,cal.data.piano
|
|
161
|
+
|
|
162
|
+
def waitAnsFromView(self)-> int:
|
|
163
|
+
''' used to wait an answer from the view return an int '''
|
|
164
|
+
while not self.flagAnsReady:
|
|
165
|
+
sleep(SleepTime_Workers)
|
|
166
|
+
self.flagAnsReady=False
|
|
167
|
+
|
|
168
|
+
return self.ans
|
|
169
|
+
|
|
170
|
+
def checkExitFromView(self):
|
|
171
|
+
''' control if an exit signal has been emitted by the view and in case raises an error signal'''
|
|
172
|
+
if self.flagExitFromView:
|
|
173
|
+
self.flagExitFromView=False
|
|
174
|
+
self.signals.textFromCalib.emit( 'stopped by user')
|
|
175
|
+
raise ValueError('Exit from view ',TYPE_ERR_STOP)
|
|
176
|
+
|
|
177
|
+
def waitPointFromView(self)-> int:
|
|
178
|
+
''' used to wait a point from the view return an int '''
|
|
179
|
+
while not self.flagPointReady and not self.flagExitFromView:
|
|
180
|
+
sleep(SleepTime_Workers)
|
|
181
|
+
self.flagPointReady=False
|
|
182
|
+
self.checkExitFromView()
|
|
183
|
+
return self.pu
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def askToRetry(self, funName:str):
|
|
188
|
+
''' used to avoid repeating code'''
|
|
189
|
+
self.signals.askFromCalib.emit('Press Yes to continue No to repeat' )
|
|
190
|
+
if not self.waitAnsFromView():
|
|
191
|
+
raise ValueError(f'Repeat in {funName}',TYPE_ERR_REPEAT)
|
|
192
|
+
|
|
193
|
+
def exceptAskRetry(self, exc:Exception, question: str,funName:str):
|
|
194
|
+
''' used to avoid repeating code'''
|
|
195
|
+
if len(exc.args) >1:# if not most probably from c Lib
|
|
196
|
+
if exc.args[1]==TYPE_ERR_STOP:# just exit
|
|
197
|
+
raise exc
|
|
198
|
+
self.signals.askFromCalib.emit(question)
|
|
199
|
+
if self.waitAnsFromView():
|
|
200
|
+
raise ValueError(f'Repeat in {funName}',TYPE_ERR_REPEAT) from exc
|
|
201
|
+
raise ValueError(f'Search stopped in {funName}',TYPE_ERR_STOP) from exc
|
|
202
|
+
@loopFun
|
|
203
|
+
def findPoint(self)->Punto:
|
|
204
|
+
''' look for a single point '''
|
|
205
|
+
self.signals.flagGetPointFromCalib.emit(1) #enables the search for points in the view
|
|
206
|
+
pu=self.waitPointFromView()
|
|
207
|
+
self.signals.flagGetPointFromCalib.emit(0) #disables the search for points in the view
|
|
208
|
+
sleep(0)
|
|
209
|
+
try:
|
|
210
|
+
pu=self.cal.findPoint(pu)
|
|
211
|
+
except ValueError as exc:
|
|
212
|
+
self.exceptAskRetry( exc, 'Point not found Yes to repeat No to stop','findPoint')
|
|
213
|
+
#pri.Info.white(f'findPoint ({pu.x}, {pu.y})')
|
|
214
|
+
self.signals.drawSingleCircleFromCalib.emit(pu,0,self.flagRicerca-1) # draws a circle on the detected points
|
|
215
|
+
return pu
|
|
216
|
+
|
|
217
|
+
@loopFun
|
|
218
|
+
def findPlaneFrom3Points(self,plane=0,op=0):
|
|
219
|
+
''' ask the user to input the 3 points and then finds the spots in the plane'''
|
|
220
|
+
try:
|
|
221
|
+
#pri.Info.magenta(plane)
|
|
222
|
+
self.resetFindPlane(plane)
|
|
223
|
+
for i in range (3):
|
|
224
|
+
self.signals.textFromCalib.emit(f'Select the {self.pointDesc[i]} point')
|
|
225
|
+
self.flagRicerca=i+1
|
|
226
|
+
self.foundPoints[i]=pu= self.findPoint()
|
|
227
|
+
self.flagFoundPoints[i]=True
|
|
228
|
+
self.signals.drawSingleCircleFromCalib.emit(pu,1,0) # draws a circle on the detected points
|
|
229
|
+
self.evalAnglesFindPlanes(op=op)
|
|
230
|
+
except ValueError as exc:
|
|
231
|
+
self.exceptAskRetry( exc, 'Plane not found Yes to repeat No to stop','findPlane')
|
|
232
|
+
self.askToRetry('findPlane')
|
|
233
|
+
|
|
234
|
+
@loopFun
|
|
235
|
+
def findPlaneFromOrigin(self,plane=1,op=1):
|
|
236
|
+
''' ask the user to input the origin then finds the spots in the plane
|
|
237
|
+
op is passed to the lib function evalAngles and should be equal to_
|
|
238
|
+
* 0:// evaluate angles from 3 points in input
|
|
239
|
+
* 1:// only the origin. Should be the second plane and the first should be already have been processed
|
|
240
|
+
* 2:// Nothing Should be the at least the third plane and the first two should be already have been processed
|
|
241
|
+
* 3:// multiplane target
|
|
242
|
+
'''
|
|
243
|
+
try:
|
|
244
|
+
self.resetFindPlane(plane)
|
|
245
|
+
self.signals.textFromCalib.emit(f'Select the {self.pointDesc[0]} point')
|
|
246
|
+
self.flagRicerca=1
|
|
247
|
+
self.foundPoints[0]=pu=self.findPoint()
|
|
248
|
+
self.flagFoundPoints[0]=True
|
|
249
|
+
self.signals.drawSingleCircleFromCalib.emit(pu,1,0)
|
|
250
|
+
self.evalAnglesFindPlanes(op=op)
|
|
251
|
+
except ValueError as exc:
|
|
252
|
+
self.exceptAskRetry( exc, 'Plane not found Yes to repeat No to stop','findPlaneFromOrigin')
|
|
253
|
+
self.askToRetry('findPlaneFromOrigin')
|
|
254
|
+
|
|
255
|
+
def findPlaneAutomatic(self,plane:int,op:int):
|
|
256
|
+
''' Automatic selection of the origin then finds the spots in the plane'''
|
|
257
|
+
self.signals.textFromCalib.emit('Automatic selection of the origin')
|
|
258
|
+
try:
|
|
259
|
+
self.resetFindPlane(plane)
|
|
260
|
+
self.evalAnglesFindPlanes(op=op)
|
|
261
|
+
except ValueError as exc:
|
|
262
|
+
try:
|
|
263
|
+
self.signals.textFromCalib.emit(exc.args[0])# todo mettere anche dove si vuole sapere l'errore preciso della libreria
|
|
264
|
+
self.exceptAskRetry( exc, 'Plane not found Yes for manual search No to exit','findPlaneAutomatic')
|
|
265
|
+
except ValueError as err:# looking for a plane from the origin
|
|
266
|
+
if err.args[1]==TYPE_ERR_REPEAT:
|
|
267
|
+
self.findPlaneFrom3Points(plane=plane)
|
|
268
|
+
#self.findPlaneFromOrigin(plane=plane,op=2) # this is not possibile unless on changes the behavior of the library
|
|
269
|
+
else :
|
|
270
|
+
#print('Si dovrebbe uscire senza errore')
|
|
271
|
+
pass
|
|
272
|
+
return
|
|
273
|
+
|
|
274
|
+
#self.askToRetry('findPlaneAutomatic')
|
|
275
|
+
self.signals.askFromCalib.emit('Press Yes to continue No for manual search' )
|
|
276
|
+
if not self.waitAnsFromView():
|
|
277
|
+
self.findPlaneFrom3Points(plane=plane)
|
|
278
|
+
#raise ValueError('Repeat in findPlaneAutomatic',TYPE_ERR_STOP)
|
|
279
|
+
|
|
280
|
+
def tryFindPlane(self,p:int)->int:
|
|
281
|
+
''' call find plane only if needed '''
|
|
282
|
+
err=0
|
|
283
|
+
flagPlane=self.cal.vect.flagPlane[p]
|
|
284
|
+
#flagPlane=self.cal.getFlagPlane(p)
|
|
285
|
+
if flagPlane:# the points have not been found
|
|
286
|
+
|
|
287
|
+
if flagPlane & CalFlags.PLANE_ORIGIN_NOT_FOUND: # no origin error code
|
|
288
|
+
#pri.Info.red('getFlagPlane-> searching????')
|
|
289
|
+
err=-1
|
|
290
|
+
return err
|
|
291
|
+
try:
|
|
292
|
+
self.findPlane(p)
|
|
293
|
+
except ValueError:
|
|
294
|
+
return -1
|
|
295
|
+
|
|
296
|
+
return err
|
|
297
|
+
|
|
298
|
+
def findPlane(self,p:int):
|
|
299
|
+
''' find all the points in a plane'''
|
|
300
|
+
try:
|
|
301
|
+
self.cal.findPlane(p)
|
|
302
|
+
except RuntimeError as exc:
|
|
303
|
+
raise ValueError('Plane not found in findPlane',TYPE_ERR_REPEAT) from exc
|
|
304
|
+
self.cal.vect.flagPlane[p]=0
|
|
305
|
+
#self.cal.setPlaneFound(p,True)
|
|
306
|
+
|
|
307
|
+
def taskFindAllPlanes(self):
|
|
308
|
+
''' finds all the planes '''
|
|
309
|
+
self.cal.flagCalibrated=False # True if the calibration has ended successfully
|
|
310
|
+
self.cal.flagWorking=1
|
|
311
|
+
self.flagFindAllPlanes=True
|
|
312
|
+
tipoCal = (self.cal.data.TipoCal >> CalFlags.SHIFT) &CalFlags.MASK#calibration type
|
|
313
|
+
try:
|
|
314
|
+
for c in range(self.nCams):
|
|
315
|
+
p0=c*self.nPlanesPerCam
|
|
316
|
+
self.findPlaneFrom3Points(plane=p0)
|
|
317
|
+
if self.cal.data.TipoTarget==1: #
|
|
318
|
+
for p in range(1,self.nPlanesPerCam):
|
|
319
|
+
self.findPlaneAutomatic(p0+p,3) #double plane target op=3
|
|
320
|
+
elif tipoCal==0:#calibrazione normale only origin op=1
|
|
321
|
+
self.findPlaneFromOrigin(plane=p0+1) # only origin op=1
|
|
322
|
+
for p in range(2,self.nPlanesPerCam):
|
|
323
|
+
self.findPlaneAutomatic(p0+p,2) # normal plane automatic op=2
|
|
324
|
+
else:#CpP, cyl or other things per plane calibration op=0
|
|
325
|
+
for p in range(1,self.nPlanesPerCam):
|
|
326
|
+
self.findPlaneFrom3Points(plane=p0+p,op=0)
|
|
327
|
+
#Nel caso avvisare cambio camera
|
|
328
|
+
#for p in range(self.nPlanes):
|
|
329
|
+
except ValueError as exc:
|
|
330
|
+
raise exc #può succedere in findPlaneAutomatic o se si preme stop
|
|
331
|
+
finally:
|
|
332
|
+
self.flagFindAllPlanes=False
|
|
333
|
+
self.cal.flagWorking=0
|
|
334
|
+
|
|
335
|
+
def taskFindAllPlanesFromOrigin(self):
|
|
336
|
+
''' finds all the spots in the planes when the origins and angles are known'''
|
|
337
|
+
self.cal.flagWorking=1
|
|
338
|
+
try:
|
|
339
|
+
for c in range(self.nCams):
|
|
340
|
+
p0=c*self.nPlanesPerCam
|
|
341
|
+
for p in range(0,self.nPlanesPerCam):
|
|
342
|
+
self.findPlane(p0+p)
|
|
343
|
+
self.signals.drawCirclesFromCalib.emit(self.plane)
|
|
344
|
+
except ValueError as exc:
|
|
345
|
+
raise exc #può succedere in findPlaneAutomatic o se si preme stop
|
|
346
|
+
finally:
|
|
347
|
+
self.cal.flagWorking=0
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
def evalAnglesFindPlanes(self,op=0)->int:
|
|
352
|
+
''' op is passed to the lib function evalAngles and should be equal to_
|
|
353
|
+
* 0:// evaluate angles from 3 points in input
|
|
354
|
+
* 1:// only the origin. Should be the second plane and the first should be already have been processed
|
|
355
|
+
* 2:// Nothing Should be the at least the third plane and the first two should be already have been processed
|
|
356
|
+
* 3:// multiplane target
|
|
357
|
+
|
|
358
|
+
'''
|
|
359
|
+
self.cal.evalAngles(self.plane,op,self.foundPoints)
|
|
360
|
+
self.cal.cleanPlanes()
|
|
361
|
+
self.findPlane(self.plane)
|
|
362
|
+
self.signals.drawCirclesFromCalib.emit(self.plane)
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
def changeMask(self,plane:int):
|
|
366
|
+
''' used after changing the mask origin may or may have not been found
|
|
367
|
+
* stores plane in self.plane
|
|
368
|
+
* plot the image
|
|
369
|
+
* initFindPoint and allocate memory if needed'''
|
|
370
|
+
|
|
371
|
+
self.cal.data.piano=self.plane=plane
|
|
372
|
+
self.cal.vect.flagPlane[plane]|= CalFlags.PLANE_NOT_INIT_TROVA_PUNTO|CalFlags.PLANE_NOT_FOUND
|
|
373
|
+
|
|
374
|
+
if (self.cal.originFound (self.plane)):
|
|
375
|
+
self.findPlane(self.plane)
|
|
376
|
+
else:
|
|
377
|
+
self.cal.initFindPoint(self.plane)
|
|
378
|
+
self.cal.removeBulk()
|
|
379
|
+
self.ccMask=self.cal.getMask()
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
def resetFindPlane(self,plane:int):
|
|
383
|
+
''' reset the plane
|
|
384
|
+
* stores plane in self.plane
|
|
385
|
+
* plot the image
|
|
386
|
+
* initFindPoint and allocate memory if needed'''
|
|
387
|
+
self.flagRicerca=1
|
|
388
|
+
self.cal.data.piano=self.plane=plane
|
|
389
|
+
self.cal.setOriginFound (self.plane,False)
|
|
390
|
+
#self.cal.vect.flagPlane[plane]|= CalFlags.PLANE_ORIGIN_NOT_FOUND|CalFlags.PLANE_NOT_FOUND
|
|
391
|
+
self.flagFoundPoints=[False]*len(self.flagFoundPoints)
|
|
392
|
+
self.cal.initFindPoint(self.plane)
|
|
393
|
+
self.signals.plotImgFromCalib.emit(self.plane,True)
|
|
394
|
+
|
|
395
|
+
def taskFindCurrentPlane(self):
|
|
396
|
+
''' finds a single plane '''
|
|
397
|
+
'''self.signals.textFromCalib.emit(f'FindCurrentPlane work in progress')
|
|
398
|
+
self.cal.flagCalibrated=False # True if the calibration has ended successfully
|
|
399
|
+
for i in range (5):
|
|
400
|
+
sleep(1)
|
|
401
|
+
self.checkExitFromView()
|
|
402
|
+
pri.Info.white (f'findCurrentPlane {i}')
|
|
403
|
+
self.signals.textFromCalib.emit(f'')
|
|
404
|
+
|
|
405
|
+
'''
|
|
406
|
+
self.cal.flagWorking=1
|
|
407
|
+
self.cal.flagCalibrated=False # True if the calibration has ended successfully
|
|
408
|
+
try:
|
|
409
|
+
self.findPlaneFrom3Points(plane=self.plane)
|
|
410
|
+
except ValueError as exc:
|
|
411
|
+
raise exc #può succedere in findPlaneAutomatic o se si preme stop
|
|
412
|
+
finally:
|
|
413
|
+
self.cal.flagWorking=0
|
|
414
|
+
|
|
415
|
+
def funOutCalib(self, flag,s) :
|
|
416
|
+
''' called by the library when calibrating '''
|
|
417
|
+
#print(f' funOutCalib {flag} {s}',end='')
|
|
418
|
+
if self.flagExitFromView is True:
|
|
419
|
+
return -1
|
|
420
|
+
|
|
421
|
+
if flag==0:
|
|
422
|
+
self.signals.textFromCalib.emit(self.strOut)
|
|
423
|
+
self.strOut=s
|
|
424
|
+
elif flag==1:
|
|
425
|
+
self.strOut+=s
|
|
426
|
+
#self.app.processEvents()
|
|
427
|
+
return 0
|
|
428
|
+
|
|
429
|
+
def taskSavePoints(self):
|
|
430
|
+
''' saves calibration points'''
|
|
431
|
+
self.cal.flagWorking=1
|
|
432
|
+
try:
|
|
433
|
+
self.cal.savePoints()
|
|
434
|
+
except RuntimeError as exc:
|
|
435
|
+
raise exc #todo a single error otherwise we should use more try blocks
|
|
436
|
+
finally:
|
|
437
|
+
self.signals.textFromCalib.emit(f'')
|
|
438
|
+
self.cal.flagWorking=0
|
|
439
|
+
|
|
440
|
+
def taskCalibrate(self):
|
|
441
|
+
''' calibrates '''
|
|
442
|
+
self.cal.flagWorking=1
|
|
443
|
+
data=self.cal.data
|
|
444
|
+
tipoCal = (data.TipoCal >> CalFlags.SHIFT) &CalFlags.MASK
|
|
445
|
+
try:
|
|
446
|
+
pri.Process.blue ('calibrating ')
|
|
447
|
+
self.signals.textFromCalib.emit('calibrating ')
|
|
448
|
+
pri.Info.white(f'init calibration {self.cal.flagCalibrated}')
|
|
449
|
+
self.cal.calibrate(self.funCalib)
|
|
450
|
+
|
|
451
|
+
while self.cal.flagWorking==2:# and not self.isKilled:
|
|
452
|
+
timesleep(sleepTimeWorkers)
|
|
453
|
+
pri.Info.white(f'end calibration {self.cal.flagCalibrated}')
|
|
454
|
+
self.cal.checkCalibration() #needed because use the main thread and may exit with an exception
|
|
455
|
+
self.FlagCalibration=True
|
|
456
|
+
self.cal.saveCfg (0,self.cfgName)
|
|
457
|
+
|
|
458
|
+
self.cal.saveConst ()
|
|
459
|
+
|
|
460
|
+
if (tipoCal>0 and tipoCal!=2):
|
|
461
|
+
self.cal.saveCfg (1,self.cfgName)
|
|
462
|
+
#self.flagCalibrated=True
|
|
463
|
+
except RuntimeError as exc:
|
|
464
|
+
raise exc #todo a single error otherwise we should use more try blocks
|
|
465
|
+
finally:
|
|
466
|
+
self.signals.textFromCalib.emit(f'')
|
|
467
|
+
self.cal.flagWorking=0
|
|
468
|
+
|
|
469
|
+
#self.cal.out.XcPun[0]=8
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
strPriCalib=self.prettyPrintCalib()
|
|
473
|
+
strPriErrCalib=self.prettyPrintErrCalib()
|
|
474
|
+
pri.Process.blue (strPriErrCalib)
|
|
475
|
+
|
|
476
|
+
self.signals.textFromCalib.emit(strPriErrCalib+'\n'+strPriCalib)
|
|
477
|
+
self.cal.data.piano=self.plane=0
|
|
478
|
+
self.signals.plotImgFromCalib.emit(self.plane,False )
|
|
479
|
+
self.signals.drawCirclesFromCalib.emit(self.plane)
|
|
480
|
+
def prettyPrintErrCalib(self)-> str:
|
|
481
|
+
''' generate a string with a "pretty" version of the calibration error '''
|
|
482
|
+
data=self.cal.data
|
|
483
|
+
strAppo=f'#Points = { data.Npti}\n'
|
|
484
|
+
strAppo+=f'ErrRms={data.Errrms:.3f} ErrMax={data.ErrMax:.3f} \nImg ({data.XMax:.2f}, {data.YMax:.2f}) Space({data.xMax:.2f}, {data.yMax:.2f}, {data.zMax:.2f})'
|
|
485
|
+
return strAppo
|
|
486
|
+
def prettyPrintCalib(self)-> str:
|
|
487
|
+
''' generate a string with a "pretty" version of the calibration parameters '''
|
|
488
|
+
data=self.cal.data
|
|
489
|
+
cost=self.cal.vect.cost
|
|
490
|
+
convGradi=180/np.pi
|
|
491
|
+
tipoCal = (data.TipoCal >> CalFlags.SHIFT) &CalFlags.MASK
|
|
492
|
+
flagPinHole =not (not( data.TipoCal & CalFlags.Flag_PIANI)) # pylint: disable=unneeded-not,superfluous-parens
|
|
493
|
+
#F_Sa = not (not(data.TipoCal & CalFlags.Flag_LIN_VI))
|
|
494
|
+
s=''
|
|
495
|
+
if (data.FlagCal == 1 or data.FlagCal == 2 or data.FlagCal == 3):
|
|
496
|
+
c = 0
|
|
497
|
+
for i in range (4, data.NumCostCalib):
|
|
498
|
+
s+=f'{cost[c][i]:+.4g} '
|
|
499
|
+
else: # TSAI di qualche forma!!!!!!!!
|
|
500
|
+
if (tipoCal> 0 or ( (data.FlagCal >= 10 and data.FlagCal <= 43)and flagPinHole)):#la seconda dovrebbe comprendere la prima
|
|
501
|
+
cPlanes=self.cal.vect.costPlanes
|
|
502
|
+
s+='Planes ******************\r\n'
|
|
503
|
+
for i in range ( data.Numpiani_PerCam):
|
|
504
|
+
s+=f'Plane {i}: Ang(°)=[{cPlanes[i,0]:+.2f},{cPlanes[i,1]:+.2f},{cPlanes[i,2]:+.2f}] T=[{cPlanes[i,3]:+.2f},{cPlanes[i,4]:+.2f},{cPlanes[i,5]:+.2f}]\r\n'
|
|
505
|
+
if data.FlagCal >= 30:#cal cilindrica
|
|
506
|
+
c = 0
|
|
507
|
+
s+='Cylinder ****************\r\n'
|
|
508
|
+
s+=f'Distortion s1={cost[c][24]:.2e} s2={cost[c][25]:.2e}\r\n'
|
|
509
|
+
s+=f'T(Cyl)=[{cost[c][17]:+.2f},{cost[c][18]:+.2f}] Ang(°)=[{cost[c][19]:+.2f},{cost[c][20]:+.2f}]\r\n'
|
|
510
|
+
s+=f'r(Cyl)=[{cost[c][21]:+.2f},{cost[c][21]+cost[c][22]:+.2f}] rho={cost[c][23]:+.2f} \r\n'
|
|
511
|
+
s+='Cameras ***************\r\n'
|
|
512
|
+
for c in range(data.NCam):
|
|
513
|
+
if cost[c][1] < 0:
|
|
514
|
+
s+='\r\n \r\n ******* The coordinate system is not right-handed ******* \r\n \r\n'
|
|
515
|
+
#Flag Rot Rot Rot Tx Ty Tz f u0 v0 b1 b2 k1 k2 p1 p2 sx S
|
|
516
|
+
|
|
517
|
+
s+=f'** c={c} Ang(°)=[{cost[c][2] * convGradi:+.2f},{cost[c][3] * convGradi:+.2f},{cost[c][4] * convGradi:+.2f}] '
|
|
518
|
+
s+=f'T=[{cost[c][5]:+.2f},{cost[c][6]:+.2f},{cost[c][7]:+.2f}] \r\n'
|
|
519
|
+
s+=f' f={cost[c][8]:+.2f} T(Img) [{cost[c][9]:+6.4g},{cost[c][10]:+6.4g}] b=[{ cost[c][11]:.2e},{ cost[c][12]:.2e}] \r\n'
|
|
520
|
+
s+=f' k=[{cost[c][13]:.2e},{cost[c][14]:.2e}] p=[{cost[c][15]:.2e},{cost[c][16]:.2e}]\r\n'
|
|
521
|
+
if data.FlagCal >= 30:
|
|
522
|
+
s+=f' Pixel Ratio={cost[c][26]:+.4g} xdim pixel={cost[c][27]:+.4g} \r\n'
|
|
523
|
+
else:
|
|
524
|
+
s+=f' Pixel Ratio={cost[c][17]:+.4g} xdim pixel={cost[c][18]:+.4g} \r\n'
|
|
525
|
+
return s
|
|
526
|
+
|
|
527
|
+
def waitForEver(self):
|
|
528
|
+
''' simply waits for ever'''
|
|
529
|
+
self.signals.flagGetPointFromCalib.emit(1)
|
|
530
|
+
#sleep(SleepTime_Workers)
|
|
531
|
+
self.taskFindAllPlanes()
|
|
532
|
+
i=0
|
|
533
|
+
while True:# and not self.isKilled:
|
|
534
|
+
sleep(SleepTime_Workers*5)
|
|
535
|
+
i+=1
|
|
536
|
+
#pri.Info.white(f'dummy called->{i}')
|
|
537
|
+
|
|
538
|
+
def readCfg(self):
|
|
539
|
+
'''if (platform.system() == "Linux"):
|
|
540
|
+
nomeImg='/mnt/c/Dati/Dropbox/DATI/Piv/calvi/CalVi/img/-2mm_cam0.tif'
|
|
541
|
+
nomeCfg='/mnt/c/Dati/Dropbox/DATI/Piv/calvi/CalVi/NewCam0.cfg'
|
|
542
|
+
else:
|
|
543
|
+
nomeImg='C:/Dati/Dropbox/DATI/Piv/calvi/CalVi/img/-2mm_cam0.tif'
|
|
544
|
+
nomeCfg='C:/Dati/Dropbox/DATI/Piv/calvi/CalVi/NewCam0.cfg'''
|
|
545
|
+
try:
|
|
546
|
+
if FlagReadCfg:
|
|
547
|
+
flagOp=self.cal.readCfg(self.cfgName)
|
|
548
|
+
else:
|
|
549
|
+
#flagOp=self.initDataDoppio_Ger()
|
|
550
|
+
#flagOp=self.initDataDoppio()
|
|
551
|
+
flagOp=self.initData_P()
|
|
552
|
+
#flagOp=self.initData_P_Piano()
|
|
553
|
+
pass
|
|
554
|
+
#except RuntimeError as exc:
|
|
555
|
+
except Exception as exc:
|
|
556
|
+
#traceback.print_exc()
|
|
557
|
+
#pri.Info.white(str(exc.__cause__).split('\n')[3])
|
|
558
|
+
pri.Info.white(str(exc.args[0]).split('\n')[3])
|
|
559
|
+
#'''
|
|
560
|
+
#for i in range(100): print(f'{outDa.z[0]} {outDa.XOr[0]} {outDa.YOr[0]} {outDa.angCol[0]} {outDa.angRow[0]}')
|
|
561
|
+
|
|
562
|
+
self.nCams=self.cal.data.NCam
|
|
563
|
+
self.cams=self.cal.getCams()
|
|
564
|
+
self.nPlanes=self.cal.data.Numpiani
|
|
565
|
+
self.nPlanesPerCam=self.cal.data.Numpiani_PerCam
|
|
566
|
+
|
|
567
|
+
|
|
568
|
+
return flagOp
|
|
569
|
+
|
|
570
|
+
def setLMinMax(self,p=0):
|
|
571
|
+
self.LLim,self.LMax,self.LMin=self.calcLMinMax(p,self.flagPlotMask)
|
|
572
|
+
return
|
|
573
|
+
# TODO GP forse è meglio fissare un LLim positivo ed uno negativo come:
|
|
574
|
+
# perc= 0.2 ad esempio
|
|
575
|
+
# LLMin=LMin-abs((LMax-LMin)*perc)
|
|
576
|
+
# LLMax=LMax+abs((LMax-LMin)*perc)
|
|
577
|
+
# questo potrebbe essere fatto direttamente in fase di plot
|
|
578
|
+
# fra l'altro potremmo calcolare queste cose solo in fase di lettura (o calcolo nel caso della maschera) e non modificarle più
|
|
579
|
+
def calcLMinMax(self,p,flagPlotMask):
|
|
580
|
+
LLim=2**16-1
|
|
581
|
+
if flagPlotMask and len(self.ccMask):
|
|
582
|
+
a=self.ccMask[p]
|
|
583
|
+
flagArray=True
|
|
584
|
+
elif len(self.imgs):
|
|
585
|
+
a=self.imgs[p]
|
|
586
|
+
LLim=np.iinfo(a.dtype).max
|
|
587
|
+
flagArray=True
|
|
588
|
+
else:
|
|
589
|
+
flagArray=False
|
|
590
|
+
if flagArray:
|
|
591
|
+
try:
|
|
592
|
+
LMax=int(a.max())
|
|
593
|
+
except:
|
|
594
|
+
LMax=LLim
|
|
595
|
+
try:
|
|
596
|
+
LMin=int(a.min())
|
|
597
|
+
except:
|
|
598
|
+
LMin=-LLim
|
|
599
|
+
else:
|
|
600
|
+
LMax=LLim
|
|
601
|
+
LMin=-LLim
|
|
602
|
+
return LLim,LMax,LMin
|
|
603
|
+
|
|
604
|
+
|
|
605
|
+
def readImgs(self ):
|
|
606
|
+
''' reads the images'''
|
|
607
|
+
for cam in range(self.nCams):
|
|
608
|
+
numero='' if self.cal.data.FlagCam else f'_cam{self.cams[cam]}'
|
|
609
|
+
for p in range(self.nPlanesPerCam):
|
|
610
|
+
nomeImg=self.cal.data.percorso+self.cal.getImgRoot(p)+numero+self.cal.data.EstensioneIn
|
|
611
|
+
da=np.array(Image.open(nomeImg),dtype=float)
|
|
612
|
+
#pri.Info.white (f'{nomeImg}')
|
|
613
|
+
data=self.cal.data
|
|
614
|
+
self.imgs.append(np.ascontiguousarray(da[data.RigaPart:data.RigaPart+data.ImgH,data.ColPart:data.ColPart+data.ImgW],dtype= np.uint16))
|
|
615
|
+
|
|
616
|
+
self.setLMinMax()
|
|
617
|
+
#self.cal.FlagPos=-5
|
|
618
|
+
|
|
619
|
+
'''aaaa=np.array([[[1, 2, 3, 4],[11, 12, 13, 14],[21, 22, 23,24]] ,[[10, 2, 3, 4],[1, 12, 13, 14],[1, 22, 23,24]] ])
|
|
620
|
+
aaaa=np.array([[[[1, 2, 3, 4],[11, 12, 13, 14],[21, 22, 23,24]] ,[[10, 2, 3, 4],[1, 12, 13, 14],[1, 22, 23,24]] ],[[[100, 2, 3, 4],[11, 12, 13, 14],[21, 22, 23,24]] ,[[1000, 2, 3, 4],[1, 12, 13, 14],[1, 22, 23,24]] ]])
|
|
621
|
+
bb=np.ascontiguousarray(aaaa,dtype= np.uint16)
|
|
622
|
+
self.cal.SetImg( [ bb])
|
|
623
|
+
bb
|
|
624
|
+
da[284,202]
|
|
625
|
+
'''
|
|
626
|
+
self.cal.setImgs(self.imgs)
|
|
627
|
+
self.ccMask=self.cal.getMask()
|
|
628
|
+
|
|
629
|
+
|
|
630
|
+
|
|
631
|
+
def initDataDoppio(self)->int:
|
|
632
|
+
|
|
633
|
+
#-------------------------------------- %
|
|
634
|
+
# Not in cfg %
|
|
635
|
+
# --------------------------------------%
|
|
636
|
+
data=self.cal.data
|
|
637
|
+
calVect=self.cal.vect
|
|
638
|
+
FlagCfgAutoGen=1 # auto start as when already processed in this case some additional vectors are needed
|
|
639
|
+
|
|
640
|
+
data.PercErrMax = 0.1 # 0.10 Percentuale massima per errore in posizioneTom da modificare
|
|
641
|
+
|
|
642
|
+
#data.PercRaggioRicerca = 0.4 # 0.40 Not used any more
|
|
643
|
+
# InitParOptCalVi(&dati->POC); #todo
|
|
644
|
+
|
|
645
|
+
#-------------------------------------- %
|
|
646
|
+
# Input and Output parameters %
|
|
647
|
+
# --------------------------------------%
|
|
648
|
+
|
|
649
|
+
data.percorso = '../../../../../New/ProvaCAlvi/in/targetDoppioPiano/' #percorso file di input
|
|
650
|
+
data.EstensioneIn = '.png' #estensione in (b16 o tif)
|
|
651
|
+
data.FlagCam=1 #se =-1 non fa nulla se positivo aggiunge _cam# alla fine del nome img e non mette il numero
|
|
652
|
+
data.percorsoOut = '../../img/calib/' # percorso file di output
|
|
653
|
+
data.NomeFileOut = 'cal' # nome file di output
|
|
654
|
+
cams=[-1]
|
|
655
|
+
data.NCam = len(cams) # Numero di elementi nel vettore cam (numero di camere da calibrare)
|
|
656
|
+
|
|
657
|
+
#-------------------------------------- %
|
|
658
|
+
# Distance between spots %
|
|
659
|
+
# --------------------------------------%
|
|
660
|
+
data.pasX = 10.0 # passo della griglia lungo X
|
|
661
|
+
data.pasY = 10.0 # passo della griglia lungo Y
|
|
662
|
+
#-------------------------------------- %
|
|
663
|
+
# Calibration parameters %
|
|
664
|
+
# --------------------------------------%
|
|
665
|
+
|
|
666
|
+
data.Threshold = 0.6 # valore percentuale della soglia
|
|
667
|
+
data.FlagPos = 1 # Tipo ricerca pallino 1 CC 2 Interp 3 geom Positivi pallini bianchi negativi pallini neri 4 e 5 TopHat piu gaussiana 6 gaussiana
|
|
668
|
+
|
|
669
|
+
|
|
670
|
+
#Cal = (TipoCal >> CalFlags.SHIFT) & CalFlags.MASK;
|
|
671
|
+
#Cyl = (TipoCal >> CalFlags.SHIFT_CYL) & CalFlags.MASK;
|
|
672
|
+
|
|
673
|
+
data.raggioInizialeRicerca=37
|
|
674
|
+
calType=0
|
|
675
|
+
data.TipoCal=self.toTipoCal(calType,0,1,0,0,0)#Type,F_Ph,F_Pl,F_Sa,P_Cyl,P_Ph=0,0,1,0,0,0 # Calibration type [Type F_Ph F_Pl F_Sa P_Cyl P_Ph]
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
|
|
679
|
+
#-------------------------------------- %
|
|
680
|
+
# Image Parameters %
|
|
681
|
+
# --------------------------------------%
|
|
682
|
+
|
|
683
|
+
data.ImgW=1104
|
|
684
|
+
data.ImgH=1996
|
|
685
|
+
data.ColPart=0
|
|
686
|
+
data.RigaPart=0
|
|
687
|
+
#-------------------------------------- %
|
|
688
|
+
# Target parameters %
|
|
689
|
+
# --------------------------------------%
|
|
690
|
+
|
|
691
|
+
data.TipoTarget = 0 # Tipo di target 0 normale singolo piano 1 doppio piano con dx dy sfalsato al 50%)
|
|
692
|
+
data.dx = 5 # TipoTarget==1 sfasamento fra i piani target altirmenti non utlizzato
|
|
693
|
+
data.dy = 5 # TipoTarget==1 sfasamento fra i piani target altirmenti non utlizzato
|
|
694
|
+
data.dz = 1.0 # TipoTarget==1 distanza fra i piani target altirmenti non utlizzato
|
|
695
|
+
if data.TipoTarget==0: data.dx = data.dy = data.dz = 0
|
|
696
|
+
data.Numpiani_PerCam=2 # numero di piani da calibrare per camera in caso di target doppio piano inserire 2 * numero di spastamenti target
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
data.Numpiani = data.NCam * data.Numpiani_PerCam
|
|
700
|
+
additionalPar=[34,1,0.011,10,10,1 ] # Calibration type and parameters (12)
|
|
701
|
+
#aa=[self.cal.getImgRoot(p) for p in range(data.Numpiani)]
|
|
702
|
+
self.cal.allocAndinit(additionalPar,0)
|
|
703
|
+
for i,c in enumerate (cams):
|
|
704
|
+
calVect.cam[i]=c
|
|
705
|
+
# -------------------------------------- %
|
|
706
|
+
# Plane img name and coordinates %
|
|
707
|
+
# -------------------------------------- %
|
|
708
|
+
calVect=self.cal.vect
|
|
709
|
+
imgRoot=['JetCal_cam0_20_0', 'JetCal_cam0_20_0']# the number of items should be equal to data.Numpiani_PerCam
|
|
710
|
+
z=[20 ,21]#should be set also when per plane calibration is active
|
|
711
|
+
costPlanes=[[0, 0, 1, 1, 2, 2],
|
|
712
|
+
[0, 0, 1, 1, 2, 2],
|
|
713
|
+
[0, 0, 1, 1, 2, 2],
|
|
714
|
+
[0, 0, 1, 1, 2, 2],
|
|
715
|
+
]
|
|
716
|
+
orPosAndShift=[# Origin Position and Shift repeated for each plane of each camera
|
|
717
|
+
[406.921,1085.14,0,0],
|
|
718
|
+
[456.143,994.494,0,0],]
|
|
719
|
+
angAndMask=[# Angles and e Mask coordinates repeated for each plane of each camera
|
|
720
|
+
[0.00639783,-1.56869,0,0,0,0],
|
|
721
|
+
[0.00639783,-1.56869,0,0,0,0],
|
|
722
|
+
]
|
|
723
|
+
|
|
724
|
+
spotDistAndRemoval=[# Spot distances and coordinate for the removal of points repeated for each plane of each camera
|
|
725
|
+
[121,180,0,0,0,0],
|
|
726
|
+
[121,180,0,0,0,0],
|
|
727
|
+
]
|
|
728
|
+
for p1 in range(data.Numpiani_PerCam):
|
|
729
|
+
for c in range(data.NCam):
|
|
730
|
+
p=p1+c*data.Numpiani_PerCam
|
|
731
|
+
self.cal.setImgRoot(p,imgRoot[p1])
|
|
732
|
+
|
|
733
|
+
|
|
734
|
+
if FlagCfgAutoGen:
|
|
735
|
+
calVect.z[p] = z[p]
|
|
736
|
+
calVect.XOr[p] = orPosAndShift[p][0] + data.ColPart
|
|
737
|
+
calVect.YOr[p] = orPosAndShift[p][1] + data.RigaPart
|
|
738
|
+
calVect.angCol[p] = angAndMask[p][0]
|
|
739
|
+
calVect.angRow[p] = angAndMask[p][1]
|
|
740
|
+
|
|
741
|
+
calVect.xOrShift[p] = round(orPosAndShift[p][2])
|
|
742
|
+
calVect.yOrShift[p] = round(orPosAndShift[p][3])
|
|
743
|
+
|
|
744
|
+
self.cal.setPuTrovaCC(angAndMask[p][2:],p)
|
|
745
|
+
#self.cal.getPuTrovaCC(p)
|
|
746
|
+
calVect.dColPix[p] = round(spotDistAndRemoval[p][0])
|
|
747
|
+
calVect.dRigPix[p] = round(spotDistAndRemoval[p][1])
|
|
748
|
+
#self.cal.calcBounds(p)
|
|
749
|
+
calVect.remPointsUp[p] = round(spotDistAndRemoval[p][2])
|
|
750
|
+
calVect.remPointsDo[p] = round(spotDistAndRemoval[p][3])
|
|
751
|
+
calVect.remPointsLe[p] = round(spotDistAndRemoval[p][4])
|
|
752
|
+
calVect.remPointsRi[p] = round(spotDistAndRemoval[p][5])
|
|
753
|
+
|
|
754
|
+
|
|
755
|
+
else:
|
|
756
|
+
calVect.z[p] =z[p1]
|
|
757
|
+
calVect.xOrShift[p] = calVect.yOrShift[p] = 0
|
|
758
|
+
calVect.remPointsUp[p] = calVect.remPointsDo[p] = calVect.remPointsLe[p] = calVect.remPointsRi[p] = 0
|
|
759
|
+
self.cal.setPuTrovaCC([0,0,0,0],p)
|
|
760
|
+
calVect.dColPix[p] =calVect.dRigPix[p] = 10000 #not really important but has to be big
|
|
761
|
+
|
|
762
|
+
|
|
763
|
+
if calType!=0: #no standard calibration planes involved
|
|
764
|
+
calVect.costPlanes[p1]=costPlanes[p1]
|
|
765
|
+
self.cal.allocAndinit(additionalPar,1)
|
|
766
|
+
if calType >= 2:# Calibrazione piano per controllo Legge le costanti di calibrazione
|
|
767
|
+
# si devono leggere o passare le costanti di calibrazione
|
|
768
|
+
for cam in range(data.NCam):
|
|
769
|
+
buffer=f'{data.percorso}{data.NomeFileOut}{abs(calVect.cam[cam])}.cal'
|
|
770
|
+
self.readCalFile(buffer,calVect.cost[cam],data.NumCostCalib)
|
|
771
|
+
self.cal.allocAndinit(additionalPar,2)
|
|
772
|
+
return FlagCfgAutoGen
|
|
773
|
+
|
|
774
|
+
def initDataDoppio_Ger(self)->int:
|
|
775
|
+
|
|
776
|
+
#-------------------------------------- %
|
|
777
|
+
# Not in cfg %
|
|
778
|
+
# --------------------------------------%
|
|
779
|
+
data=self.cal.data
|
|
780
|
+
calVect=self.cal.vect
|
|
781
|
+
FlagCfgAutoGen=0 # auto start as when already processed in this case some additional vectors are needed
|
|
782
|
+
|
|
783
|
+
data.PercErrMax = 0.1 # 0.10 Percentuale massima per errore in posizioneTom da modificare
|
|
784
|
+
|
|
785
|
+
#data.PercRaggioRicerca = 0.4 # 0.40 Not used any more
|
|
786
|
+
# InitParOptCalVi(&dati->POC); #todo
|
|
787
|
+
|
|
788
|
+
#-------------------------------------- %
|
|
789
|
+
# Input and Output parameters %
|
|
790
|
+
# --------------------------------------%
|
|
791
|
+
|
|
792
|
+
data.percorso = '../CALVI_GUI/testCase/' #percorso file di input
|
|
793
|
+
data.EstensioneIn = '.tif' #estensione in (b16 o tif)
|
|
794
|
+
data.FlagCam=0 #se =-1 non fa nulla se positivo aggiunge _cam# alla fine del nome img e non mette il numero
|
|
795
|
+
data.percorsoOut = '../CALVI_GUI/testCase/' # percorso file di output
|
|
796
|
+
data.NomeFileOut = 'cal' # nome file di output
|
|
797
|
+
cams=[0]
|
|
798
|
+
data.NCam = len(cams) # Numero di elementi nel vettore cam (numero di camere da calibrare)
|
|
799
|
+
|
|
800
|
+
#-------------------------------------- %
|
|
801
|
+
# Distance between spots %
|
|
802
|
+
# --------------------------------------%
|
|
803
|
+
data.pasX = 5.0 # passo della griglia lungo X
|
|
804
|
+
data.pasY = 5.0 # passo della griglia lungo Y
|
|
805
|
+
#-------------------------------------- %
|
|
806
|
+
# Calibration parameters %
|
|
807
|
+
# --------------------------------------%
|
|
808
|
+
|
|
809
|
+
data.Threshold = 0.5 # valore percentuale della soglia
|
|
810
|
+
data.FlagPos = 1 # Tipo ricerca pallino 1 CC 2 Interp 3 geom Positivi pallini bianchi negativi pallini neri 4 e 5 TopHat piu gaussiana 6 gaussiana
|
|
811
|
+
|
|
812
|
+
|
|
813
|
+
#Cal = (TipoCal >> CalFlags.SHIFT) & CalFlags.MASK;
|
|
814
|
+
#Cyl = (TipoCal >> CalFlags.SHIFT_CYL) & CalFlags.MASK;
|
|
815
|
+
|
|
816
|
+
data.raggioInizialeRicerca=35
|
|
817
|
+
calType=0
|
|
818
|
+
data.TipoCal=self.toTipoCal(calType,1,1,0,0,0)#Type,F_Ph,F_Pl,F_Sa,P_Cyl,P_Ph=0,0,1,0,0,0 # Calibration type [Type F_Ph F_Pl F_Sa P_Cyl P_Ph]
|
|
819
|
+
|
|
820
|
+
|
|
821
|
+
|
|
822
|
+
#-------------------------------------- %
|
|
823
|
+
# Image Parameters %
|
|
824
|
+
# --------------------------------------%
|
|
825
|
+
|
|
826
|
+
data.ImgW=2050
|
|
827
|
+
data.ImgH=1050
|
|
828
|
+
data.ColPart=0
|
|
829
|
+
data.RigaPart=0
|
|
830
|
+
#-------------------------------------- %
|
|
831
|
+
# Target parameters %
|
|
832
|
+
# --------------------------------------%
|
|
833
|
+
|
|
834
|
+
data.TipoTarget = 0 # Tipo di target 0 normale singolo piano 1 doppio piano con dx dy sfalsato al 50%)
|
|
835
|
+
data.dx = 5 # TipoTarget==1 sfasamento fra i piani target altirmenti non utlizzato
|
|
836
|
+
data.dy = 5 # TipoTarget==1 sfasamento fra i piani target altirmenti non utlizzato
|
|
837
|
+
data.dz = 10.0 # TipoTarget==1 distanza fra i piani target altirmenti non utlizzato
|
|
838
|
+
if data.TipoTarget==0: data.dx = data.dy = data.dz = 0
|
|
839
|
+
data.Numpiani_PerCam=3 # numero di piani da calibrare per camera in caso di target doppio piano inserire 2 * numero di spastamenti target
|
|
840
|
+
|
|
841
|
+
|
|
842
|
+
data.Numpiani = data.NCam * data.Numpiani_PerCam
|
|
843
|
+
additionalPar=[14,1,0.0065 ] # Calibration type and parameters (12)
|
|
844
|
+
#aa=[self.cal.getImgRoot(p) for p in range(data.Numpiani)]
|
|
845
|
+
self.cal.allocAndinit(additionalPar,0)
|
|
846
|
+
for i,c in enumerate (cams):
|
|
847
|
+
calVect.cam[i]=c
|
|
848
|
+
# -------------------------------------- %
|
|
849
|
+
# Plane img name and coordinates %
|
|
850
|
+
# -------------------------------------- %
|
|
851
|
+
calVect=self.cal.vect
|
|
852
|
+
imgRoot=['-10mm','0mm', '10mm']# the number of items should be equal to data.Numpiani_PerCam
|
|
853
|
+
z=[-10,0 ,10]#should be set also when per plane calibration is active
|
|
854
|
+
costPlanes=[[0.0, 0.0, 0.0, 0.0, 0.0, -10.0 ],
|
|
855
|
+
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ],
|
|
856
|
+
[0.0, 0.0, 0.0, 0.0, 0.0, 10.0 ]]
|
|
857
|
+
orPosAndShift=[[0.0]*4]*data.Numpiani
|
|
858
|
+
angAndMask=[[0.0]*6]*data.Numpiani
|
|
859
|
+
spotDistAndRemoval=[[0.0]*6]*data.Numpiani
|
|
860
|
+
"""
|
|
861
|
+
costPlanes=[[0, 0, 1, 1, 2, 2],
|
|
862
|
+
[0, 0, 1, 1, 2, 2],
|
|
863
|
+
[0, 0, 1, 1, 2, 2],
|
|
864
|
+
[0, 0, 1, 1, 2, 2],
|
|
865
|
+
]
|
|
866
|
+
orPosAndShift=[# Origin Position and Shift repeated for each plane of each camera
|
|
867
|
+
[406.921,1085.14,0,0],
|
|
868
|
+
[456.143,994.494,0,0],]
|
|
869
|
+
angAndMask=[# Angles and e Mask coordinates repeated for each plane of each camera
|
|
870
|
+
[0.00639783,-1.56869,0,0,0,0],
|
|
871
|
+
[0.00639783,-1.56869,0,0,0,0],
|
|
872
|
+
]
|
|
873
|
+
|
|
874
|
+
spotDistAndRemoval=[# Spot distances and coordinate for the removal of points repeated for each plane of each camera
|
|
875
|
+
[121,180,0,0,0,0],
|
|
876
|
+
[121,180,0,0,0,0],
|
|
877
|
+
]
|
|
878
|
+
"""
|
|
879
|
+
for p1 in range(data.Numpiani_PerCam):
|
|
880
|
+
for c in range(data.NCam):
|
|
881
|
+
p=p1+c*data.Numpiani_PerCam
|
|
882
|
+
self.cal.setImgRoot(p,imgRoot[p1])
|
|
883
|
+
|
|
884
|
+
|
|
885
|
+
if FlagCfgAutoGen:
|
|
886
|
+
calVect.z[p] = z[p]
|
|
887
|
+
calVect.XOr[p] = orPosAndShift[p][0] + data.ColPart
|
|
888
|
+
calVect.YOr[p] = orPosAndShift[p][1] + data.RigaPart
|
|
889
|
+
calVect.angCol[p] = angAndMask[p][0]
|
|
890
|
+
calVect.angRow[p] = angAndMask[p][1]
|
|
891
|
+
|
|
892
|
+
calVect.xOrShift[p] = round(orPosAndShift[p][2])
|
|
893
|
+
calVect.yOrShift[p] = round(orPosAndShift[p][3])
|
|
894
|
+
|
|
895
|
+
self.cal.setPuTrovaCC(angAndMask[p][2:],p)
|
|
896
|
+
#self.cal.getPuTrovaCC(p)
|
|
897
|
+
calVect.dColPix[p] = round(spotDistAndRemoval[p][0])
|
|
898
|
+
calVect.dRigPix[p] = round(spotDistAndRemoval[p][1])
|
|
899
|
+
#self.cal.calcBounds(p)
|
|
900
|
+
calVect.remPointsUp[p] = round(spotDistAndRemoval[p][2])
|
|
901
|
+
calVect.remPointsDo[p] = round(spotDistAndRemoval[p][3])
|
|
902
|
+
calVect.remPointsLe[p] = round(spotDistAndRemoval[p][4])
|
|
903
|
+
calVect.remPointsRi[p] = round(spotDistAndRemoval[p][5])
|
|
904
|
+
|
|
905
|
+
|
|
906
|
+
else:
|
|
907
|
+
calVect.z[p] =z[p1]
|
|
908
|
+
calVect.xOrShift[p] = calVect.yOrShift[p] = 0
|
|
909
|
+
calVect.remPointsUp[p] = calVect.remPointsDo[p] = calVect.remPointsLe[p] = calVect.remPointsRi[p] = 0
|
|
910
|
+
self.cal.setPuTrovaCC([0,0,0,0],p)
|
|
911
|
+
|
|
912
|
+
|
|
913
|
+
if calType!=0: #no standard calibration planes involved
|
|
914
|
+
calVect.costPlanes[p1]=costPlanes[p1]
|
|
915
|
+
self.cal.allocAndinit(additionalPar,1)
|
|
916
|
+
if calType >= 2:# Calibrazione piano per controllo Legge le costanti di calibrazione
|
|
917
|
+
# si devono leggere o passare le costanti di calibrazione
|
|
918
|
+
for cam in range(data.NCam):
|
|
919
|
+
buffer=f'{data.percorso}{data.NomeFileOut}{abs(calVect.cam[cam])}.cal'
|
|
920
|
+
self.readCalFile(buffer,calVect.cost[cam],data.NumCostCalib)
|
|
921
|
+
self.cal.allocAndinit(additionalPar,2)
|
|
922
|
+
|
|
923
|
+
return FlagCfgAutoGen
|
|
924
|
+
|
|
925
|
+
def initData_P_Ger(self)->int:
|
|
926
|
+
|
|
927
|
+
#-------------------------------------- %
|
|
928
|
+
# Not in cfg %
|
|
929
|
+
# --------------------------------------%
|
|
930
|
+
data=self.cal.data
|
|
931
|
+
calVect=self.cal.vect
|
|
932
|
+
FlagCfgAutoGen=1 # auto start as when already processed in this case some additional vectors are needed
|
|
933
|
+
|
|
934
|
+
data.PercErrMax = 0.1 # 0.10 Percentuale massima per errore in posizioneTom da modificare
|
|
935
|
+
|
|
936
|
+
#data.PercRaggioRicerca = 0.4 # 0.40 Not used any more
|
|
937
|
+
# InitParOptCalVi(&dati->POC); #todo
|
|
938
|
+
|
|
939
|
+
#-------------------------------------- %
|
|
940
|
+
# Input and Output parameters %
|
|
941
|
+
# --------------------------------------%
|
|
942
|
+
|
|
943
|
+
data.percorso = '../CALVI_GUI/testCase/' #percorso file di input
|
|
944
|
+
data.EstensioneIn = '.tif' #estensione in (b16 o tif)
|
|
945
|
+
data.FlagCam=0 #se =-1 non fa nulla se positivo aggiunge _cam# alla fine del nome img e non mette il numero
|
|
946
|
+
data.percorsoOut = '../CALVI_GUI/testCase/' # percorso file di output
|
|
947
|
+
data.NomeFileOut = 'cal' # nome file di output
|
|
948
|
+
cams=[0]
|
|
949
|
+
data.NCam = len(cams) # Numero di elementi nel vettore cam (numero di camere da calibrare)
|
|
950
|
+
#-------------------------------------- %
|
|
951
|
+
# Distance between spots %
|
|
952
|
+
# --------------------------------------%
|
|
953
|
+
data.pasX = 5.0 # passo della griglia lungo X
|
|
954
|
+
data.pasY = 5.0 # passo della griglia lungo Y
|
|
955
|
+
#-------------------------------------- %
|
|
956
|
+
# Calibration parameters %
|
|
957
|
+
# --------------------------------------%
|
|
958
|
+
|
|
959
|
+
data.Threshold = 0.5 # valore percentuale della soglia
|
|
960
|
+
data.FlagPos = 1 # Tipo ricerca pallino 1 CC 2 Interp 3 geom Positivi pallini bianchi negativi pallini neri 4 e 5 TopHat piu gaussiana 6 gaussiana
|
|
961
|
+
|
|
962
|
+
|
|
963
|
+
#Cal = (TipoCal >> CalFlags.SHIFT) & CalFlags.MASK;
|
|
964
|
+
#Cyl = (TipoCal >> CalFlags.SHIFT_CYL) & CalFlags.MASK;
|
|
965
|
+
|
|
966
|
+
data.raggioInizialeRicerca=10
|
|
967
|
+
calType=1
|
|
968
|
+
data.TipoCal=self.toTipoCal(calType,1,1,0,0,0)#Type,F_Ph,F_Pl,F_Sa,P_Cyl,P_Ph=0,0,1,0,0,0 # Calibration type [Type F_Ph F_Pl F_Sa P_Cyl P_Ph]
|
|
969
|
+
|
|
970
|
+
#-------------------------------------- %
|
|
971
|
+
# Image Parameters %
|
|
972
|
+
# --------------------------------------%
|
|
973
|
+
|
|
974
|
+
data.ImgW=2050
|
|
975
|
+
data.ImgH=1050
|
|
976
|
+
data.ColPart=0
|
|
977
|
+
data.RigaPart=0
|
|
978
|
+
#-------------------------------------- %
|
|
979
|
+
# Target parameters %
|
|
980
|
+
# --------------------------------------%
|
|
981
|
+
|
|
982
|
+
data.TipoTarget = 0 # Tipo di target 0 normale singolo piano 1 doppio piano con dx dy sfalsato al 50%)
|
|
983
|
+
data.dx = 0 # TipoTarget==1 sfasamento fra i piani target altirmenti non utlizzato
|
|
984
|
+
data.dy = 0 # TipoTarget==1 sfasamento fra i piani target altirmenti non utlizzato
|
|
985
|
+
data.dz = 0 # TipoTarget==1 distanza fra i piani target altirmenti non utlizzato
|
|
986
|
+
if data.TipoTarget==0: data.dx = data.dy = data.dz = 0
|
|
987
|
+
data.Numpiani_PerCam=3 # numero di piani da calibrare per camera in caso di target doppio piano inserire 2 * numero di spastamenti target
|
|
988
|
+
|
|
989
|
+
|
|
990
|
+
data.Numpiani = data.NCam * data.Numpiani_PerCam
|
|
991
|
+
additionalPar=[14,1,0.0065 ] # Calibration type and parameters (12)
|
|
992
|
+
#aa=[self.cal.getImgRoot(p) for p in range(data.Numpiani)]
|
|
993
|
+
|
|
994
|
+
self.cal.allocAndinit(additionalPar,0)
|
|
995
|
+
for i,c in enumerate (cams):
|
|
996
|
+
calVect.cam[i]=c
|
|
997
|
+
# -------------------------------------- %
|
|
998
|
+
# Plane img name and coordinates %
|
|
999
|
+
# -------------------------------------- %
|
|
1000
|
+
imgRoot=['0mm', '10mm','-10mm']# the number of items should be equal to data.Numpiani_PerCam
|
|
1001
|
+
z=[0 ,0, 0 ,0]#should be set also when per plane calibration is active
|
|
1002
|
+
costPlanes=[[ 2.5e-03, -2.250e-02, 0.0e+00, 2.0e-02, -1.5e-02, 1.8775e+00],
|
|
1003
|
+
[ 1.34894426e-01, 2.91175150e+00, 1.98674975e+00,-8.72858866e-01, -1.99508511e+00, 4.63332625e+00],
|
|
1004
|
+
]
|
|
1005
|
+
orPosAndShift=[# Origin Position and Shift repeated for each plane of each camera
|
|
1006
|
+
[782.439, 497.443, 0, 0],
|
|
1007
|
+
[759.74, 570.252, 0, 0],
|
|
1008
|
+
[540.461, 288.694, 0, 0],
|
|
1009
|
+
[562.007, 287.582, 0, 0]]
|
|
1010
|
+
|
|
1011
|
+
|
|
1012
|
+
angAndMask=[# Angles and e Mask coordinates repeated for each plane of each camera
|
|
1013
|
+
[0.00205666, -1.57294, 0, 0, 0, 0],
|
|
1014
|
+
[0.0523335, -1.55305, 0, 0, 0, 0],
|
|
1015
|
+
[3.13826, 1.56465, 0, 0, 0, 0],
|
|
1016
|
+
[3.13769, 1.61467, 0, 0, 0, 0]
|
|
1017
|
+
]
|
|
1018
|
+
|
|
1019
|
+
spotDistAndRemoval=[# Spot distances and coordinate for the removal of points repeated for each plane of each camera
|
|
1020
|
+
[113, 101, 0, 0, 0, 0],
|
|
1021
|
+
[110, 103, 0, 0, 0, 0],
|
|
1022
|
+
[105, 94, 0, 0, 0, 0] ,
|
|
1023
|
+
[104, 93, 0, 0, 0, 0],
|
|
1024
|
+
]
|
|
1025
|
+
|
|
1026
|
+
for p1 in range(data.Numpiani_PerCam):
|
|
1027
|
+
for c in range(data.NCam):
|
|
1028
|
+
p=p1+c*data.Numpiani_PerCam
|
|
1029
|
+
self.cal.setImgRoot(p,imgRoot[p1])
|
|
1030
|
+
|
|
1031
|
+
|
|
1032
|
+
if FlagCfgAutoGen:
|
|
1033
|
+
calVect.z[p] = z[p]
|
|
1034
|
+
calVect.XOr[p] = orPosAndShift[p][0] + data.ColPart
|
|
1035
|
+
calVect.YOr[p] = orPosAndShift[p][1] + data.RigaPart
|
|
1036
|
+
calVect.angCol[p] = angAndMask[p][0]
|
|
1037
|
+
calVect.angRow[p] = angAndMask[p][1]
|
|
1038
|
+
|
|
1039
|
+
calVect.xOrShift[p] = round(orPosAndShift[p][2])
|
|
1040
|
+
calVect.yOrShift[p] = round(orPosAndShift[p][3])
|
|
1041
|
+
|
|
1042
|
+
self.cal.setPuTrovaCC(angAndMask[p][2:],p)
|
|
1043
|
+
#self.cal.getPuTrovaCC(p)
|
|
1044
|
+
calVect.dColPix[p] = round(spotDistAndRemoval[p][0])
|
|
1045
|
+
calVect.dRigPix[p] = round(spotDistAndRemoval[p][1])
|
|
1046
|
+
#self.cal.calcBounds(p)
|
|
1047
|
+
calVect.remPointsUp[p] = round(spotDistAndRemoval[p][2])
|
|
1048
|
+
calVect.remPointsDo[p] = round(spotDistAndRemoval[p][3])
|
|
1049
|
+
calVect.remPointsLe[p] = round(spotDistAndRemoval[p][4])
|
|
1050
|
+
calVect.remPointsRi[p] = round(spotDistAndRemoval[p][5])
|
|
1051
|
+
|
|
1052
|
+
|
|
1053
|
+
else:
|
|
1054
|
+
calVect.z[p] =z[p1]
|
|
1055
|
+
calVect.xOrShift[p] = calVect.yOrShift[p] = 0
|
|
1056
|
+
calVect.remPointsUp[p] = calVect.remPointsDo[p] = calVect.remPointsLe[p] = calVect.remPointsRi[p] = 0
|
|
1057
|
+
self.cal.setPuTrovaCC([0,0,0,0],p)
|
|
1058
|
+
|
|
1059
|
+
|
|
1060
|
+
if calType!=0: #no standard calibration planes involved
|
|
1061
|
+
calVect.costPlanes[p1]=costPlanes[p1]
|
|
1062
|
+
self.cal.allocAndinit(additionalPar,1)
|
|
1063
|
+
if calType >= 2:# Calibrazione piano per controllo Legge le costanti di calibrazione
|
|
1064
|
+
# si devono leggere o passare le costanti di calibrazione
|
|
1065
|
+
for cam in range(data.NCam):
|
|
1066
|
+
buffer=f'{data.percorso}{data.NomeFileOut}{abs(calVect.cam[cam])}.cal'
|
|
1067
|
+
self.readCalFile(buffer,calVect.cost[cam],data.NumCostCalib)
|
|
1068
|
+
self.cal.allocAndinit(additionalPar,2)
|
|
1069
|
+
return FlagCfgAutoGen
|
|
1070
|
+
|
|
1071
|
+
def initData_P(self)->int:
|
|
1072
|
+
|
|
1073
|
+
#-------------------------------------- %
|
|
1074
|
+
# Not in cfg %
|
|
1075
|
+
# --------------------------------------%
|
|
1076
|
+
data=self.cal.data
|
|
1077
|
+
calVect=self.cal.vect
|
|
1078
|
+
FlagCfgAutoGen=1 # auto start as when already processed in this case some additional vectors are needed
|
|
1079
|
+
|
|
1080
|
+
data.PercErrMax = 0.1 # 0.10 Percentuale massima per errore in posizioneTom da modificare
|
|
1081
|
+
|
|
1082
|
+
#data.PercRaggioRicerca = 0.4 # 0.40 Not used any more
|
|
1083
|
+
# InitParOptCalVi(&dati->POC); #todo
|
|
1084
|
+
|
|
1085
|
+
#-------------------------------------- %
|
|
1086
|
+
# Input and Output parameters %
|
|
1087
|
+
# --------------------------------------%
|
|
1088
|
+
|
|
1089
|
+
data.percorso = '../../../../../New/ProvaCAlvi/in/Pia/' #percorso file di input
|
|
1090
|
+
data.EstensioneIn = '.tif' #estensione in (b16 o tif)
|
|
1091
|
+
data.FlagCam=0 #se =-1 non fa nulla se positivo aggiunge _cam# alla fine del nome img e non mette il numero
|
|
1092
|
+
data.percorsoOut = '../../img/calib/' # percorso file di output
|
|
1093
|
+
data.NomeFileOut = 'cal' # nome file di output
|
|
1094
|
+
cams=[0 ,1]
|
|
1095
|
+
data.NCam = len(cams) # Numero di elementi nel vettore cam (numero di camere da calibrare)
|
|
1096
|
+
#-------------------------------------- %
|
|
1097
|
+
# Distance between spots %
|
|
1098
|
+
# --------------------------------------%
|
|
1099
|
+
data.pasX = 5.0 # passo della griglia lungo X
|
|
1100
|
+
data.pasY = 5.0 # passo della griglia lungo Y
|
|
1101
|
+
#-------------------------------------- %
|
|
1102
|
+
# Calibration parameters %
|
|
1103
|
+
# --------------------------------------%
|
|
1104
|
+
|
|
1105
|
+
data.Threshold = 0.6 # valore percentuale della soglia
|
|
1106
|
+
data.FlagPos = -1 # Tipo ricerca pallino 1 CC 2 Interp 3 geom Positivi pallini bianchi negativi pallini neri 4 e 5 TopHat piu gaussiana 6 gaussiana
|
|
1107
|
+
|
|
1108
|
+
|
|
1109
|
+
#Cal = (TipoCal >> CalFlags.SHIFT) & CalFlags.MASK;
|
|
1110
|
+
#Cyl = (TipoCal >> CalFlags.SHIFT_CYL) & CalFlags.MASK;
|
|
1111
|
+
|
|
1112
|
+
data.raggioInizialeRicerca=37
|
|
1113
|
+
calType=1
|
|
1114
|
+
data.TipoCal=self.toTipoCal(calType,1,1,0,0,0)#Type,F_Ph,F_Pl,F_Sa,P_Cyl,P_Ph=0,0,1,0,0,0 # Calibration type [Type F_Ph F_Pl F_Sa P_Cyl P_Ph]
|
|
1115
|
+
|
|
1116
|
+
#-------------------------------------- %
|
|
1117
|
+
# Image Parameters %
|
|
1118
|
+
# --------------------------------------%
|
|
1119
|
+
data.ImgW=1280
|
|
1120
|
+
data.ImgH=800
|
|
1121
|
+
data.ColPart=0
|
|
1122
|
+
data.RigaPart=0
|
|
1123
|
+
|
|
1124
|
+
#-------------------------------------- %
|
|
1125
|
+
# Target parameters %
|
|
1126
|
+
# --------------------------------------%
|
|
1127
|
+
|
|
1128
|
+
data.TipoTarget = 0 # Tipo di target 0 normale singolo piano 1 doppio piano con dx dy sfalsato al 50%)
|
|
1129
|
+
data.dx = 0 # TipoTarget==1 sfasamento fra i piani target altirmenti non utlizzato
|
|
1130
|
+
data.dy = 0 # TipoTarget==1 sfasamento fra i piani target altirmenti non utlizzato
|
|
1131
|
+
data.dz = 0 # TipoTarget==1 distanza fra i piani target altirmenti non utlizzato
|
|
1132
|
+
if data.TipoTarget==0: data.dx = data.dy = data.dz = 0
|
|
1133
|
+
data.Numpiani_PerCam=2 # numero di piani da calibrare per camera in caso di target doppio piano inserire 2 * numero di spastamenti target
|
|
1134
|
+
|
|
1135
|
+
|
|
1136
|
+
data.Numpiani = data.NCam * data.Numpiani_PerCam
|
|
1137
|
+
additionalPar=[14,1,0.02 ] # Calibration type and parameters (12)
|
|
1138
|
+
#aa=[self.cal.getImgRoot(p) for p in range(data.Numpiani)]
|
|
1139
|
+
|
|
1140
|
+
self.cal.allocAndinit(additionalPar,0)
|
|
1141
|
+
for i,c in enumerate (cams):
|
|
1142
|
+
calVect.cam[i]=c
|
|
1143
|
+
# -------------------------------------- %
|
|
1144
|
+
# Plane img name and coordinates %
|
|
1145
|
+
# -------------------------------------- %
|
|
1146
|
+
imgRoot=['2mm', '1991mm']# the number of items should be equal to data.Numpiani_PerCam
|
|
1147
|
+
z=[0 ,0, 0 ,0]#should be set also when per plane calibration is active
|
|
1148
|
+
costPlanes=[[ 2.5e-03, -2.250e-02, 0.0e+00, 2.0e-02, -1.5e-02, 1.8775e+00],
|
|
1149
|
+
[ 1.34894426e-01, 2.91175150e+00, 1.98674975e+00,-8.72858866e-01, -1.99508511e+00, 4.63332625e+00],
|
|
1150
|
+
]
|
|
1151
|
+
orPosAndShift=[# Origin Position and Shift repeated for each plane of each camera
|
|
1152
|
+
[782.439, 497.443, 0, 0],
|
|
1153
|
+
[759.74, 570.252, 0, 0],
|
|
1154
|
+
[540.461, 288.694, 0, 0],
|
|
1155
|
+
[562.007, 287.582, 0, 0]]
|
|
1156
|
+
|
|
1157
|
+
|
|
1158
|
+
angAndMask=[# Angles and e Mask coordinates repeated for each plane of each camera
|
|
1159
|
+
[0.00205666, -1.57294, 0, 0, 0, 0],
|
|
1160
|
+
[0.0523335, -1.55305, 0, 0, 0, 0],
|
|
1161
|
+
[3.13826, 1.56465, 0, 0, 0, 0],
|
|
1162
|
+
[3.13769, 1.61467, 0, 0, 0, 0]
|
|
1163
|
+
]
|
|
1164
|
+
|
|
1165
|
+
spotDistAndRemoval=[# Spot distances and coordinate for the removal of points repeated for each plane of each camera
|
|
1166
|
+
[113, 101, 0, 0, 0, 0],
|
|
1167
|
+
[110, 103, 0, 0, 0, 0],
|
|
1168
|
+
[105, 94, 0, 0, 0, 0] ,
|
|
1169
|
+
[104, 93, 0, 0, 0, 0],
|
|
1170
|
+
]
|
|
1171
|
+
|
|
1172
|
+
for p1 in range(data.Numpiani_PerCam):
|
|
1173
|
+
for c in range(data.NCam):
|
|
1174
|
+
p=p1+c*data.Numpiani_PerCam
|
|
1175
|
+
self.cal.setImgRoot(p,imgRoot[p1])
|
|
1176
|
+
|
|
1177
|
+
|
|
1178
|
+
if FlagCfgAutoGen:
|
|
1179
|
+
calVect.z[p] = z[p]
|
|
1180
|
+
calVect.XOr[p] = orPosAndShift[p][0] + data.ColPart
|
|
1181
|
+
calVect.YOr[p] = orPosAndShift[p][1] + data.RigaPart
|
|
1182
|
+
calVect.angCol[p] = angAndMask[p][0]
|
|
1183
|
+
calVect.angRow[p] = angAndMask[p][1]
|
|
1184
|
+
|
|
1185
|
+
calVect.xOrShift[p] = round(orPosAndShift[p][2])
|
|
1186
|
+
calVect.yOrShift[p] = round(orPosAndShift[p][3])
|
|
1187
|
+
|
|
1188
|
+
self.cal.setPuTrovaCC(angAndMask[p][2:],p)
|
|
1189
|
+
#self.cal.getPuTrovaCC(p)
|
|
1190
|
+
calVect.dColPix[p] = round(spotDistAndRemoval[p][0])
|
|
1191
|
+
calVect.dRigPix[p] = round(spotDistAndRemoval[p][1])
|
|
1192
|
+
#self.cal.calcBounds(p)
|
|
1193
|
+
calVect.remPointsUp[p] = round(spotDistAndRemoval[p][2])
|
|
1194
|
+
calVect.remPointsDo[p] = round(spotDistAndRemoval[p][3])
|
|
1195
|
+
calVect.remPointsLe[p] = round(spotDistAndRemoval[p][4])
|
|
1196
|
+
calVect.remPointsRi[p] = round(spotDistAndRemoval[p][5])
|
|
1197
|
+
|
|
1198
|
+
|
|
1199
|
+
else:
|
|
1200
|
+
calVect.z[p] =z[p1]
|
|
1201
|
+
calVect.xOrShift[p] = calVect.yOrShift[p] = 0
|
|
1202
|
+
calVect.remPointsUp[p] = calVect.remPointsDo[p] = calVect.remPointsLe[p] = calVect.remPointsRi[p] = 0
|
|
1203
|
+
self.cal.setPuTrovaCC([0,0,0,0],p)
|
|
1204
|
+
calVect.dColPix[p] =calVect.dRigPix[p] = 10000 #not really important but has to be big
|
|
1205
|
+
|
|
1206
|
+
|
|
1207
|
+
if calType!=0: #no standard calibration planes involved
|
|
1208
|
+
calVect.costPlanes[p1]=costPlanes[p1]
|
|
1209
|
+
self.cal.allocAndinit(additionalPar,1)
|
|
1210
|
+
if calType >= 2:# Calibrazione piano per controllo Legge le costanti di calibrazione
|
|
1211
|
+
# si devono leggere o passare le costanti di calibrazione
|
|
1212
|
+
for cam in range(data.NCam):
|
|
1213
|
+
buffer=f'{data.percorso}{data.NomeFileOut}{abs(calVect.cam[cam])}.cal'
|
|
1214
|
+
self.readCalFile(buffer,calVect.cost[cam],data.NumCostCalib)
|
|
1215
|
+
self.cal.allocAndinit(additionalPar,2)
|
|
1216
|
+
return FlagCfgAutoGen
|
|
1217
|
+
|
|
1218
|
+
|
|
1219
|
+
def initData_P_Piano(self)->int:
|
|
1220
|
+
|
|
1221
|
+
#-------------------------------------- %
|
|
1222
|
+
# Not in cfg %
|
|
1223
|
+
# --------------------------------------%
|
|
1224
|
+
data=self.cal.data
|
|
1225
|
+
calVect=self.cal.vect
|
|
1226
|
+
FlagCfgAutoGen=1 # auto start as when already processed in this case some additional vectors are needed
|
|
1227
|
+
|
|
1228
|
+
data.PercErrMax = 0.1 # 0.10 Percentuale massima per errore in posizioneTom da modificare
|
|
1229
|
+
|
|
1230
|
+
#data.PercRaggioRicerca = 0.4 # 0.40 Not used any more
|
|
1231
|
+
# InitParOptCalVi(&dati->POC); #todo
|
|
1232
|
+
|
|
1233
|
+
#-------------------------------------- %
|
|
1234
|
+
# Input and Output parameters %
|
|
1235
|
+
# --------------------------------------%
|
|
1236
|
+
data.percorso = '../../../../../New/ProvaCAlvi/in/Pia/' #percorso file di input
|
|
1237
|
+
data.EstensioneIn = '.tif' #estensione in (b16 o tif)
|
|
1238
|
+
data.FlagCam=0 #se =-1 non fa nulla se positivo aggiunge _cam# alla fine del nome img e non mette il numero
|
|
1239
|
+
data.percorsoOut = '../../img/calib/' # percorso file di output
|
|
1240
|
+
data.NomeFileOut = 'cal' # nome file di output
|
|
1241
|
+
cams=[0 ,1]
|
|
1242
|
+
data.NCam = len(cams) # Numero di elementi nel vettore cam (numero di camere da calibrare)
|
|
1243
|
+
|
|
1244
|
+
#-------------------------------------- %
|
|
1245
|
+
# Distance between spots %
|
|
1246
|
+
# --------------------------------------%
|
|
1247
|
+
data.pasX = 5.0 # passo della griglia lungo X
|
|
1248
|
+
data.pasY = 5.0 # passo della griglia lungo Y
|
|
1249
|
+
#-------------------------------------- %
|
|
1250
|
+
# Calibration parameters %
|
|
1251
|
+
# --------------------------------------%
|
|
1252
|
+
|
|
1253
|
+
data.Threshold = 0.6 # valore percentuale della soglia
|
|
1254
|
+
data.FlagPos = -1 # Tipo ricerca pallino 1 CC 2 Interp 3 geom Positivi pallini bianchi negativi pallini neri 4 e 5 TopHat piu gaussiana 6 gaussiana
|
|
1255
|
+
|
|
1256
|
+
|
|
1257
|
+
#Cal = (TipoCal >> CalFlags.SHIFT) & CalFlags.MASK;
|
|
1258
|
+
#Cyl = (TipoCal >> CalFlags.SHIFT_CYL) & CalFlags.MASK;
|
|
1259
|
+
|
|
1260
|
+
data.raggioInizialeRicerca=37
|
|
1261
|
+
calType=2
|
|
1262
|
+
data.TipoCal=self.toTipoCal(calType,1,1,0,0,0)#Type,F_Ph,F_Pl,F_Sa,P_Cyl,P_Ph=0,0,1,0,0,0 # Calibration type [Type F_Ph F_Pl F_Sa P_Cyl P_Ph]
|
|
1263
|
+
|
|
1264
|
+
#-------------------------------------- %
|
|
1265
|
+
# Image Parameters %
|
|
1266
|
+
# --------------------------------------%
|
|
1267
|
+
|
|
1268
|
+
data.ImgW=1280
|
|
1269
|
+
data.ImgH=800
|
|
1270
|
+
data.ColPart=0
|
|
1271
|
+
data.RigaPart=0
|
|
1272
|
+
#-------------------------------------- %
|
|
1273
|
+
# Target parameters %
|
|
1274
|
+
# --------------------------------------%
|
|
1275
|
+
|
|
1276
|
+
data.TipoTarget = 0 # Tipo di target 0 normale singolo piano 1 doppio piano con dx dy sfalsato al 50%)
|
|
1277
|
+
data.dx = 0 # TipoTarget==1 sfasamento fra i piani target altirmenti non utlizzato
|
|
1278
|
+
data.dy = 0 # TipoTarget==1 sfasamento fra i piani target altirmenti non utlizzato
|
|
1279
|
+
data.dz = 0 # TipoTarget==1 distanza fra i piani target altirmenti non utlizzato
|
|
1280
|
+
if data.TipoTarget==0: data.dx = data.dy = data.dz = 0
|
|
1281
|
+
data.Numpiani_PerCam=1 # numero di piani da calibrare per camera in caso di target doppio piano inserire 2 * numero di spastamenti target
|
|
1282
|
+
|
|
1283
|
+
|
|
1284
|
+
data.Numpiani = data.NCam * data.Numpiani_PerCam
|
|
1285
|
+
additionalPar=[14,1,0.02 ] # Calibration type and parameters (12)
|
|
1286
|
+
#aa=[self.cal.getImgRoot(p) for p in range(data.Numpiani)]
|
|
1287
|
+
|
|
1288
|
+
self.cal.allocAndinit(additionalPar,0)
|
|
1289
|
+
for i,c in enumerate (cams):
|
|
1290
|
+
calVect.cam[i]=c
|
|
1291
|
+
# -------------------------------------- %
|
|
1292
|
+
# Plane img name and coordinates %
|
|
1293
|
+
# -------------------------------------- %
|
|
1294
|
+
imgRoot=['2mm', '1991mm']# the number of items should be equal to data.Numpiani_PerCam
|
|
1295
|
+
z=[0 ,0, 0 ,0]#should be set also when per plane calibration is active
|
|
1296
|
+
costPlanes=[[ -3.60015048016046e+02, -2.07316568271620e-02 ,-1.79997723561649e+02, 5.02013720544883e+00, 4.98453013490223e+00, 1.87393988788882e+00 ],
|
|
1297
|
+
|
|
1298
|
+
]
|
|
1299
|
+
orPosAndShift=[# Origin Position and Shift repeated for each plane of each camera
|
|
1300
|
+
[782.439, 497.443, 0, 0],
|
|
1301
|
+
[540.461, 288.694, 0, 0],
|
|
1302
|
+
]
|
|
1303
|
+
|
|
1304
|
+
|
|
1305
|
+
angAndMask=[# Angles and e Mask coordinates repeated for each plane of each camera
|
|
1306
|
+
[-3.14044 ,-1.57307, 0, 0, 0, 0],
|
|
1307
|
+
[-0.00289468 ,1.57463 , 0, 0, 0, 0],
|
|
1308
|
+
|
|
1309
|
+
]
|
|
1310
|
+
|
|
1311
|
+
spotDistAndRemoval=[# Spot distances and coordinate for the removal of points repeated for each plane of each camera
|
|
1312
|
+
[110, 101, 0, 0, 0, 0],
|
|
1313
|
+
[107, 94, 0, 0, 0, 0] ,
|
|
1314
|
+
]
|
|
1315
|
+
|
|
1316
|
+
for p1 in range(data.Numpiani_PerCam):
|
|
1317
|
+
for c in range(data.NCam):
|
|
1318
|
+
p=p1+c*data.Numpiani_PerCam
|
|
1319
|
+
self.cal.setImgRoot(p,imgRoot[p1])
|
|
1320
|
+
|
|
1321
|
+
|
|
1322
|
+
if FlagCfgAutoGen:
|
|
1323
|
+
calVect.z[p] = z[p]
|
|
1324
|
+
calVect.XOr[p] = orPosAndShift[p][0] + data.ColPart
|
|
1325
|
+
calVect.YOr[p] = orPosAndShift[p][1] + data.RigaPart
|
|
1326
|
+
calVect.angCol[p] = angAndMask[p][0]
|
|
1327
|
+
calVect.angRow[p] = angAndMask[p][1]
|
|
1328
|
+
|
|
1329
|
+
calVect.xOrShift[p] = round(orPosAndShift[p][2])
|
|
1330
|
+
calVect.yOrShift[p] = round(orPosAndShift[p][3])
|
|
1331
|
+
|
|
1332
|
+
self.cal.setPuTrovaCC(angAndMask[p][2:],p)
|
|
1333
|
+
#self.cal.getPuTrovaCC(p)
|
|
1334
|
+
calVect.dColPix[p] = round(spotDistAndRemoval[p][0])
|
|
1335
|
+
calVect.dRigPix[p] = round(spotDistAndRemoval[p][1])
|
|
1336
|
+
#self.cal.calcBounds(p)
|
|
1337
|
+
calVect.remPointsUp[p] = round(spotDistAndRemoval[p][2])
|
|
1338
|
+
calVect.remPointsDo[p] = round(spotDistAndRemoval[p][3])
|
|
1339
|
+
calVect.remPointsLe[p] = round(spotDistAndRemoval[p][4])
|
|
1340
|
+
calVect.remPointsRi[p] = round(spotDistAndRemoval[p][5])
|
|
1341
|
+
|
|
1342
|
+
|
|
1343
|
+
else:
|
|
1344
|
+
calVect.z[p] =z[p1]
|
|
1345
|
+
calVect.xOrShift[p] = calVect.yOrShift[p] = 0
|
|
1346
|
+
calVect.remPointsUp[p] = calVect.remPointsDo[p] = calVect.remPointsLe[p] = calVect.remPointsRi[p] = 0
|
|
1347
|
+
self.cal.setPuTrovaCC([0,0,0,0],p)
|
|
1348
|
+
calVect.dColPix[p] =calVect.dRigPix[p] = 10000 #not really important but has to be big
|
|
1349
|
+
|
|
1350
|
+
|
|
1351
|
+
if calType!=0: #no standard calibration planes involved
|
|
1352
|
+
calVect.costPlanes[p1]=costPlanes[p1]
|
|
1353
|
+
self.cal.allocAndinit(additionalPar,1)
|
|
1354
|
+
if calType >= 2:# Calibrazione piano per controllo Legge le costanti di calibrazione
|
|
1355
|
+
# si devono leggere o passare le costanti di calibrazione
|
|
1356
|
+
for cam in range(data.NCam):
|
|
1357
|
+
buffer=f'{data.percorso}{data.NomeFileOut}{abs(calVect.cam[cam])}.cal'
|
|
1358
|
+
self.readCalFile(buffer,calVect.cost[cam],data.NumCostCalib)
|
|
1359
|
+
self.cal.allocAndinit(additionalPar,2)
|
|
1360
|
+
return FlagCfgAutoGen
|
|
1361
|
+
|
|
1362
|
+
|
|
1363
|
+
|
|
1364
|
+
|
|
1365
|
+
def readCalFile(self,buffer:str,cost:list[float],numCostCalib:int,calType:int=None):
|
|
1366
|
+
''' reads the calibration constants from a file
|
|
1367
|
+
buffer is the name of the file
|
|
1368
|
+
if cost and numCostCalib are normally None in this case they are initialized internally
|
|
1369
|
+
if cost is different from none should be large enough to contain the constants
|
|
1370
|
+
if numCostCalib is different from none it is used regardless of the value in the file
|
|
1371
|
+
In output returns flagCal,N,cost
|
|
1372
|
+
'''
|
|
1373
|
+
try:
|
|
1374
|
+
with open(buffer,'r') as f:
|
|
1375
|
+
tag=readCfgTag(f)
|
|
1376
|
+
|
|
1377
|
+
if tag != "%SP00015":
|
|
1378
|
+
raise RuntimeError(f'Wrong tag in file: {buffer}')
|
|
1379
|
+
ind=1
|
|
1380
|
+
#ind,flagCal=readNumVecCfg(f,ind,int)
|
|
1381
|
+
ind,flagCal=readNumCfg(f,ind,int)
|
|
1382
|
+
ind,parNumber=readNumCfg(f,ind,int)
|
|
1383
|
+
N=parNumber if numCostCalib is None else numCostCalib
|
|
1384
|
+
|
|
1385
|
+
def fCalType(c):
|
|
1386
|
+
if c in (1,2,3): t=c
|
|
1387
|
+
elif c>=10 and c<15: t=10
|
|
1388
|
+
elif c>=30 and c<39: t=30
|
|
1389
|
+
return t
|
|
1390
|
+
|
|
1391
|
+
if calType:
|
|
1392
|
+
FlagCylFromPinhole=fCalType(flagCal)==10 and fCalType(calType)==30
|
|
1393
|
+
if fCalType(flagCal)!=fCalType(calType) and not FlagCylFromPinhole:
|
|
1394
|
+
CamMod_items=['polynomial', #0
|
|
1395
|
+
'rational', #1
|
|
1396
|
+
'tri-polynomial', #2
|
|
1397
|
+
'pinhole', #3
|
|
1398
|
+
'pinhole + cylinder', #4
|
|
1399
|
+
]
|
|
1400
|
+
CamMod_id=[1,2,3,10,30]
|
|
1401
|
+
file_CamMod=CamMod_items[CamMod_id.index(fCalType(flagCal))]
|
|
1402
|
+
excepted_CamMod=CamMod_items[CamMod_id.index(fCalType(calType))]
|
|
1403
|
+
raise RuntimeError(f'Wrong type of camera calibration model in file: {buffer}. Found {file_CamMod}, expected {excepted_CamMod} camera model.')
|
|
1404
|
+
else:
|
|
1405
|
+
FlagCylFromPinhole=False
|
|
1406
|
+
|
|
1407
|
+
if FlagCylFromPinhole:
|
|
1408
|
+
flagCal+=-10+30
|
|
1409
|
+
N=28
|
|
1410
|
+
if cost is None:
|
|
1411
|
+
cost=[0]*N
|
|
1412
|
+
if not FlagCylFromPinhole:
|
|
1413
|
+
for i in range(N):# dati->NumCostCalib; i++):
|
|
1414
|
+
ind,cost[i]=readNumCfg(f,ind,float)
|
|
1415
|
+
else:
|
|
1416
|
+
for i in range(17):# dati->NumCostCalib; i++):
|
|
1417
|
+
ind,cost[i]=readNumCfg(f,ind,float)
|
|
1418
|
+
ind,cost[26]=readNumCfg(f,ind,float)
|
|
1419
|
+
ind,cost[27]=readNumCfg(f,ind,float)
|
|
1420
|
+
|
|
1421
|
+
|
|
1422
|
+
#if "%SP00015"
|
|
1423
|
+
#for index, line in enumerate(f): pri.Info.white("Line {}: {}".format(index, line.strip()))
|
|
1424
|
+
#except Exception as exc:
|
|
1425
|
+
except IOError as exc:
|
|
1426
|
+
raise RuntimeError(f'Error opening the calibration constants file: {buffer}') from exc
|
|
1427
|
+
except ValueError as exc:
|
|
1428
|
+
raise RuntimeError(f'Error reading line:{ind+1} of file: {buffer}') from exc
|
|
1429
|
+
except IndexError as exc:
|
|
1430
|
+
raise RuntimeError(f'Error reading array in line:{ind+1} of file: {buffer}') from exc
|
|
1431
|
+
|
|
1432
|
+
|
|
1433
|
+
def toTipoCal(self,type ,F_Ph,F_Pl,F_Sa,P_Cyl,P_Ph):
|
|
1434
|
+
''' from parameters to tipoCal
|
|
1435
|
+
type is the type of calibration
|
|
1436
|
+
F_Ph, F_Pl, F_Sa are boolean to activate the relative function (PinHole, Plane, or save Line of sights)
|
|
1437
|
+
P_Cyl are additional parameters for cylindrical calibration
|
|
1438
|
+
P_Ph are additional parameters for PinHole not used
|
|
1439
|
+
|
|
1440
|
+
Vecchi tipi di calibrazione
|
|
1441
|
+
type | F_Ph | F_Pia | F_SA_LinVista
|
|
1442
|
+
0 Normale 0 | | |
|
|
1443
|
+
(-1) Calibrazione per piani 1 | x |Implicito|
|
|
1444
|
+
(-2) Calibrazione singolo(multi) piano 2 | |Implicito|
|
|
1445
|
+
(-3) Calibrazione Cyl No Pinhole Si Piani 3 | | x |
|
|
1446
|
+
(-4) Calibrazione Cyl Si Pinhole NO Piani 3 | x | |
|
|
1447
|
+
(-5) Calibrazione Cyl Si Pinhole Si Piani 3 | x | x |
|
|
1448
|
+
(-6) Calibrazione Cyl Si Pinhole No Piani 3 | x | |
|
|
1449
|
+
(-7) Calibrazione Cyl SI Pinhole Si Piani anche linee vista 3 | x | x | x
|
|
1450
|
+
(-8) Calibrazione Cyl SI Pinhole No Piani anche linee vista 3 | x | | x
|
|
1451
|
+
(-10) SelfCal 10
|
|
1452
|
+
In questo momento type è un numero (0:15)
|
|
1453
|
+
F_Ph, F_Pia e F_SA_LinVista sono booleani
|
|
1454
|
+
In aggiunta sono previsti due parametri aggiuntivi P_CYL (vedi IntiCostMin) e P_PH (per ora non utilizzato)
|
|
1455
|
+
Di seguito i dettagli
|
|
1456
|
+
|
|
1457
|
+
// long flagCal
|
|
1458
|
+
// Per ora usati solo i primi 2 byte in particolare ogni cifra esadecimale � usata per uno scopo
|
|
1459
|
+
// per inserire i dati supponendo che type sia il primo blocco, Cyl il secondo, PH il terzo e si voglia attivare solo il flag PIANI
|
|
1460
|
+
// int flagCal =type + (Cyl << CalFlags.SHIFT_CYL) + (PH<<CalFlags.SHIFT_PH)+CalFlags.FLAG_PIANI;
|
|
1461
|
+
|
|
1462
|
+
int type = 3, PH = 4, Cyl = 10;
|
|
1463
|
+
int tipoCal = type + (P_Cyl << CalFlags.SHIFT_CYL)+(P_Ph << CalFlags.SHIFT_PH) + (F_Ph *CalFlags.Flag_PINHOLE)
|
|
1464
|
+
+ (F_Pl*CalFlags.Flag_PIANI)+F_Sa*CalFlags.Flag_LIN_VI
|
|
1465
|
+
cal = (tipoCal >> CalFlags.SHIFT) & CalFlags.MASK
|
|
1466
|
+
P_Cyl = (tipoCal >> CalFlags.SHIFT_CYL) & CalFlags.MASK
|
|
1467
|
+
P_Ph = (tipoCal >> CalFlags.SHIFT_PH) & CalFlags.MASK
|
|
1468
|
+
F_Ph = tipoCal & CalFlags.Flag_PINHOLE
|
|
1469
|
+
F_Pl = tipoCal & CalFlags.Flag_PIANI
|
|
1470
|
+
F_Sa = tipoCal & CalFlags.Flag_LIN_VI
|
|
1471
|
+
|
|
1472
|
+
'''
|
|
1473
|
+
return type + (P_Cyl << CalFlags.SHIFT_CYL)+(P_Ph << CalFlags.SHIFT_PH) + (F_Ph *CalFlags.Flag_PINHOLE)+ (F_Pl*CalFlags.Flag_PIANI)+F_Sa*CalFlags.Flag_LIN_VI
|
|
1474
|
+
def fromTipoCal(self,tipoCal):
|
|
1475
|
+
''' from parameters to tipoCal
|
|
1476
|
+
call with
|
|
1477
|
+
type,F_Ph,F_Pl,F_Sa,P_Cyl,P_Ph=self.fromTipoCal(tipoCal)
|
|
1478
|
+
type is the type of calibration
|
|
1479
|
+
F_Ph, F_Pl, F_Sa are bolean to activate the relative function (PinHole, Plane, or save Line of sights)
|
|
1480
|
+
P_Cyl are additional parameters for cylindrical calibration
|
|
1481
|
+
P_Ph are additional parameters for PinHole not used'''
|
|
1482
|
+
type = (tipoCal >> CalFlags.SHIFT) & CalFlags.MASK
|
|
1483
|
+
P_Cyl = (tipoCal >> CalFlags.SHIFT_CYL) & CalFlags.MASK
|
|
1484
|
+
P_Ph = (tipoCal >> CalFlags.SHIFT_PH) & CalFlags.MASK
|
|
1485
|
+
F_Ph = tipoCal & CalFlags.Flag_PINHOLE
|
|
1486
|
+
F_Pl = tipoCal & CalFlags.Flag_PIANI
|
|
1487
|
+
F_Sa = tipoCal & CalFlags.Flag_LIN_VI
|
|
1488
|
+
return type,F_Ph,F_Pl,F_Sa,P_Cyl,P_Ph
|