PaIRS-UniNa 0.1.13__cp310-cp310-win_amd64.whl → 0.2.8__cp310-cp310-win_amd64.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 +331 -0
- PaIRS_UniNa/Changes.txt +134 -2
- PaIRS_UniNa/Custom_Top.py +299 -299
- PaIRS_UniNa/Explorer.py +3136 -0
- PaIRS_UniNa/FolderLoop.py +562 -0
- PaIRS_UniNa/Input_Tab.py +831 -0
- PaIRS_UniNa/Input_Tab_CalVi.py +786 -0
- PaIRS_UniNa/Input_Tab_tools.py +3025 -0
- PaIRS_UniNa/Log_Tab.py +57 -14
- PaIRS_UniNa/Output_Tab.py +922 -0
- PaIRS_UniNa/PaIRS_PIV.py +111 -18
- PaIRS_UniNa/PaIRS_pypacks.py +698 -140
- PaIRS_UniNa/Process_Tab.py +1221 -1402
- PaIRS_UniNa/Process_Tab_CalVi.py +137 -262
- PaIRS_UniNa/Process_Tab_Disp.py +163 -0
- PaIRS_UniNa/Process_Tab_Min.py +120 -0
- PaIRS_UniNa/Saving_tools.py +296 -0
- PaIRS_UniNa/TabTools.py +863 -543
- PaIRS_UniNa/Vis_Tab.py +1898 -1315
- PaIRS_UniNa/Vis_Tab_CalVi.py +484 -356
- PaIRS_UniNa/Whatsnew.py +59 -10
- PaIRS_UniNa/_PaIRS_PIV.pyd +0 -0
- PaIRS_UniNa/__init__.py +4 -3
- PaIRS_UniNa/addwidgets_ps.py +326 -56
- PaIRS_UniNa/calib.py +19 -12
- PaIRS_UniNa/calibView.py +48 -25
- PaIRS_UniNa/gPaIRS.py +3902 -3461
- PaIRS_UniNa/gPalette.py +189 -170
- 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/bin_off.png +0 -0
- PaIRS_UniNa/icons/bin_on.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/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/close_all.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/cut.png +0 -0
- PaIRS_UniNa/icons/cut_warnings.png +0 -0
- PaIRS_UniNa/icons/darkmode.png +0 -0
- PaIRS_UniNa/icons/disp_step.png +0 -0
- PaIRS_UniNa/icons/disp_step_off.png +0 -0
- PaIRS_UniNa/icons/edit_list.png +0 -0
- PaIRS_UniNa/icons/example_list.png +0 -0
- PaIRS_UniNa/icons/flaticon_PaIRS_beta.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/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/import_set.png +0 -0
- PaIRS_UniNa/icons/information.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/log_logo.png +0 -0
- PaIRS_UniNa/icons/logo_opaco.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/new_workspace.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/paused.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/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/read.png +0 -0
- PaIRS_UniNa/icons/read_list.png +0 -0
- PaIRS_UniNa/icons/reset.png +0 -0
- PaIRS_UniNa/icons/reset_levels.png +0 -0
- PaIRS_UniNa/icons/restore_undo.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/save_and_stop.png +0 -0
- PaIRS_UniNa/icons/save_cfg.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/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/unedited.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/vectorColor.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/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 +8 -8
- PaIRS_UniNa/parForMulti.py +7 -5
- PaIRS_UniNa/parForWorkers.py +370 -31
- PaIRS_UniNa/pivParFor.py +233 -229
- PaIRS_UniNa/plt_util.py +141 -141
- PaIRS_UniNa/preProcParFor.py +153 -148
- PaIRS_UniNa/procTools.py +631 -178
- PaIRS_UniNa/readcfg.py +31 -1
- PaIRS_UniNa/rqrdpckgs.txt +9 -0
- PaIRS_UniNa/stereoPivParFor.py +227 -0
- PaIRS_UniNa/tAVarie.py +215 -215
- PaIRS_UniNa/tabSplitter.py +612 -0
- PaIRS_UniNa/ui_Calibration_Tab.py +545 -0
- PaIRS_UniNa/ui_Custom_Top.py +5 -5
- PaIRS_UniNa/ui_Input_Tab.py +1101 -0
- PaIRS_UniNa/{ui_Import_Tab_CalVi.py → ui_Input_Tab_CalVi.py} +1282 -1275
- PaIRS_UniNa/ui_Log_Tab.py +262 -257
- PaIRS_UniNa/{ui_Export_Tab.py → ui_Output_Tab.py} +2361 -1778
- PaIRS_UniNa/ui_Process_Tab.py +3809 -3758
- PaIRS_UniNa/ui_Process_Tab_CalVi.py +1547 -1546
- PaIRS_UniNa/ui_Process_Tab_Disp.py +1141 -0
- PaIRS_UniNa/ui_Process_Tab_Min.py +437 -0
- PaIRS_UniNa/ui_Vis_Tab.py +1626 -1208
- PaIRS_UniNa/ui_Vis_Tab_CalVi.py +1249 -1249
- PaIRS_UniNa/ui_Whatsnew.py +131 -131
- PaIRS_UniNa/ui_gPairs.py +876 -950
- PaIRS_UniNa/ui_infoPaIRS.py +550 -425
- PaIRS_UniNa/whatsnew.txt +6 -4
- {PaIRS_UniNa-0.1.13.dist-info → pairs_unina-0.2.8.dist-info}/METADATA +69 -51
- pairs_unina-0.2.8.dist-info/RECORD +329 -0
- {PaIRS_UniNa-0.1.13.dist-info → pairs_unina-0.2.8.dist-info}/WHEEL +1 -1
- PaIRS_UniNa/CalVi.py +0 -18
- PaIRS_UniNa/Export_Tab.py +0 -574
- PaIRS_UniNa/Import_Tab.py +0 -657
- PaIRS_UniNa/Import_Tab_CalVi.py +0 -861
- PaIRS_UniNa/Import_Tab_tools.py +0 -598
- PaIRS_UniNa/Tree_Tab.py +0 -543
- PaIRS_UniNa/gCalVi.py +0 -2024
- PaIRS_UniNa/icons/add.png +0 -0
- PaIRS_UniNa/icons/cancelled.png +0 -0
- PaIRS_UniNa/icons/chain.png +0 -0
- PaIRS_UniNa/icons/chain_broken.png +0 -0
- PaIRS_UniNa/icons/default_sizes.png +0 -0
- PaIRS_UniNa/icons/dock_tabs.png +0 -0
- PaIRS_UniNa/icons/done.png +0 -0
- PaIRS_UniNa/icons/down_arrow.png +0 -0
- PaIRS_UniNa/icons/export_logo.png +0 -0
- PaIRS_UniNa/icons/fast_delete.png +0 -0
- PaIRS_UniNa/icons/flip_y.png +0 -0
- PaIRS_UniNa/icons/ganci.png +0 -0
- PaIRS_UniNa/icons/import_blue.png +0 -0
- PaIRS_UniNa/icons/import_logo.png +0 -0
- PaIRS_UniNa/icons/missing.png +0 -0
- PaIRS_UniNa/icons/process_icon.png +0 -0
- PaIRS_UniNa/icons/processing.png +0 -0
- PaIRS_UniNa/icons/restart.png +0 -0
- PaIRS_UniNa/icons/right_arrow.png +0 -0
- PaIRS_UniNa/icons/run_piv.png +0 -0
- PaIRS_UniNa/icons/terminal.png +0 -0
- PaIRS_UniNa/icons/undock_tabs.png +0 -0
- PaIRS_UniNa/icons/vect_field.png +0 -0
- PaIRS_UniNa/icons/w0.png +0 -0
- PaIRS_UniNa/icons/w1.png +0 -0
- PaIRS_UniNa/icons/w2.png +0 -0
- PaIRS_UniNa/icons/w3.png +0 -0
- PaIRS_UniNa/icons/w4.png +0 -0
- PaIRS_UniNa/icons/w5.png +0 -0
- PaIRS_UniNa/run_CalVi.py +0 -14
- PaIRS_UniNa/run_gcalvi.py +0 -5
- PaIRS_UniNa/ui_Import_Tab.py +0 -1077
- PaIRS_UniNa/ui_Tree_Tab.py +0 -684
- PaIRS_UniNa/ui_gCalVi.py +0 -640
- PaIRS_UniNa/ui_infoCalVi.py +0 -428
- PaIRS_UniNa-0.1.13.dist-info/LICENSE +0 -19
- PaIRS_UniNa-0.1.13.dist-info/RECORD +0 -174
- /PaIRS_UniNa/icons/{clean_queue.png → clean.png} +0 -0
- /PaIRS_UniNa/icons/{waiting_c.png → sandglass.png} +0 -0
- {PaIRS_UniNa-0.1.13.dist-info → pairs_unina-0.2.8.dist-info}/top_level.txt +0 -0
PaIRS_UniNa/parForMulti.py
CHANGED
|
@@ -167,15 +167,16 @@ class ParForMul():
|
|
|
167
167
|
id is the id of the task should be a numeber between 1 and numUsedCores'''
|
|
168
168
|
return ('finalTask',2)
|
|
169
169
|
|
|
170
|
-
def launchTask(self,task,initTask,finalTask, *args,**kwargs):
|
|
170
|
+
def launchTask(self,procId,task,initTask,finalTask, *args,**kwargs):
|
|
171
171
|
''' the main parallel function first calls initTask (eventExit is an event that enables the safe exit)
|
|
172
172
|
then for all the element in the queue q calls task with the variable returned by initTask
|
|
173
173
|
finally calls finalTask puts in the queue qOut the final result '''
|
|
174
174
|
# aggiunto try così almeno ci rendiamo conto se c'è un errore
|
|
175
|
+
'''
|
|
175
176
|
try:
|
|
176
177
|
procId=mp.current_process()._identity[0]
|
|
177
178
|
except:
|
|
178
|
-
procId=0
|
|
179
|
+
procId=0 # '''
|
|
179
180
|
#pid=mp.current_process().pid
|
|
180
181
|
flagHasWorked=False#if true the task has processed at least one element
|
|
181
182
|
#if procId==2: prTimeLock(f"launchTask |||||||||||| Inizio procId={procId} flagHasWorked={flagHasWorked} ")
|
|
@@ -253,7 +254,7 @@ class ParForMul():
|
|
|
253
254
|
com.q.put((-1,-1))
|
|
254
255
|
|
|
255
256
|
for i in range(self.numUsedCores):
|
|
256
|
-
_=parPool.apply_async(self.launchTask,(task, initTask,finalTask)+args,kwargs,callback=callWrapUp, error_callback=self.errorHandler)
|
|
257
|
+
_=parPool.apply_async(self.launchTask,(i,task, initTask,finalTask)+args,kwargs,callback=callWrapUp, error_callback=self.errorHandler)
|
|
257
258
|
#_=parPool.apply_async(self.launchTask,(task, initTask,finalTask)+args,kwargs, error_callback=self.errorHandler)
|
|
258
259
|
#prTime(0,'Dopo apply async in parForExtPool ++++++++++++++++++++++++++++++++++')
|
|
259
260
|
nThreadEnd=0
|
|
@@ -285,7 +286,7 @@ class ParForMul():
|
|
|
285
286
|
|
|
286
287
|
return self.p,flagProcessed,strOutput,self.flagError
|
|
287
288
|
|
|
288
|
-
def simpleFor(self,task,names,*args,initTask=None,finalTask=None,wrapUp=None,callBack=None,**kwargs):
|
|
289
|
+
def simpleFor(self,parPool,task,names,*args,initTask=None,finalTask=None,wrapUp=None,callBack=None,**kwargs):
|
|
289
290
|
''' parallel for main function
|
|
290
291
|
task is the main function that is called for each value in names.
|
|
291
292
|
optionally initTask and finalTask are called only one time per worker
|
|
@@ -314,7 +315,8 @@ class ParForMul():
|
|
|
314
315
|
for _ in range(1):
|
|
315
316
|
com.q.put((-1,-1))
|
|
316
317
|
#with mp.Pool(self.numUsedCores) as pp:
|
|
317
|
-
|
|
318
|
+
procId=0
|
|
319
|
+
var=self.launchTask(procId,task, initTask,finalTask,*args,**kwargs)
|
|
318
320
|
callWrapUp(var)
|
|
319
321
|
nThreadEnd=0
|
|
320
322
|
while True:
|
PaIRS_UniNa/parForWorkers.py
CHANGED
|
@@ -13,6 +13,7 @@ from .PaIRS_pypacks import *
|
|
|
13
13
|
|
|
14
14
|
from .preProcParFor import *
|
|
15
15
|
from .pivParFor import *
|
|
16
|
+
from .stereoPivParFor import *
|
|
16
17
|
|
|
17
18
|
prTime = PrintTA(PrintTA.yellow, PrintTA.faceStd, PrintTAPriority.medium).prTime
|
|
18
19
|
|
|
@@ -25,7 +26,7 @@ class WorkerSignals(QObject):
|
|
|
25
26
|
kill = Signal(int)
|
|
26
27
|
|
|
27
28
|
class ParForWorker(QRunnable):
|
|
28
|
-
def __init__(self,data:dataTreePar,indWorker:int,indProc:int,
|
|
29
|
+
def __init__(self,data:dataTreePar,indWorker:int,indProc:int,numMaxProcs:int,pfPool:ParForPool,parForMul:ParForMul,nameWorker:str,mainFun:Callable):
|
|
29
30
|
#super(MIN_ParFor_Worker,self).__init__(data,indWorker,indProc,pfPool=ParForPool,parForMul=ParForMul)
|
|
30
31
|
super().__init__()
|
|
31
32
|
self.pfPool=pfPool
|
|
@@ -34,7 +35,7 @@ class ParForWorker(QRunnable):
|
|
|
34
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
|
|
35
36
|
self.indWorker = indWorker
|
|
36
37
|
self.indProc = indProc
|
|
37
|
-
self.
|
|
38
|
+
self.numMaxProcs=numMaxProcs
|
|
38
39
|
self.signals=WorkerSignals()
|
|
39
40
|
self.isKilled = False
|
|
40
41
|
self.isStoreCompleted = False
|
|
@@ -47,7 +48,7 @@ class ParForWorker(QRunnable):
|
|
|
47
48
|
if Flag_DEBUG_PARPOOL: debugpy.debug_this_thread()
|
|
48
49
|
try:
|
|
49
50
|
#pr(f'ParForWorker.run self.isKilled={self.isKilled} self.indWorker={self.indWorker} self.indProc={self.indProc} ')
|
|
50
|
-
self.parForMul.numUsedCores=self.
|
|
51
|
+
self.parForMul.numUsedCores=self.numMaxProcs
|
|
51
52
|
while self.indWorker!=self.indProc:# and not self.isKilled:
|
|
52
53
|
timesleep(SleepTime_Workers)
|
|
53
54
|
if self.isKilled:
|
|
@@ -59,14 +60,11 @@ class ParForWorker(QRunnable):
|
|
|
59
60
|
Message=printException('ParForWorker',flagMessage=True)
|
|
60
61
|
self.signals.finished.emit(self.data,Message)
|
|
61
62
|
#finally:#also after return eliminated
|
|
62
|
-
pri.Process.blue(f'End of ParForWorker {self.nameWorker} ({self.indWorker}, {self.numCallBackTotOk} )')
|
|
63
63
|
while not self.isStoreCompleted:
|
|
64
64
|
timesleep(SleepTime_Workers)
|
|
65
65
|
self.signals.completed.emit()
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
pri.Process.blue(f'End of ParForWorker {self.nameWorker} ({self.indWorker}, {self.numCallBackTotOk} )')
|
|
67
|
+
|
|
70
68
|
@Slot()
|
|
71
69
|
def killOrReset(self,isKilled):
|
|
72
70
|
#pr('\n***********************\n************************* ParForWorker.die {isKilled}')
|
|
@@ -89,8 +87,8 @@ class ParForWorker(QRunnable):
|
|
|
89
87
|
self.isStoreCompleted=True
|
|
90
88
|
|
|
91
89
|
class MIN_ParFor_Worker(ParForWorker):
|
|
92
|
-
def __init__(self,data:dataTreePar,indWorker:int,indProc:int,
|
|
93
|
-
super().__init__(data,indWorker,indProc,
|
|
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)
|
|
94
92
|
|
|
95
93
|
def calcmin(self):
|
|
96
94
|
stringaErr=''
|
|
@@ -100,10 +98,10 @@ class MIN_ParFor_Worker(ParForWorker):
|
|
|
100
98
|
|
|
101
99
|
#pp=ParForMul()
|
|
102
100
|
#pp.sleepTime=ParFor_sleepTime #time between calls of callBack
|
|
103
|
-
#pp.numCoresParPool=
|
|
101
|
+
#pp.numCoresParPool=numMaxProcs
|
|
104
102
|
|
|
105
103
|
self.data.compMin.restoreMin()
|
|
106
|
-
args=(self.data,self.
|
|
104
|
+
args=(self.data,self.numMaxProcs)
|
|
107
105
|
kwargs={}
|
|
108
106
|
numCallBackTotOk=self.data.numFinalized #su quelli non finalized ci ripassiamo quindi inizialmente il num di callback ok = num di finalized
|
|
109
107
|
|
|
@@ -112,14 +110,21 @@ class MIN_ParFor_Worker(ParForWorker):
|
|
|
112
110
|
|
|
113
111
|
myCallBack=lambda a,b,c,d,e,f: callBackMin(a,b,c,d,e,f,self.signals.progress)
|
|
114
112
|
#for ii,f in enumerate(self.data.list_pim): pr(f'{ii}-{hex(f)} ',end='')
|
|
115
|
-
pri.Process.blue(f'Init calcmin Contab={self.data.compMin.contab} numCallBackTotOk={numCallBackTotOk}
|
|
113
|
+
pri.Process.blue(f'Init calcmin Contab={self.data.compMin.contab} numCallBackTotOk={numCallBackTotOk} numMaxProcs={self.numMaxProcs}')
|
|
116
114
|
self.signals.initialized.emit()
|
|
115
|
+
|
|
116
|
+
self.parForMul.numUsedCores=self.numMaxProcs
|
|
117
117
|
#TBD TA all the exceptions should be managed inside parForExtPool therefore the try should be useless just in case I check
|
|
118
118
|
try:
|
|
119
|
-
|
|
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)
|
|
120
124
|
except Exception as e:
|
|
121
125
|
PrintTA().printEvidenced('Calcmin exception raised.\nThis should never happen.')
|
|
122
126
|
raise (e)
|
|
127
|
+
|
|
123
128
|
if flagError:
|
|
124
129
|
self.signals.finished.emit(self.data,printException('calcmin',flagMessage=True,exception=self.parForMul.exception))
|
|
125
130
|
return
|
|
@@ -170,55 +175,84 @@ class MIN_ParFor_Worker(ParForWorker):
|
|
|
170
175
|
self.signals.finished.emit(self.data,stringaErr)
|
|
171
176
|
|
|
172
177
|
class PIV_ParFor_Worker(ParForWorker):
|
|
173
|
-
def __init__(self,data:dataTreePar,indWorker:int,indProc:int,
|
|
174
|
-
super().__init__(data,indWorker,indProc,
|
|
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)
|
|
175
180
|
|
|
176
|
-
def runPIVParFor(self)
|
|
181
|
+
def runPIVParFor(self):#unified function for piv and Stereo
|
|
177
182
|
stringaErr=''
|
|
178
183
|
global FlagStopWorkers
|
|
179
|
-
|
|
184
|
+
|
|
185
|
+
outString='runPIVParFor' if self.data.Step==StepTypes.piv else 'runStereoPIVParFor'
|
|
186
|
+
pri.Time.cyan(3,outString)
|
|
180
187
|
FlagStopWorkers[0]=0
|
|
181
188
|
# TODEL
|
|
182
189
|
|
|
183
190
|
flagDebugMem=False
|
|
184
191
|
if flagDebugMem:# TODEL?
|
|
185
192
|
m1=memoryUsagePsutil()
|
|
186
|
-
filename_preproc=self.data.filename_proc[
|
|
193
|
+
filename_preproc=self.data.filename_proc[StepTypes.min]
|
|
187
194
|
|
|
188
195
|
self.data.mediaPIV.restoreSum()
|
|
189
196
|
|
|
190
197
|
#args=(self.data,)
|
|
191
|
-
|
|
192
|
-
|
|
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
|
|
193
213
|
kwargs={}
|
|
194
214
|
numCallBackTotOk=self.data.numFinalized #su quelli non finalized ci ripassiamo quindi inizialmente il num di callback ok = num di finalized
|
|
195
215
|
|
|
196
216
|
|
|
197
217
|
nImg=range(self.data.nimg)
|
|
198
218
|
myCallBack=lambda a,b,c,d,e,f: callBackPIV(a,b,c,d,e,f,self.signals.progress)
|
|
199
|
-
pri.Process.blue(f'
|
|
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}')
|
|
200
220
|
|
|
201
221
|
self.signals.initialized.emit()
|
|
202
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
|
|
203
232
|
try:
|
|
204
|
-
|
|
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
|
+
|
|
205
238
|
except Exception as e:
|
|
206
|
-
PrintTA().printEvidenced('
|
|
239
|
+
PrintTA().printEvidenced(f'{outString} exception raised\nThis should never happen ')
|
|
207
240
|
raise (e)
|
|
241
|
+
|
|
208
242
|
if flagError:
|
|
209
|
-
self.signals.finished.emit(self.data,printException(
|
|
243
|
+
self.signals.finished.emit(self.data,printException(outString,flagMessage=True,exception=self.parForMul.exception))
|
|
210
244
|
return
|
|
211
245
|
|
|
212
246
|
try:
|
|
213
247
|
if me.cont:
|
|
214
|
-
me:
|
|
248
|
+
me:MediaPIV
|
|
215
249
|
me.calcMedia()
|
|
216
250
|
nameFields=me.namesPIV.avgVelFields
|
|
217
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]
|
|
218
252
|
nameVar=me.namesPIV.avgVel
|
|
219
253
|
saveResults(self.data,-1,Var,nameVar)
|
|
220
254
|
except:
|
|
221
|
-
stringaErr+=printException(
|
|
255
|
+
stringaErr+=printException(outString,flagMessage=True,exception=self.parForMul.exception)+'\n'
|
|
222
256
|
numCallBackTotOk+=sum(1 if x&FLAG_CALLBACK_INTERNAL else 0 for x in flagOut)
|
|
223
257
|
|
|
224
258
|
# Tbd
|
|
@@ -237,18 +271,323 @@ class PIV_ParFor_Worker(ParForWorker):
|
|
|
237
271
|
#initTime=time()
|
|
238
272
|
self.data.flagParForCompleted=True
|
|
239
273
|
while self.numCallBackTotOk!=numCallBackTotOk :
|
|
240
|
-
pri.Process.blue (f'Error
|
|
274
|
+
pri.Process.blue (f'Error {outString} self.numCallBackTotOk={self.numCallBackTotOk} numCallBackTotOk={numCallBackTotOk} numUsedProcs={numUsedProcs} numPivOmpCores={numPivOmpCores}')
|
|
241
275
|
timesleep(SleepTime_Workers)
|
|
242
276
|
|
|
243
|
-
if me.cont:
|
|
244
|
-
|
|
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]}')
|
|
245
279
|
|
|
246
280
|
#self.numFinalized=sum(1 if f&FLAG_FINALIZED[0] else 0 for f in flagOut)
|
|
247
281
|
numProcOrErrTot=sum(1 if f else 0 for f in flagOut)
|
|
248
282
|
|
|
249
283
|
#for ii,f in enumerate(flagOut): pr(f'{ii}-{hex(f)} ',end='')
|
|
250
|
-
pri.Process.blue (f'Fine
|
|
284
|
+
pri.Process.blue (f'Fine {outString} ************** numCallBackTotOk={numCallBackTotOk} numProcOrErrTot={numProcOrErrTot} numFinalized={self.data.numFinalized}')
|
|
251
285
|
|
|
252
286
|
self.data.mediaPIV=me
|
|
253
287
|
self.data.FlagFinished=self.data.nimg==numProcOrErrTot
|
|
254
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
|