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
|
@@ -0,0 +1,593 @@
|
|
|
1
|
+
'''
|
|
2
|
+
parForWorker worker used for parfor
|
|
3
|
+
'''
|
|
4
|
+
|
|
5
|
+
from typing import Callable
|
|
6
|
+
from .PaIRS_pypacks import *
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
# To me, pylint is correct in flagging this error here the top level module is database (it contains an __init__.py file)
|
|
10
|
+
# Your import should look like (fully absolute)
|
|
11
|
+
# https://stackoverflow.com/a/51236340
|
|
12
|
+
#from PIV_ParFor import callBack, FlagStopWorkers
|
|
13
|
+
|
|
14
|
+
from .preProcParFor import *
|
|
15
|
+
from .pivParFor import *
|
|
16
|
+
from .stereoPivParFor import *
|
|
17
|
+
|
|
18
|
+
prTime = PrintTA(PrintTA.yellow, PrintTA.faceStd, PrintTAPriority.medium).prTime
|
|
19
|
+
|
|
20
|
+
class WorkerSignals(QObject):
|
|
21
|
+
progress = Signal(int,int,int,list,str)
|
|
22
|
+
result = Signal(int,int,list,str)
|
|
23
|
+
finished = Signal(object,str)
|
|
24
|
+
initialized = Signal()
|
|
25
|
+
completed = Signal()
|
|
26
|
+
kill = Signal(int)
|
|
27
|
+
|
|
28
|
+
class ParForWorker(QRunnable):
|
|
29
|
+
def __init__(self,data:dataTreePar,indWorker:int,indProc:int,numMaxProcs:int,pfPool:ParForPool,parForMul:ParForMul,nameWorker:str,mainFun:Callable):
|
|
30
|
+
#super(MIN_ParFor_Worker,self).__init__(data,indWorker,indProc,pfPool=ParForPool,parForMul=ParForMul)
|
|
31
|
+
super().__init__()
|
|
32
|
+
self.pfPool=pfPool
|
|
33
|
+
self.parForMul=parForMul
|
|
34
|
+
self.nameWorker=nameWorker # diverso per le due classi
|
|
35
|
+
self.data=data.duplicate() #OPTIMIZE TA GP controllare se le modifiche fatte nel workers interferiscono con quelle fatte in progress_proc ed eventualmente evitare l'aggiornamento in resetProc e in store_proc
|
|
36
|
+
self.indWorker = indWorker
|
|
37
|
+
self.indProc = indProc
|
|
38
|
+
self.numMaxProcs=numMaxProcs
|
|
39
|
+
self.signals=WorkerSignals()
|
|
40
|
+
self.isKilled = False
|
|
41
|
+
self.isStoreCompleted = False
|
|
42
|
+
self.numCallBackTotOk=0
|
|
43
|
+
|
|
44
|
+
self.mainFun=mainFun
|
|
45
|
+
|
|
46
|
+
@Slot()
|
|
47
|
+
def run(self):
|
|
48
|
+
if Flag_DEBUG_PARPOOL: debugpy.debug_this_thread()
|
|
49
|
+
try:
|
|
50
|
+
#pr(f'ParForWorker.run self.isKilled={self.isKilled} self.indWorker={self.indWorker} self.indProc={self.indProc} ')
|
|
51
|
+
self.parForMul.numUsedCores=self.numMaxProcs
|
|
52
|
+
while self.indWorker!=self.indProc:# and not self.isKilled:
|
|
53
|
+
timesleep(SleepTime_Workers)
|
|
54
|
+
if self.isKilled:
|
|
55
|
+
self.signals.completed.emit()
|
|
56
|
+
return # in this case we are killing all the threads
|
|
57
|
+
pri.Process.blue(f'ParForWorker.run starting {self.nameWorker} self.isKilled={self.isKilled} self.indWorker={self.indWorker} self.indProc={self.indProc} ')
|
|
58
|
+
self.mainFun()
|
|
59
|
+
except:
|
|
60
|
+
Message=printException('ParForWorker',flagMessage=True)
|
|
61
|
+
self.signals.finished.emit(self.data,Message)
|
|
62
|
+
#finally:#also after return eliminated
|
|
63
|
+
while not self.isStoreCompleted:
|
|
64
|
+
timesleep(SleepTime_Workers)
|
|
65
|
+
self.signals.completed.emit()
|
|
66
|
+
pri.Process.blue(f'End of ParForWorker {self.nameWorker} ({self.indWorker}, {self.numCallBackTotOk} )')
|
|
67
|
+
|
|
68
|
+
@Slot()
|
|
69
|
+
def killOrReset(self,isKilled):
|
|
70
|
+
#pr('\n***********************\n************************* ParForWorker.die {isKilled}')
|
|
71
|
+
global FlagStopWorkers
|
|
72
|
+
self.isKilled=isKilled
|
|
73
|
+
FlagStopWorkers[0]=1 if isKilled else 0
|
|
74
|
+
|
|
75
|
+
@Slot(int)
|
|
76
|
+
def updateIndProc(self,indProc):
|
|
77
|
+
#pr(f'updateIndProc {self.nameWorker} ({self.indWorker})')
|
|
78
|
+
self.indProc=indProc
|
|
79
|
+
|
|
80
|
+
@Slot(int)
|
|
81
|
+
def setNumCallBackTot(self,numCallBackTotOk):
|
|
82
|
+
#if (self.numCallBackTotnumCallBackTotOk>numCallBackTotOk): prLock(f'setNumCallBackTot numCallBackTotOk={numCallBackTotOk}')
|
|
83
|
+
self.numCallBackTotOk=numCallBackTotOk
|
|
84
|
+
|
|
85
|
+
@Slot()
|
|
86
|
+
def storeCompleted(self):
|
|
87
|
+
self.isStoreCompleted=True
|
|
88
|
+
|
|
89
|
+
class MIN_ParFor_Worker(ParForWorker):
|
|
90
|
+
def __init__(self,data:dataTreePar,indWorker:int,indProc:int,numMaxProcs:int,pfPool:ParForPool,parForMul:ParForMul):
|
|
91
|
+
super().__init__(data,indWorker,indProc,numMaxProcs,pfPool,parForMul,nameWorker='calcMin_Worker',mainFun=self.calcmin)
|
|
92
|
+
|
|
93
|
+
def calcmin(self):
|
|
94
|
+
stringaErr=''
|
|
95
|
+
global FlagStopWorkers
|
|
96
|
+
pri.Time.blue(0,'calcmin')
|
|
97
|
+
FlagStopWorkers[0]=0
|
|
98
|
+
|
|
99
|
+
#pp=ParForMul()
|
|
100
|
+
#pp.sleepTime=ParFor_sleepTime #time between calls of callBack
|
|
101
|
+
#pp.numCoresParPool=numMaxProcs
|
|
102
|
+
|
|
103
|
+
self.data.compMin.restoreMin()
|
|
104
|
+
args=(self.data,self.numMaxProcs)
|
|
105
|
+
kwargs={}
|
|
106
|
+
numCallBackTotOk=self.data.numFinalized #su quelli non finalized ci ripassiamo quindi inizialmente il num di callback ok = num di finalized
|
|
107
|
+
|
|
108
|
+
nImg=range(self.data.nimg)
|
|
109
|
+
#nImg=range(2*self.data.nimg)
|
|
110
|
+
|
|
111
|
+
myCallBack=lambda a,b,c,d,e,f: callBackMin(a,b,c,d,e,f,self.signals.progress)
|
|
112
|
+
#for ii,f in enumerate(self.data.list_pim): pr(f'{ii}-{hex(f)} ',end='')
|
|
113
|
+
pri.Process.blue(f'Init calcmin Contab={self.data.compMin.contab} numCallBackTotOk={numCallBackTotOk} numMaxProcs={self.numMaxProcs}')
|
|
114
|
+
self.signals.initialized.emit()
|
|
115
|
+
|
|
116
|
+
self.parForMul.numUsedCores=self.numMaxProcs
|
|
117
|
+
#TBD TA all the exceptions should be managed inside parForExtPool therefore the try should be useless just in case I check
|
|
118
|
+
try:
|
|
119
|
+
|
|
120
|
+
if self.pfPool:
|
|
121
|
+
(mi,flagOut,VarOut,flagError)=self.parForMul.parForExtPool(self.pfPool.parPool,procMIN,nImg,initTask=initMIN,finalTask=finalMIN, wrapUp=saveAndMin, callBack=myCallBack,*args,**kwargs)
|
|
122
|
+
else:
|
|
123
|
+
(mi,flagOut,VarOut,flagError)=self.parForMul.simpleFor(procMIN,nImg,initTask=initMIN,finalTask=finalMIN, wrapUp=saveAndMin, callBack=myCallBack,*args,**kwargs)
|
|
124
|
+
except Exception as e:
|
|
125
|
+
PrintTA().printEvidenced('Calcmin exception raised.\nThis should never happen.')
|
|
126
|
+
raise (e)
|
|
127
|
+
|
|
128
|
+
if flagError:
|
|
129
|
+
self.signals.finished.emit(self.data,printException('calcmin',flagMessage=True,exception=self.parForMul.exception))
|
|
130
|
+
return
|
|
131
|
+
|
|
132
|
+
pri.Time.blue(0,'dopo parForExtPool ****************************************')
|
|
133
|
+
'''
|
|
134
|
+
def callBackSaveMin(f3):
|
|
135
|
+
pri.Time.blue(0,'callBackSaveMin')
|
|
136
|
+
#(pfPool,parForMul)=f3.result()
|
|
137
|
+
async def callSaveMin(data:dataTreePar,Imin=list):
|
|
138
|
+
#t1=asyncio.create_task(saveMin(self.data,mi.Imin))
|
|
139
|
+
#await t1
|
|
140
|
+
saveMin(self.data,mi.Imin) #nel caso controllare errore come sotto
|
|
141
|
+
'''
|
|
142
|
+
executor = concurrent.futures.ThreadPoolExecutor(max_workers=2)
|
|
143
|
+
if mi.contab[0]!=0:
|
|
144
|
+
mi.calcMed()
|
|
145
|
+
#OPTIMIZE TAGP sul mio pc (TA) saveMin è lenta (5 secondi) forse si può organizzare con una funzione async tanto non ci interessa quando finisce
|
|
146
|
+
#f3=executor.submit(asyncio.run,callSaveMin(self.data,mi.Imin))
|
|
147
|
+
#f3.add_done_callback(callBackSaveMin)
|
|
148
|
+
try:
|
|
149
|
+
saveMin(self.data,mi.Imin)
|
|
150
|
+
except:
|
|
151
|
+
stringaErr+=printException('calcmin',flagMessage=True)+'\n'
|
|
152
|
+
pri.Time.blue(0,'dopo saveMin ****************************************')
|
|
153
|
+
#for ii,f in enumerate(flagOut): pr(f'{ii}-{hex(f)} ',end='')
|
|
154
|
+
numCallBackTotOk+=sum(1 if x&FLAG_CALLBACK_INTERNAL else 0 for x in flagOut)
|
|
155
|
+
|
|
156
|
+
#initTime=time()
|
|
157
|
+
self.data.flagParForCompleted=True
|
|
158
|
+
while self.numCallBackTotOk!=numCallBackTotOk:
|
|
159
|
+
pri.Process.blue (f'Error Calcmin self.numCallBackTotOk={self.numCallBackTotOk} numCallBackTotOk={numCallBackTotOk} ')
|
|
160
|
+
timesleep(SleepTime_Workers)
|
|
161
|
+
|
|
162
|
+
#numProcOrErrTot=sum(1 if (f&FLAG_FINALIZED_OR_ERR[0])and (f&FLAG_FINALIZED_OR_ERR[1]) else 0 for f in flagOut)
|
|
163
|
+
numProcOrErrTot=sum(1 if f else 0 for f in flagOut)
|
|
164
|
+
pri.Process.blue (f'Fine calcmin ************** numCallBackTotOk={numCallBackTotOk} numProcOrErrTot={numProcOrErrTot} numFinalized={self.data.numFinalized}')
|
|
165
|
+
pri.Time.blue(0,'fine calcmin ****************************************')
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
if mi.contab[0]!=0:
|
|
169
|
+
pri.Time.blue(0,f'Min value coord(20,20) Min=[{mi.Imin[0][20][20]},{mi.Imin[1][20][20]}] med=[{mi.med[0][20][20]},{mi.med[1][20][20]}]')
|
|
170
|
+
pri.Time.blue(0,f'Min value coord(52,52) Min=[{mi.Imin[0][52][52]} {mi.Imin[1][52][52]}] med=[{mi.med[0][52][52]} {mi.med[1][52][52]}]')
|
|
171
|
+
# In pause_MINproc oltre a salvare il minimo si verifica se tutte le img programmate sono state processate anche con esito negativo, nel caso si passa al task successivo
|
|
172
|
+
|
|
173
|
+
self.data.compMin=mi
|
|
174
|
+
self.data.FlagFinished=self.data.nimg==numProcOrErrTot
|
|
175
|
+
self.signals.finished.emit(self.data,stringaErr)
|
|
176
|
+
|
|
177
|
+
class PIV_ParFor_Worker(ParForWorker):
|
|
178
|
+
def __init__(self,data:dataTreePar,indWorker:int,indProc:int,numMaxProcs:int,pfPool:ParForPool,parForMul:ParForMul):
|
|
179
|
+
super().__init__(data,indWorker,indProc,numMaxProcs,pfPool,parForMul,nameWorker='PIV_Worker',mainFun=self.runPIVParFor)
|
|
180
|
+
|
|
181
|
+
def runPIVParFor(self):#unified function for piv and Stereo
|
|
182
|
+
stringaErr=''
|
|
183
|
+
global FlagStopWorkers
|
|
184
|
+
|
|
185
|
+
outString='runPIVParFor' if self.data.Step==StepTypes.piv else 'runStereoPIVParFor'
|
|
186
|
+
pri.Time.cyan(3,outString)
|
|
187
|
+
FlagStopWorkers[0]=0
|
|
188
|
+
# TODEL
|
|
189
|
+
|
|
190
|
+
flagDebugMem=False
|
|
191
|
+
if flagDebugMem:# TODEL?
|
|
192
|
+
m1=memoryUsagePsutil()
|
|
193
|
+
filename_preproc=self.data.filename_proc[StepTypes.min]
|
|
194
|
+
|
|
195
|
+
self.data.mediaPIV.restoreSum()
|
|
196
|
+
|
|
197
|
+
#args=(self.data,)
|
|
198
|
+
'''
|
|
199
|
+
if self.pfPool:#normal condition
|
|
200
|
+
#todo GP we should print the number of piv cores and processes in the log
|
|
201
|
+
numPivOmpCores,numUsedProcs=optimalPivCores(self.numMaxProcs,self.data.nimg,penCore=0.95)
|
|
202
|
+
self.data.numUsedProcs=numUsedProcs # self.data.numUsedProcs is used for output should be the number of parfor threads used
|
|
203
|
+
self.data.numPivOmpCores=numPivOmpCores
|
|
204
|
+
else:# serial par for used only for debugging the c library
|
|
205
|
+
self.data.numUsedProcs=numUsedProcs=1 # self.data.numUsedProcs is used for output should be the number of parfor threads used
|
|
206
|
+
self.data.numPivOmpCores=numPivOmpCores=self.numMaxProcs
|
|
207
|
+
self.data.numUsedProcs=numUsedProcs=1 # self.data.numUsedProcs is used for output should be the number of parfor threads used
|
|
208
|
+
self.data.numPivOmpCores=numPivOmpCores=2#self.numMaxProcs '''
|
|
209
|
+
numPivOmpCores=self.data.numPivOmpCores
|
|
210
|
+
numUsedProcs=self.data.numUsedProcs
|
|
211
|
+
args=(self.data,numUsedProcs)
|
|
212
|
+
#kwargs={'finalPIVPIppo': self.data.nimg}#unused just for example
|
|
213
|
+
kwargs={}
|
|
214
|
+
numCallBackTotOk=self.data.numFinalized #su quelli non finalized ci ripassiamo quindi inizialmente il num di callback ok = num di finalized
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
nImg=range(self.data.nimg)
|
|
218
|
+
myCallBack=lambda a,b,c,d,e,f: callBackPIV(a,b,c,d,e,f,self.signals.progress)
|
|
219
|
+
pri.Process.blue(f'{outString} mediaPIV cont={self.data.mediaPIV.cont} self.numCallBackTotOk={self.numCallBackTotOk} self.data.nimg={self.data.nimg} numProc={numUsedProcs} numPivProc={numPivOmpCores}')
|
|
220
|
+
|
|
221
|
+
self.signals.initialized.emit()
|
|
222
|
+
#TBD TA all the exceptions should be managed inside parForExtPool therefore the try should be useless just in case I check
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
if self.pfPool:
|
|
226
|
+
self.parForMul.numUsedCores=numUsedProcs
|
|
227
|
+
parPool=self.pfPool.parPool
|
|
228
|
+
parForFun= self.parForMul.parForExtPool
|
|
229
|
+
else:
|
|
230
|
+
parPool=None
|
|
231
|
+
parForFun= self.parForMul.simpleFor
|
|
232
|
+
try:
|
|
233
|
+
if self.data.Step==StepTypes.piv:
|
|
234
|
+
(me,flagOut,VarOut,flagError)=parForFun(parPool,procPIV,nImg,initTask=initPIV,finalTask=finalPIV, wrapUp=saveAndMean, callBack=myCallBack,*args,**kwargs)
|
|
235
|
+
elif self.data.Step==StepTypes.spiv:
|
|
236
|
+
(me,flagOut,VarOut,flagError)=parForFun(parPool,procStereoPIV,nImg,initTask=initStereoPIV,finalTask=finalStereoPIV, wrapUp=saveAndMean, callBack=myCallBack,*args,**kwargs)
|
|
237
|
+
|
|
238
|
+
except Exception as e:
|
|
239
|
+
PrintTA().printEvidenced(f'{outString} exception raised\nThis should never happen ')
|
|
240
|
+
raise (e)
|
|
241
|
+
|
|
242
|
+
if flagError:
|
|
243
|
+
self.signals.finished.emit(self.data,printException(outString,flagMessage=True,exception=self.parForMul.exception))
|
|
244
|
+
return
|
|
245
|
+
|
|
246
|
+
try:
|
|
247
|
+
if me.cont:
|
|
248
|
+
me:MediaPIV
|
|
249
|
+
me.calcMedia()
|
|
250
|
+
nameFields=me.namesPIV.avgVelFields
|
|
251
|
+
Var=[getattr(me,f) for f in nameFields ]#me.x,me.y,me.u,me.v,me.up,me.vp,me.uvp,me.sn,me.Info]
|
|
252
|
+
nameVar=me.namesPIV.avgVel
|
|
253
|
+
saveResults(self.data,-1,Var,nameVar)
|
|
254
|
+
except:
|
|
255
|
+
stringaErr+=printException(outString,flagMessage=True,exception=self.parForMul.exception)+'\n'
|
|
256
|
+
numCallBackTotOk+=sum(1 if x&FLAG_CALLBACK_INTERNAL else 0 for x in flagOut)
|
|
257
|
+
|
|
258
|
+
# Tbd
|
|
259
|
+
'''
|
|
260
|
+
if flagDebugMem:
|
|
261
|
+
pri.Time.cyan(0,'Save results')
|
|
262
|
+
pr(f"Number of garbage element not collected before {gc.get_count()}",end='')
|
|
263
|
+
gc.collect()
|
|
264
|
+
pr(f" after {gc.get_count()}")
|
|
265
|
+
pr(f"********************** End Fun Main -> {(memoryUsagePsutil()-m1)/ float(2 ** 20)}MByte")
|
|
266
|
+
pr(*gc.garbage)
|
|
267
|
+
'''
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
#initTime=time()
|
|
272
|
+
self.data.flagParForCompleted=True
|
|
273
|
+
while self.numCallBackTotOk!=numCallBackTotOk :
|
|
274
|
+
pri.Process.blue (f'Error {outString} self.numCallBackTotOk={self.numCallBackTotOk} numCallBackTotOk={numCallBackTotOk} numUsedProcs={numUsedProcs} numPivOmpCores={numPivOmpCores}')
|
|
275
|
+
timesleep(SleepTime_Workers)
|
|
276
|
+
|
|
277
|
+
#if me.cont:
|
|
278
|
+
# pri.Time.cyan(f'u={me.u[5][4]} v={me.v[5][4]} up={me.up[5][4]} vp={me.vp[5][4]} uvp={me.uvp[5][4]} sn={me.sn[5][4]} Info={me.Info[5][4]}')
|
|
279
|
+
|
|
280
|
+
#self.numFinalized=sum(1 if f&FLAG_FINALIZED[0] else 0 for f in flagOut)
|
|
281
|
+
numProcOrErrTot=sum(1 if f else 0 for f in flagOut)
|
|
282
|
+
|
|
283
|
+
#for ii,f in enumerate(flagOut): pr(f'{ii}-{hex(f)} ',end='')
|
|
284
|
+
pri.Process.blue (f'Fine {outString} ************** numCallBackTotOk={numCallBackTotOk} numProcOrErrTot={numProcOrErrTot} numFinalized={self.data.numFinalized}')
|
|
285
|
+
|
|
286
|
+
self.data.mediaPIV=me
|
|
287
|
+
self.data.FlagFinished=self.data.nimg==numProcOrErrTot
|
|
288
|
+
self.signals.finished.emit(self.data,stringaErr)
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
class StereoDisparity_ParFor_Worker(ParForWorker):
|
|
292
|
+
def __init__(self,data:dataTreePar,indWorker:int,indProc:int,numMaxProcs:int,pfPool:ParForPool,parForMul:ParForMul):
|
|
293
|
+
super().__init__(data,indWorker,indProc,numMaxProcs,pfPool,parForMul,nameWorker='Disp_Worker',mainFun=self.runDisparity)
|
|
294
|
+
|
|
295
|
+
def runDisparity(self):
|
|
296
|
+
''' main proc function called for all the images one time per processor
|
|
297
|
+
k=0 always
|
|
298
|
+
In output flagOut and varOut[0] can be:
|
|
299
|
+
Already processed: varOut[0]=-1 flagOut=FLAG_PROC[k]|FLAG_READ[k]|FLAG_FINALIZED[k]
|
|
300
|
+
Error reading: varOut[0]=i flagOut=FLAG_READ_ERR[k]
|
|
301
|
+
Error processing: varOut[0]=i flagOut=FLAG_READ[k]
|
|
302
|
+
Process stoped by user: varOut[0]=-1 flagOut=FLAG_READ[k]
|
|
303
|
+
Error saving: varOut[0]=i flagOut=FLAG_PROC[k]|FLAG_READ[k]
|
|
304
|
+
Read and processed: varOut[0]=i flagOut=FLAG_PROC[k]|FLAG_READ[k]|FLAG_FINALIZED[k]|FLAG_CALLBACK_INTERNAL
|
|
305
|
+
'''
|
|
306
|
+
self.signals.initialized.emit()
|
|
307
|
+
data=self.data
|
|
308
|
+
|
|
309
|
+
it=0
|
|
310
|
+
Var=[]
|
|
311
|
+
procID=-1
|
|
312
|
+
|
|
313
|
+
flagOut=flagOutIter=0
|
|
314
|
+
kConst=0
|
|
315
|
+
self.disp=data2Disp(data)
|
|
316
|
+
spivIn=self.disp.SPIVIn
|
|
317
|
+
dP=self.disp.dataProc
|
|
318
|
+
dAC=self.disp.dispAvCo
|
|
319
|
+
ve=self.disp.vect
|
|
320
|
+
ve.PianoLaser[0]=np.float32(data.OUT_dict['zconst'])
|
|
321
|
+
ve.PianoLaser[1]=np.float32(data.OUT_dict['xterm'])
|
|
322
|
+
ve.PianoLaser[2]=np.float32(data.OUT_dict['yterm'])
|
|
323
|
+
|
|
324
|
+
stringaErr=''
|
|
325
|
+
if self.isKilled: return self.stopDisparity(it,flagOut,flagOutIter)
|
|
326
|
+
try:
|
|
327
|
+
#1/0 #***************** delete
|
|
328
|
+
self.disp.evalCommonZone()
|
|
329
|
+
except Exception as inst: #ValueError as exc:
|
|
330
|
+
FlagInitError=True
|
|
331
|
+
stringaErr=f'\n!!!!!!!!!! Error while evaluating common region:\n{inst}\n'
|
|
332
|
+
pri.Error.red(stringaErr)
|
|
333
|
+
flagOut|=FLAG_READ_ERR[kConst]
|
|
334
|
+
else:
|
|
335
|
+
FlagInitError=False
|
|
336
|
+
|
|
337
|
+
"""
|
|
338
|
+
if self.isKilled: return self.stopDisparity(it,flagOut,flagOutIter)
|
|
339
|
+
if not FlagInitError:
|
|
340
|
+
self.imgs=[]
|
|
341
|
+
ind=np.ix_(np.arange(spivIn.RigaPart,spivIn.RigaPart+dP.ImgH),np.arange(spivIn.ColPart,spivIn.ColPart+dP.ImgW))
|
|
342
|
+
#data.list_Image_Files[c][f][k]
|
|
343
|
+
imList=data.list_Image_Files
|
|
344
|
+
for p in range(len(imList[0][0])):
|
|
345
|
+
if self.isKilled: return self.stopDisparity(it,flagOut,flagOutIter)
|
|
346
|
+
ic=[]
|
|
347
|
+
#print(f'reading {p}')
|
|
348
|
+
try:
|
|
349
|
+
for cam in range(len(imList[0])):
|
|
350
|
+
da=db=None
|
|
351
|
+
if spivIn.FlagImgTau in (0,1):
|
|
352
|
+
if self.isKilled: return self.stopDisparity(it,flagOut,flagOutIter)
|
|
353
|
+
nomeImg=data.inpPath+imList[cam][0][p]
|
|
354
|
+
da=np.ascontiguousarray(np.array(Image.open(nomeImg),dtype=float)[ind],dtype= np.uint16)
|
|
355
|
+
if spivIn.FlagImgTau in (0,2):
|
|
356
|
+
if self.isKilled: return self.stopDisparity(it,flagOut,flagOutIter)
|
|
357
|
+
nomeImg=data.inpPath+imList[cam][1][p]
|
|
358
|
+
db=np.ascontiguousarray(np.array(Image.open(nomeImg),dtype=float)[ind],dtype= np.uint16)
|
|
359
|
+
|
|
360
|
+
ic.append([da,db])
|
|
361
|
+
except Exception as inst: #ValueError as exc:
|
|
362
|
+
FlagInitError=True
|
|
363
|
+
stringaErr=f"\n!!!!!!!!!! Error while reading the image {nomeImg}:\n{inst}\n"
|
|
364
|
+
pri.Error.red(stringaErr)
|
|
365
|
+
flagOut|=FLAG_READ_ERR[kConst]
|
|
366
|
+
break
|
|
367
|
+
else:
|
|
368
|
+
self.imgs.append(ic)
|
|
369
|
+
#self.imgs.append(np.ascontiguousarray(da[spivIn.RigaPart:spivIn.RigaPart+dP.ImgH,spivIn.ColPart:spivIn.ColPart+dP.ImgW],dtype= np.uint16))
|
|
370
|
+
"""
|
|
371
|
+
|
|
372
|
+
imList=data.list_Image_Files
|
|
373
|
+
indim=np.ix_(np.arange(spivIn.RigaPart,spivIn.RigaPart+dP.ImgH),np.arange(spivIn.ColPart,spivIn.ColPart+dP.ImgW))
|
|
374
|
+
if data.FlagMIN:
|
|
375
|
+
data.compMin.Imin=[[np.zeros(1) for _ in range(data.nframe)] for _ in range(data.ncam)]
|
|
376
|
+
for c,Iminc in enumerate(data.Imin):
|
|
377
|
+
for k,filename in enumerate(Iminc):
|
|
378
|
+
try:
|
|
379
|
+
data.compMin.Imin[c][k]=np.ascontiguousarray(np.array(Image.open(filename),dtype=float)[indim],dtype= np.uint16)
|
|
380
|
+
except Exception as inst:
|
|
381
|
+
FlagInitError=True
|
|
382
|
+
stringaErr=f'\n!!!!!!!!!! Error while reading background image {filename}:\n{inst}\n'
|
|
383
|
+
pri.Error.red(stringaErr)
|
|
384
|
+
flagOut|=FLAG_READ_ERR[kConst]
|
|
385
|
+
break
|
|
386
|
+
|
|
387
|
+
if not FlagInitError:
|
|
388
|
+
if self.isKilled: return self.stopDisparity(it,flagOut,flagOutIter)
|
|
389
|
+
try:
|
|
390
|
+
self.disp.initAllocDisp()
|
|
391
|
+
self.disp.dispAvCo.NImg=2*len(imList[0][0]) if spivIn.FlagImgTau==0 else len(imList[0][0])
|
|
392
|
+
except Exception as inst: #ValueError as exc:
|
|
393
|
+
FlagInitError=True
|
|
394
|
+
stringaErr=f'\n!!!!!!!!!! Error during disparity process initialization:\n{inst}\n'
|
|
395
|
+
pri.Error.red(stringaErr)
|
|
396
|
+
flagOut|=FLAG_READ_ERR[kConst]
|
|
397
|
+
|
|
398
|
+
#print(f'Esempio risoluzione utilizzata {self.disp.dataProc.RisxRadd} {1/self.disp.dataProc.RisxRadd}')
|
|
399
|
+
#sleepTimeWorkers=0.2 #for multithreading and other stuff
|
|
400
|
+
#if FlagInitError: flagOut|=FLAG_FINALIZED[kConst]|FLAG_CALLBACK_INTERNAL
|
|
401
|
+
flagOutIter=FLAG_READ[kConst]
|
|
402
|
+
for it in range(spivIn.Niter):
|
|
403
|
+
if FlagInitError:
|
|
404
|
+
if data.list_pim[it]&FLAG_READ_ERR[kConst]: ind=-1# no log already written
|
|
405
|
+
if it==0: stampa=stringaErr
|
|
406
|
+
else: stampa=''
|
|
407
|
+
data.list_print[it]=stampa
|
|
408
|
+
data.list_pim[it]=flagOut
|
|
409
|
+
self.signals.progress.emit(procID,-1,flagOut,Var,stringaErr)
|
|
410
|
+
continue
|
|
411
|
+
if data.list_pim[it]&FLAG_FINALIZED[kConst]:
|
|
412
|
+
flagOut=FLAG_READ[kConst]|FLAG_PROC[kConst]|FLAG_FINALIZED[kConst] # It has been already processed. Exit without calling the callback core
|
|
413
|
+
stampa=''
|
|
414
|
+
ind=-1
|
|
415
|
+
self.signals.progress.emit(procID,ind,flagOut,Var,stampa)
|
|
416
|
+
continue
|
|
417
|
+
flagOut=flagOutIter
|
|
418
|
+
Var=[]
|
|
419
|
+
stampa=f"Iteration {it+1}\n"
|
|
420
|
+
ind=it
|
|
421
|
+
if self.isKilled: return self.stopDisparity(it,flagOut,flagOutIter)
|
|
422
|
+
try:
|
|
423
|
+
errorType='evaluating viewing angles'
|
|
424
|
+
self.disp.evaldXdY()
|
|
425
|
+
if self.isKilled: return self.stopDisparity(it,flagOut,flagOutIter)
|
|
426
|
+
for p in range(len(imList[0][0])):
|
|
427
|
+
if self.isKilled: return self.stopDisparity(it,flagOut,flagOutIter)
|
|
428
|
+
ic=[]
|
|
429
|
+
#print(f'reading {p}')
|
|
430
|
+
for cam in range(len(imList[0])):
|
|
431
|
+
da=db=None
|
|
432
|
+
if spivIn.FlagImgTau in (0,1):
|
|
433
|
+
if self.isKilled: return self.stopDisparity(it,flagOut,flagOutIter)
|
|
434
|
+
nomeImg=data.inpPath+imList[cam][0][p]
|
|
435
|
+
errorType=f'reading the image {nomeImg}'
|
|
436
|
+
da=np.ascontiguousarray(np.array(Image.open(nomeImg),dtype=float)[indim],dtype= np.uint16)
|
|
437
|
+
if data.FlagMIN:
|
|
438
|
+
if data.FlagTR and p%2:
|
|
439
|
+
da=da-data.compMin.Imin[cam][1]
|
|
440
|
+
else:
|
|
441
|
+
da=da-data.compMin.Imin[cam][0]
|
|
442
|
+
da=np.ascontiguousarray(da,dtype= np.uint16)
|
|
443
|
+
if spivIn.FlagImgTau in (0,2):
|
|
444
|
+
if self.isKilled: return self.stopDisparity(it,flagOut,flagOutIter)
|
|
445
|
+
nomeImg=data.inpPath+imList[cam][1][p]
|
|
446
|
+
errorType=f'reading the image {nomeImg}'
|
|
447
|
+
db=np.ascontiguousarray(np.array(Image.open(nomeImg),dtype=float)[indim],dtype= np.uint16)
|
|
448
|
+
if data.FlagMIN:
|
|
449
|
+
if data.FlagTR and p%2:
|
|
450
|
+
db=db-data.compMin.Imin[cam][0]
|
|
451
|
+
else:
|
|
452
|
+
db=db-data.compMin.Imin[cam][1]
|
|
453
|
+
db=np.ascontiguousarray(db,dtype= np.uint16)
|
|
454
|
+
|
|
455
|
+
ic.append([da,db])
|
|
456
|
+
|
|
457
|
+
errorType=f'dewarping and computing disparity ({imList[0][0][p]},...,{imList[1][1][p]})'
|
|
458
|
+
self.disp.deWarpAndCalcCC(ic)
|
|
459
|
+
#while self.disp.flagWorking==2:# and not self.isKilled: sleep (sleepTimeWorkers)
|
|
460
|
+
if self.isKilled: return self.stopDisparity(it,flagOut,flagOutIter)
|
|
461
|
+
|
|
462
|
+
errorType=f'computing the laser plane constants'
|
|
463
|
+
self.disp.calcDisparity()
|
|
464
|
+
if self.isKilled: return self.stopDisparity(it,flagOut,flagOutIter)
|
|
465
|
+
#while self.disp.flagWorking==2:# and not self.isKilled: sleep (sleepTimeWorkers)
|
|
466
|
+
except Exception as inst:
|
|
467
|
+
if (data.list_pim[it]&FLAG_READ[kConst]): ind=-1# no log already written
|
|
468
|
+
#dum=str(inst.__cause__).split('\n')[3] #solved
|
|
469
|
+
dum=str(inst.args[0])
|
|
470
|
+
#varOut[1]+=f"\n!!!!!!!!!! Error while processing the above image pair: {dum}"
|
|
471
|
+
errorPrint=f"!!!!!!!!!! Error while {errorType}:\n{dum}\n"
|
|
472
|
+
stampa+=errorPrint
|
|
473
|
+
stringaErr+=stampa
|
|
474
|
+
pri.Error.red(stringaErr)
|
|
475
|
+
else:
|
|
476
|
+
flagOut|=FLAG_PROC[kConst]# per completezza aggiungo anche processato
|
|
477
|
+
stampa+=f" Laser plane eq. : z (mm) = {ve.PianoLaser[0]:.4g} + {ve.PianoLaser[1]:.4g} * x + {ve.PianoLaser[2]:.4g} * y\n Residual calib. err. ort. = {dAC.dOrtMean:.4g} pixels\n Residual calib. err. par. = {dAC.dParMean:.4g} pixels\n Estimated laser thick. = {dAC.DeltaZ:.4g} pixels (approx. {dAC.DeltaZ * dP.RisxRadd / abs(dAC.ta0Mean - dAC.ta1Mean):.4g} mm)\n Outliers % = {dAC.percOutlier*100:g} \n"
|
|
478
|
+
data.OUT_dict['zconst']=float(ve.PianoLaser[0])
|
|
479
|
+
data.OUT_dict['xterm']=float(ve.PianoLaser[1])
|
|
480
|
+
data.OUT_dict['yterm']=float(ve.PianoLaser[2])
|
|
481
|
+
try:
|
|
482
|
+
nameVar=data.namesPIV.instVel
|
|
483
|
+
Var=[getattr(self.disp.vect,f) for f in nameVar ]
|
|
484
|
+
#if it==spivIn.Niter-1:
|
|
485
|
+
# saveResults(data,-1,Var,nameVar)
|
|
486
|
+
#else:
|
|
487
|
+
saveResults(data,f'it{it+1}',Var,nameVar)
|
|
488
|
+
CC_rot=self.create_CC_image(self.disp.vect.CCrot)
|
|
489
|
+
nameFileOut=data.resF(f'it{it+1}',string='dispMap')
|
|
490
|
+
self.save_CC_image(CC_rot,nameFileOut)
|
|
491
|
+
pass
|
|
492
|
+
except Exception as inst:
|
|
493
|
+
errorPrint=f"\n!!!!!!!!!! Error while saving the results:\n{str(inst)}\n"
|
|
494
|
+
stampa+=errorPrint
|
|
495
|
+
stringaErr+=stampa
|
|
496
|
+
pri.Error.red(stringaErr)
|
|
497
|
+
FlagFinalized=False
|
|
498
|
+
else:
|
|
499
|
+
FlagFinalized=True
|
|
500
|
+
if it==spivIn.Niter-1:
|
|
501
|
+
errorPrint=self.writeLaserPlaneConst(filename=data.outPathRoot+'.clz',planeConst=ve.PianoLaser,resolution=self.disp.dataProc.RisxRadd)
|
|
502
|
+
if errorPrint:
|
|
503
|
+
stampa+=errorPrint
|
|
504
|
+
stringaErr+=stampa
|
|
505
|
+
pri.Error.red(stringaErr)
|
|
506
|
+
FlagFinalized=False
|
|
507
|
+
else:
|
|
508
|
+
data.res=1./self.disp.dataProc.RisxRadd
|
|
509
|
+
data.laserConst=[float(const) for const in ve.PianoLaser]
|
|
510
|
+
if FlagFinalized:
|
|
511
|
+
flagOut|=FLAG_FINALIZED[kConst]|FLAG_CALLBACK_INTERNAL
|
|
512
|
+
|
|
513
|
+
data.list_print[it]=stampa
|
|
514
|
+
data.list_pim[it]=flagOut
|
|
515
|
+
self.signals.progress.emit(procID,ind,flagOut,Var,stampa)
|
|
516
|
+
if stringaErr: break
|
|
517
|
+
timesleep(3)
|
|
518
|
+
|
|
519
|
+
for j in range(it+1,spivIn.Niter):
|
|
520
|
+
data.list_print[j]=''
|
|
521
|
+
data.list_pim[j]=flagOut
|
|
522
|
+
self.signals.progress.emit(procID,j,flagOut,[],'')
|
|
523
|
+
|
|
524
|
+
self.data.FlagFinished=True
|
|
525
|
+
self.signals.finished.emit(data,stringaErr)
|
|
526
|
+
|
|
527
|
+
def writeLaserPlaneConst(self,filename:str, planeConst:list, resolution:float):
|
|
528
|
+
try:
|
|
529
|
+
with open(filename, "w") as cfg:
|
|
530
|
+
cfg.write(f"%SP00007\n")
|
|
531
|
+
cfg.write(f"% Used resolution={1 / resolution:.6g}pix/mm\n")
|
|
532
|
+
cfg.write(f"% Laser plane constants\n")
|
|
533
|
+
cfg.write(f"{planeConst[0]:.14e},\n")
|
|
534
|
+
cfg.write(f"{planeConst[1]:.14e},\n")
|
|
535
|
+
cfg.write(f"{planeConst[2]:.14e},\n")
|
|
536
|
+
except Exception as inst:
|
|
537
|
+
errorPrint=f"\n!!!!!!!!!! Error while saving the results:\n{str(inst)}\n"
|
|
538
|
+
#pri.Error.red(f'Error while saving the laser plane constants!\n{traceback.format_exc()}\n')
|
|
539
|
+
else:
|
|
540
|
+
errorPrint=''
|
|
541
|
+
return errorPrint
|
|
542
|
+
|
|
543
|
+
def stopDisparity(self,it,flagOut,flagOutIter):
|
|
544
|
+
procID=-1
|
|
545
|
+
ind=-1
|
|
546
|
+
data=self.data
|
|
547
|
+
spivIn=self.disp.SPIVIn
|
|
548
|
+
for j in range(it,spivIn.Niter):
|
|
549
|
+
data.list_print[j]=''
|
|
550
|
+
data.list_pim[j]=flagOut if j==it else flagOutIter
|
|
551
|
+
self.signals.progress.emit(procID,ind,flagOutIter,[],'')
|
|
552
|
+
self.signals.finished.emit(data,'')
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
def create_CC_image(self,CC):
|
|
556
|
+
# Get the dimensions of the input matrix
|
|
557
|
+
n, m, h, w = CC.shape
|
|
558
|
+
|
|
559
|
+
# Normalize the matrix values to the range [0, 65535]
|
|
560
|
+
CC_min = CC.min()
|
|
561
|
+
CC_max = CC.max()
|
|
562
|
+
CC_mean = 0.5*(CC_min+CC_max)
|
|
563
|
+
CC_mean_normalized = (CC_mean + 1.0)/2.0 * 65535
|
|
564
|
+
|
|
565
|
+
CC_normalized = (CC + 1.0)/2.0 * 65535
|
|
566
|
+
CC_normalized = CC_normalized.astype(np.uint16) # Convert to 16-bit integers
|
|
567
|
+
|
|
568
|
+
# Initialize the final image grid with the correct size
|
|
569
|
+
h=2*self.disp.dispAvCo.N_NormEpi+1
|
|
570
|
+
grid_height = h * n
|
|
571
|
+
grid_width = w * m
|
|
572
|
+
CC_rot = np.zeros((grid_height, grid_width), dtype=np.uint16)
|
|
573
|
+
|
|
574
|
+
# Populate the grid with submatrices
|
|
575
|
+
try:
|
|
576
|
+
for i in range(n):
|
|
577
|
+
for j in range(m):
|
|
578
|
+
# Copy the submatrix (w x h) into the appropriate position in the grid
|
|
579
|
+
CC_rot[i*h:(i+1)*h, j*w:(j+1)*w] = CC_normalized[i, j, :h, :]
|
|
580
|
+
CC_rot[i*h, j*w:(j+1)*w] = CC_mean_normalized
|
|
581
|
+
CC_rot[i*h:(i+1)*h, j*w] = CC_mean_normalized
|
|
582
|
+
CC_rot[(i+1)*h-1, j*w:(j+1)*w] = CC_mean_normalized
|
|
583
|
+
CC_rot[i*h:(i+1)*h, (j+1)*w-1] = CC_mean_normalized
|
|
584
|
+
except:
|
|
585
|
+
pri.Error.red(f'Error while generating disparity map image:\n{traceback.format_exc()}\n\n')
|
|
586
|
+
pass
|
|
587
|
+
|
|
588
|
+
return CC_rot
|
|
589
|
+
|
|
590
|
+
def save_CC_image(self,CC,file_path):
|
|
591
|
+
image = Image.fromarray(CC)
|
|
592
|
+
image.save(file_path)
|
|
593
|
+
return
|