PaIRS-UniNa 0.2.0__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 +39 -23
- PaIRS_UniNa/Changes.txt +127 -8
- PaIRS_UniNa/Custom_Top.py +12 -9
- PaIRS_UniNa/Explorer.py +534 -165
- PaIRS_UniNa/FolderLoop.py +562 -0
- PaIRS_UniNa/Input_Tab.py +261 -100
- PaIRS_UniNa/Input_Tab_CalVi.py +24 -25
- PaIRS_UniNa/Input_Tab_tools.py +967 -405
- PaIRS_UniNa/Output_Tab.py +324 -130
- PaIRS_UniNa/PaIRS_PIV.py +58 -1
- PaIRS_UniNa/PaIRS_pypacks.py +1415 -1039
- PaIRS_UniNa/Process_Tab.py +15 -19
- PaIRS_UniNa/Process_Tab_Disp.py +12 -5
- PaIRS_UniNa/Saving_tools.py +27 -13
- PaIRS_UniNa/TabTools.py +176 -59
- PaIRS_UniNa/Vis_Tab.py +664 -256
- PaIRS_UniNa/Vis_Tab_CalVi.py +114 -45
- PaIRS_UniNa/Whatsnew.py +58 -9
- PaIRS_UniNa/_PaIRS_PIV.pyd +0 -0
- PaIRS_UniNa/__init__.py +4 -3
- PaIRS_UniNa/addwidgets_ps.py +150 -63
- PaIRS_UniNa/calib.py +6 -3
- PaIRS_UniNa/calibView.py +19 -6
- PaIRS_UniNa/gPaIRS.py +1397 -543
- PaIRS_UniNa/icons/align_all.png +0 -0
- PaIRS_UniNa/icons/announcement.png +0 -0
- PaIRS_UniNa/icons/bugfix.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/copy_process_off.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/folder_loop_cleanup.png +0 -0
- PaIRS_UniNa/icons/folder_loop_cleanup_off.png +0 -0
- PaIRS_UniNa/icons/linked.png +0 -0
- PaIRS_UniNa/icons/logo_opaco.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/process_loop.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/restore_undo.png +0 -0
- PaIRS_UniNa/icons/save_and_stop.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_path_loop.png +0 -0
- PaIRS_UniNa/icons/scan_path_loop_off.png +0 -0
- PaIRS_UniNa/icons/show_all.png +0 -0
- PaIRS_UniNa/icons/star.png +0 -0
- PaIRS_UniNa/icons/step_inheritance.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/window.png +0 -0
- PaIRS_UniNa/listLib.py +3 -2
- PaIRS_UniNa/parForMulti.py +7 -5
- PaIRS_UniNa/parForWorkers.py +174 -140
- PaIRS_UniNa/pivParFor.py +9 -11
- PaIRS_UniNa/preProcParFor.py +4 -4
- PaIRS_UniNa/procTools.py +120 -44
- PaIRS_UniNa/rqrdpckgs.txt +9 -0
- PaIRS_UniNa/stereoPivParFor.py +16 -22
- PaIRS_UniNa/tabSplitter.py +17 -7
- PaIRS_UniNa/ui_Input_Tab.py +56 -57
- PaIRS_UniNa/ui_Input_Tab_CalVi.py +71 -64
- PaIRS_UniNa/ui_Log_Tab.py +8 -6
- PaIRS_UniNa/ui_Output_Tab.py +180 -4
- PaIRS_UniNa/ui_Process_Tab.py +19 -19
- PaIRS_UniNa/ui_Process_Tab_Disp.py +181 -10
- PaIRS_UniNa/ui_Vis_Tab.py +332 -196
- PaIRS_UniNa/ui_Whatsnew.py +13 -13
- PaIRS_UniNa/ui_gPairs.py +140 -71
- PaIRS_UniNa/ui_infoPaIRS.py +156 -31
- PaIRS_UniNa/whatsnew.txt +6 -4
- {PaIRS_UniNa-0.2.0.dist-info → pairs_unina-0.2.8.dist-info}/METADATA +62 -26
- {PaIRS_UniNa-0.2.0.dist-info → pairs_unina-0.2.8.dist-info}/RECORD +82 -54
- {PaIRS_UniNa-0.2.0.dist-info → pairs_unina-0.2.8.dist-info}/WHEEL +1 -1
- PaIRS_UniNa/icons/order.png +0 -0
- PaIRS_UniNa/icons/order_reverse.png +0 -0
- PaIRS_UniNa/icons/run_piv.png +0 -0
- PaIRS_UniNa/stereo.py +0 -685
- PaIRS_UniNa/ui_infoCalVi.py +0 -428
- PaIRS_UniNa-0.2.0.dist-info/LICENSE +0 -19
- {PaIRS_UniNa-0.2.0.dist-info → pairs_unina-0.2.8.dist-info}/top_level.txt +0 -0
PaIRS_UniNa/stereo.py
DELETED
|
@@ -1,685 +0,0 @@
|
|
|
1
|
-
''' helper class for Stereo'''
|
|
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 typing import Tuple#,Callable
|
|
9
|
-
from enum import Enum
|
|
10
|
-
from time import sleep
|
|
11
|
-
#import faulthandler # per capire da dove vengono gli errori c
|
|
12
|
-
import platform
|
|
13
|
-
|
|
14
|
-
from PIL import Image
|
|
15
|
-
import numpy as np
|
|
16
|
-
|
|
17
|
-
from .tAVarie import pri, PrintTA ,PrintTAPriority
|
|
18
|
-
from .readcfg import readNumCfg, readCfgTag,readNumVecCfg
|
|
19
|
-
|
|
20
|
-
if __package__ or "." in __name__:
|
|
21
|
-
import PaIRS_UniNa.PaIRS_PIV as PaIRS_lib
|
|
22
|
-
from PaIRS_UniNa.PaIRS_PIV import Punto
|
|
23
|
-
|
|
24
|
-
else:
|
|
25
|
-
if platform.system() == "Darwin":
|
|
26
|
-
sys.path.append('../lib/mac')
|
|
27
|
-
#sys.path.append('../lib')
|
|
28
|
-
else:
|
|
29
|
-
#sys.path.append('PaIRS_PIV')
|
|
30
|
-
sys.path.append('../lib')
|
|
31
|
-
sys.path.append('TpivPython/lib')
|
|
32
|
-
import PaIRS_PIV as PaIRS_lib # type: ignore
|
|
33
|
-
from PaIRS_PIV import Punto # type: ignore
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
# to be deleted
|
|
37
|
-
#import debugpy #nel caso mettere nel thread debugpy.debug_this_thread()
|
|
38
|
-
#from PaIRS_pypacks import Flag_DEBUG_PARPOOL
|
|
39
|
-
Flag_DEBUG_PARPOOL=1 # pylint: disable=invalid-name
|
|
40
|
-
if Flag_DEBUG_PARPOOL: import debugpy #nel casso mettere nel thread debugpy.debug_this_thread()
|
|
41
|
-
|
|
42
|
-
FlagReadCfg=True
|
|
43
|
-
PrintTA.flagPriority=PrintTAPriority.veryLow
|
|
44
|
-
# errror codes
|
|
45
|
-
TYPE_ERR_REPEAT=-101 # pylint: disable=invalid-name
|
|
46
|
-
TYPE_ERR_STOP=0 # pylint: disable=invalid-name
|
|
47
|
-
|
|
48
|
-
#for multithreading and other stuff
|
|
49
|
-
SleepTime_Workers=0.1 # pylint: disable=invalid-name
|
|
50
|
-
|
|
51
|
-
class StereoTasks(Enum):
|
|
52
|
-
''' when <=0 no button is created'''
|
|
53
|
-
#stop should be zero so that is is possible to check immediately is no task are running
|
|
54
|
-
stop = 0 # pylint: disable=invalid-name
|
|
55
|
-
findAllPlanes= 1 # pylint: disable=invalid-name
|
|
56
|
-
'''****
|
|
57
|
-
findCurrentPlane= 2 # pylint: disable=invalid-name
|
|
58
|
-
calibrate=3 # pylint: disable=invalid-name
|
|
59
|
-
savePoints=4 # pylint: disable=invalid-name
|
|
60
|
-
findPlanesFromOrigin=-1 # pylint: disable=invalid-name
|
|
61
|
-
***'''
|
|
62
|
-
stereoTasksText=[
|
|
63
|
-
# the index is relative to the value of CalibTask
|
|
64
|
-
'Stop',
|
|
65
|
-
'Find all' ,
|
|
66
|
-
'''***
|
|
67
|
-
'Find curr.',
|
|
68
|
-
'Calibrate' ,
|
|
69
|
-
'Save coord.' ,
|
|
70
|
-
'...'
|
|
71
|
-
***'''
|
|
72
|
-
|
|
73
|
-
]
|
|
74
|
-
''' when not calibrated all the voices are disabled'''
|
|
75
|
-
class StereoFunctions(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
|
-
stereoFunctionsText=[
|
|
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
|
-
def printPIVLog(PD):
|
|
108
|
-
stampa="It IW #IW #Vect/#Tot % CC CC(avg) DC%\n"# NR% Cap%\n"
|
|
109
|
-
for j in range(len(PD.It)):
|
|
110
|
-
riga="%3d %3dx%-3d %4dx%-4d %7d/%-7d %5.1f %8.7f %8.7f %4.1f\n" %\
|
|
111
|
-
(PD.It[j], PD.WCella[j], PD.HCella[j], PD.W[j], PD.H[j], PD.NVect[j],\
|
|
112
|
-
PD.W[j]*PD.H[j], 100.0*PD.NVect[j]/(PD.W[j]*PD.H[j]), PD.Fc[j],\
|
|
113
|
-
PD.FcMedia[j], 100.0*PD.ContErorreDc[j]/(PD.W[j]*PD.H[j]))#,\
|
|
114
|
-
#100.0*PIV.PD.ContRemNoise[j]/(PIV.Inp.ImgW*PIV.Inp.ImgH),\
|
|
115
|
-
#100.0*PIV.PD.ContCap[j]/(PIV.Inp.ImgW*PIV.Inp.ImgH))
|
|
116
|
-
stampa=stampa+riga
|
|
117
|
-
return stampa
|
|
118
|
-
|
|
119
|
-
class Stereo(PaIRS_lib.PyFunOutCalib):
|
|
120
|
-
def __init__(self):
|
|
121
|
-
#super().__init__(mainFun=self.findAllPlanes)
|
|
122
|
-
PaIRS_lib.PyFunOutCalib.__init__(self)
|
|
123
|
-
# self.funCalib =PaIRS_lib.getPyFunCalib(self)
|
|
124
|
-
# self.pointDesc=['origin ', 'right (along x)','upper (along y)']
|
|
125
|
-
# self.inputPoints=[Punto(0,0)]*3 #input points when looking for origin
|
|
126
|
-
# self.foundPoints=[Punto(0,0)]*3 #found point near the input points when looking for origin
|
|
127
|
-
# self.flagFoundPoints=[False]*3 #flag to be sure that point have been found
|
|
128
|
-
#self.cal=PaIRS_lib.Cal()
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
#self.disp=PaIRS_lib.StereoDisp()
|
|
132
|
-
self.stereo=PaIRS_lib.Stereo()
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
self.imgs =[] # Images imgs[i][c][0/1] i img number c cam last first or second image
|
|
136
|
-
# self.ccMask =[] # correlation mask
|
|
137
|
-
# self.flagRicerca=0 # 0 stand by 1-3 searching first, second or third point 4 the three point have been found
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
# self.tipoCal=0 # Calibration type see calibra.h
|
|
144
|
-
# comunication with the view
|
|
145
|
-
self.signals:SignalsStereoWorker=None
|
|
146
|
-
self.ans=0 # Answer from view
|
|
147
|
-
self.pu=Punto(0,0) # Point From view
|
|
148
|
-
self.flagAnsReady=False #True if answer is ready to be read
|
|
149
|
-
self.flagPointReady=False #True if point is ready to be read
|
|
150
|
-
self.flagExitFromView=False #True if exit from View signal
|
|
151
|
-
self.flagFindAllPlanes=False #True if point searching all the planes
|
|
152
|
-
self.rectZonaCom:Tuple=None
|
|
153
|
-
#self.cal.flagCalibrated=False # True if the calibration has ended successfully
|
|
154
|
-
# various
|
|
155
|
-
self.cfgName='' # Name of the cfg file comprehensive of path but without extension
|
|
156
|
-
self.cfgNameStereo='' # Name of the cfg file comprehensive of path but without extension
|
|
157
|
-
pri.Time.cyan(0,'Init Stereo')
|
|
158
|
-
self.nImgs=0
|
|
159
|
-
self.img=0 # Img in use
|
|
160
|
-
self.nCams=2 # number of cameras
|
|
161
|
-
self.cam=0 # camera in use
|
|
162
|
-
|
|
163
|
-
self.cams=[] # list of the camera identifiers
|
|
164
|
-
self.pair=0 # 0 img a 1 img b
|
|
165
|
-
# flags
|
|
166
|
-
# self.flagShowMask=True # True to plot the mask #todo maybe in a different window
|
|
167
|
-
#self.flagPlotMask=False
|
|
168
|
-
#self.strOut=''
|
|
169
|
-
|
|
170
|
-
self.LLim=1
|
|
171
|
-
self.LMax=1
|
|
172
|
-
self.LMin=0
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
def waitAnsFromView(self)-> int:
|
|
178
|
-
''' used to wait an answer from the view return an int '''
|
|
179
|
-
while not self.flagAnsReady:
|
|
180
|
-
sleep(SleepTime_Workers)
|
|
181
|
-
self.flagAnsReady=False
|
|
182
|
-
|
|
183
|
-
return self.ans
|
|
184
|
-
|
|
185
|
-
def checkExitFromView(self):
|
|
186
|
-
''' control if an exit signal has been emitted by the view and in case raises an error signal'''
|
|
187
|
-
if self.flagExitFromView:
|
|
188
|
-
self.flagExitFromView=False
|
|
189
|
-
self.signals.textFromStereo.emit( 'stopped by user')
|
|
190
|
-
raise ValueError('Exit from view ',TYPE_ERR_STOP)
|
|
191
|
-
|
|
192
|
-
def waitPointFromView(self)-> int:
|
|
193
|
-
''' used to wait a point from the view return an int '''
|
|
194
|
-
while not self.flagPointReady and not self.flagExitFromView:
|
|
195
|
-
sleep(SleepTime_Workers)
|
|
196
|
-
self.flagPointReady=False
|
|
197
|
-
self.checkExitFromView()
|
|
198
|
-
return self.pu
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
def askToRetry(self, funName:str):
|
|
203
|
-
''' used to avoid repeating code'''
|
|
204
|
-
self.signals.textFromStereo.emit('Press Yes to continue No to repeat' )
|
|
205
|
-
if not self.waitAnsFromView():
|
|
206
|
-
raise ValueError(f'Repeat in {funName}',TYPE_ERR_REPEAT)
|
|
207
|
-
|
|
208
|
-
def exceptAskRetry(self, exc:Exception, question: str,funName:str):
|
|
209
|
-
''' used to avoid repeating code'''
|
|
210
|
-
if len(exc.args) >1:# if not most probably from c Lib
|
|
211
|
-
if exc.args[1]==TYPE_ERR_STOP:# just exit
|
|
212
|
-
raise exc
|
|
213
|
-
self.signals.textFromStereo.emit(question)
|
|
214
|
-
if self.waitAnsFromView():
|
|
215
|
-
raise ValueError(f'Repeat in {funName}',TYPE_ERR_REPEAT) from exc
|
|
216
|
-
raise ValueError(f'Search stopped in {funName}',TYPE_ERR_STOP) from exc
|
|
217
|
-
|
|
218
|
-
@loopFun
|
|
219
|
-
def findPoint(self)->Punto:
|
|
220
|
-
''' look for a single point '''
|
|
221
|
-
self.signals.flagGetPointFromStereo.emit(1) #enables the search for points in the view
|
|
222
|
-
pu=self.waitPointFromView()
|
|
223
|
-
self.signals.flagGetPointFromStereo.emit(0) #disables the search for points in the view
|
|
224
|
-
sleep(0)
|
|
225
|
-
try:
|
|
226
|
-
pu=self.cal.findPoint(pu)
|
|
227
|
-
except ValueError as exc:
|
|
228
|
-
self.exceptAskRetry( exc, 'Point not found Yes to repeat No to stop','findPoint')
|
|
229
|
-
#pri.Info.white(f'findPoint ({pu.x}, {pu.y})')
|
|
230
|
-
self.signals.drawSingleCircleFromStereo.emit(pu,0,self.flagRicerca-1) # draws a circle on the detected points
|
|
231
|
-
return pu
|
|
232
|
-
def getZonaCom(self,c:int):
|
|
233
|
-
return (min (self.disp.vect.Xinf[c],self.disp.vect.Xsup[c]),
|
|
234
|
-
min (self.disp.vect.Yinf[c],self.disp.vect.Ysup[c]),
|
|
235
|
-
max (self.disp.vect.Xinf[c],self.disp.vect.Xsup[c]),
|
|
236
|
-
max (self.disp.vect.Yinf[c],self.disp.vect.Ysup[c]))
|
|
237
|
-
def getZonaComStereo(self,c:int):
|
|
238
|
-
return (min (self.stereo.vect.Xinf[c],self.stereo.vect.Xsup[c]),
|
|
239
|
-
min (self.stereo.vect.Yinf[c],self.stereo.vect.Ysup[c]),
|
|
240
|
-
max (self.stereo.vect.Xinf[c],self.stereo.vect.Xsup[c]),
|
|
241
|
-
max (self.stereo.vect.Yinf[c],self.stereo.vect.Ysup[c]))
|
|
242
|
-
def taskFindAllPlanes(self):
|
|
243
|
-
''' finds all the planes '''
|
|
244
|
-
|
|
245
|
-
pri.Callback.cyan('taskFindAllPlanes')
|
|
246
|
-
|
|
247
|
-
def prettyPrintErrCalib(self)-> str:
|
|
248
|
-
''' generate a string with a "pretty" version of the calibration error '''
|
|
249
|
-
data=self.cal.data
|
|
250
|
-
strAppo=f'#Points = { data.Npti}\n'
|
|
251
|
-
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})'
|
|
252
|
-
return strAppo
|
|
253
|
-
|
|
254
|
-
def prettyPrintCalib(self)-> str:
|
|
255
|
-
''' generate a string with a "pretty" version of the calibration parameters '''
|
|
256
|
-
data=self.cal.data
|
|
257
|
-
cost=self.cal.vect.cost
|
|
258
|
-
convGradi=180/np.pi
|
|
259
|
-
tipoCal = (data.TipoCal >> CalFlags.SHIFT) &CalFlags.MASK
|
|
260
|
-
flagPinHole =not (not( data.TipoCal & CalFlags.Flag_PIANI)) # pylint: disable=unneeded-not,superfluous-parens
|
|
261
|
-
#F_Sa = not (not(data.TipoCal & CalFlags.Flag_LIN_VI))
|
|
262
|
-
s=''
|
|
263
|
-
if (data.FlagCal == 1 or data.FlagCal == 2 or data.FlagCal == 3):
|
|
264
|
-
c = 0
|
|
265
|
-
for i in range (4, data.NumCostCalib):
|
|
266
|
-
s+=f'{cost[c][i]:+.4g} '
|
|
267
|
-
else: # TSAI di qualche forma!!!!!!!!
|
|
268
|
-
if (tipoCal> 0 or ( (data.FlagCal >= 10 and data.FlagCal <= 43)and flagPinHole)):#la seconda dovrebbe comprendere la prima
|
|
269
|
-
cPlanes=self.cal.vect.costPlanes
|
|
270
|
-
s+='Planes ******************\r\n'
|
|
271
|
-
for i in range ( data.Numpiani_PerCam):
|
|
272
|
-
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'
|
|
273
|
-
if data.FlagCal >= 30:#cal cilindrica
|
|
274
|
-
c = 0
|
|
275
|
-
s+='Cylinder ****************\r\n'
|
|
276
|
-
s+=f'Distortion s1={cost[c][24]:.2e} s2={cost[c][25]:.2e}\r\n'
|
|
277
|
-
s+=f'T(Cyl)=[{cost[c][17]:+.2f},{cost[c][18]:+.2f}] Ang(°)=[{cost[c][19]:+.2f},{cost[c][20]:+.2f}]\r\n'
|
|
278
|
-
s+=f'r(Cyl) [{cost[c][21]:+.2f},{cost[c][21]+cost[c][23]:+.2f}] rho=%g \r\n'
|
|
279
|
-
s+='Cameras ***************\r\n'
|
|
280
|
-
for c in range(data.NCam):
|
|
281
|
-
if cost[c][1] < 0:
|
|
282
|
-
s+='\r\n \r\n ******* The coordinate system is not right-handed ******* \r\n \r\n'
|
|
283
|
-
#Flag Rot Rot Rot Tx Ty Tz f u0 v0 b1 b2 k1 k2 p1 p2 sx S
|
|
284
|
-
|
|
285
|
-
s+=f'** c={c} Ang(°)=[{cost[c][2] * convGradi:+.2f},{cost[c][3] * convGradi:+.2f},{cost[c][4] * convGradi:+.2f}] '
|
|
286
|
-
s+=f'T=[{cost[c][5]:+.2f},{cost[c][6]:+.2f},{cost[c][7]:+.2f}] \r\n'
|
|
287
|
-
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'
|
|
288
|
-
s+=f' k=[{cost[c][13]:.2e},{cost[c][14]:.2e}] p=[{cost[c][15]:.2e},{cost[c][16]:.2e}]\r\n'
|
|
289
|
-
if data.FlagCal >= 30:
|
|
290
|
-
s+=f' Pixel Ratio={cost[c][26]:+.4g} xdim pixel={cost[c][27]:+.4g} \r\n'
|
|
291
|
-
else:
|
|
292
|
-
s+=f' Pixel Ratio={cost[c][17]:+.4g} xdim pixel={cost[c][18]:+.4g} \r\n'
|
|
293
|
-
return s
|
|
294
|
-
|
|
295
|
-
def waitForEver(self):
|
|
296
|
-
''' simply waits for ever'''
|
|
297
|
-
self.signals.flagGetPointFromStereo.emit(1)
|
|
298
|
-
#sleep(SleepTime_Workers)
|
|
299
|
-
self.taskFindAllPlanes()
|
|
300
|
-
i=0
|
|
301
|
-
while True:# and not self.isKilled:
|
|
302
|
-
sleep(SleepTime_Workers*5)
|
|
303
|
-
i+=1
|
|
304
|
-
#pri.Info.white(f'dummy called->{i}')
|
|
305
|
-
|
|
306
|
-
def setLMinMax(self,img=0,cam=0,pair=0):
|
|
307
|
-
self.LLim,self.LMax,self.LMin=self.calcLMinMax(img=img,cam=cam,pair=pair)
|
|
308
|
-
return
|
|
309
|
-
# TODO GP forse è meglio fissare un LLim positivo ed uno negativo come:
|
|
310
|
-
# perc= 0.2 ad esempio
|
|
311
|
-
# LLMin=LMin-abs((LMax-LMin)*perc)
|
|
312
|
-
# LLMax=LMax+abs((LMax-LMin)*perc)
|
|
313
|
-
# questo potrebbe essere fatto direttamente in fase di plot
|
|
314
|
-
# fra l'altro potremmo calcolare queste cose solo in fase di lettura (o calcolo nel caso della maschera) e non modificarle più
|
|
315
|
-
def calcLMinMax(self,img=0,cam=0,pair=0):
|
|
316
|
-
LLim=2**16-1
|
|
317
|
-
if len(self.imgs):
|
|
318
|
-
a=self.imgs[img][cam][pair]
|
|
319
|
-
LLim=np.iinfo(a.dtype).max
|
|
320
|
-
flagArray=True
|
|
321
|
-
else:
|
|
322
|
-
flagArray=False
|
|
323
|
-
if flagArray:
|
|
324
|
-
try:
|
|
325
|
-
LMax=int(a.max())
|
|
326
|
-
except:
|
|
327
|
-
LMax=LLim
|
|
328
|
-
try:
|
|
329
|
-
LMin=int(a.min())
|
|
330
|
-
except:
|
|
331
|
-
LMin=-LLim
|
|
332
|
-
else:
|
|
333
|
-
LMax=LLim
|
|
334
|
-
LMin=-LLim
|
|
335
|
-
return LLim,LMax,LMin
|
|
336
|
-
|
|
337
|
-
def readCalFile(self,buffer:str)->Tuple[int,int ,list[float]]:
|
|
338
|
-
''' reads the calibration constants from a file
|
|
339
|
-
buffer is the name of the file
|
|
340
|
-
if numCostCalib is different from none it is used regardless of the value in the file
|
|
341
|
-
In output returns flagCal,numCostCalib,cost
|
|
342
|
-
'''
|
|
343
|
-
try:
|
|
344
|
-
with open(buffer,'r') as f:
|
|
345
|
-
tag=readCfgTag(f)
|
|
346
|
-
|
|
347
|
-
if tag != "%SP00015":
|
|
348
|
-
raise RuntimeError(f'Wrong tag in file: {buffer}')
|
|
349
|
-
ind=1
|
|
350
|
-
ind,flagCal=readNumCfg(f,ind,int)
|
|
351
|
-
ind,numCostCalib=readNumCfg(f,ind,int)
|
|
352
|
-
|
|
353
|
-
cost=[0]*numCostCalib
|
|
354
|
-
for i in range(numCostCalib):# dati->NumCostCalib; i++):
|
|
355
|
-
ind,cost[i]=readNumCfg(f,ind,float)
|
|
356
|
-
return flagCal,numCostCalib,cost
|
|
357
|
-
#if "%SP00015"
|
|
358
|
-
#for index, line in enumerate(f): pri.Info.white("Line {}: {}".format(index, line.strip()))
|
|
359
|
-
#except Exception as exc:
|
|
360
|
-
except IOError as exc:
|
|
361
|
-
raise RuntimeError(f'Error opening the calibration constants file: {buffer}') from exc
|
|
362
|
-
except ValueError as exc:
|
|
363
|
-
raise RuntimeError(f'Error reading line:{ind+1} of file: {buffer}') from exc
|
|
364
|
-
except IndexError as exc:
|
|
365
|
-
raise RuntimeError(f'Error reading array in line:{ind+1} of file: {buffer}') from exc
|
|
366
|
-
|
|
367
|
-
def readImgsStereo(self ):
|
|
368
|
-
''' reads the images'''
|
|
369
|
-
formato=f'0{self.stereo.SPIVIn.Digit}d'
|
|
370
|
-
spivIn=self.stereo.SPIVIn
|
|
371
|
-
dP=self.stereo.dataProc
|
|
372
|
-
ind=np.ix_(np.arange(spivIn.RigaPart,spivIn.RigaPart+dP.ImgH),np.arange(spivIn.ColPart,spivIn.ColPart+dP.ImgW))
|
|
373
|
-
for p in range(spivIn.FirstImg, spivIn.LastImg+1):
|
|
374
|
-
ic=[]
|
|
375
|
-
for cam in range(self.nCams):
|
|
376
|
-
#numero='' if self.cal.data.FlagCam else f'_cam{self.cams[cam]}'
|
|
377
|
-
nomeImg=spivIn.InDir+spivIn.ImgRoot+f'{self.cams[cam]}_a{p:{formato}}'+spivIn.InExt
|
|
378
|
-
da=np.array(Image.open(nomeImg),dtype=float)
|
|
379
|
-
nomeImg=spivIn.InDir+spivIn.ImgRoot+f'{self.cams[cam]}_b{p:{formato}}'+spivIn.InExt
|
|
380
|
-
db=np.array(Image.open(nomeImg),dtype=float)
|
|
381
|
-
#pri.Info.white (f'{nomeImg}')
|
|
382
|
-
#ic.append
|
|
383
|
-
|
|
384
|
-
ic.append([np.ascontiguousarray(da[ind],dtype= np.uint16),np.ascontiguousarray(db[ind],dtype= np.uint16)])
|
|
385
|
-
self.imgs.append(ic)
|
|
386
|
-
#self.imgs.append(np.ascontiguousarray(da[spivIn.RigaPart:spivIn.RigaPart+dP.ImgH,spivIn.ColPart:spivIn.ColPart+dP.ImgW],dtype= np.uint16))
|
|
387
|
-
|
|
388
|
-
self.setLMinMax()
|
|
389
|
-
self.stereo.initAlloc(None)
|
|
390
|
-
for i in range( spivIn.LastImg+1-spivIn.FirstImg):
|
|
391
|
-
self.stereo.run(self.imgs[i])
|
|
392
|
-
sOut=printPIVLog(self.stereo.PD0)
|
|
393
|
-
sOut+=printPIVLog(self.stereo.PD1)
|
|
394
|
-
print (sOut)
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
#[Image2PIV_Float(I) for I in iProc]
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
def readImgs(self ):
|
|
403
|
-
''' reads the images'''
|
|
404
|
-
formato=f'0{self.disp.SPIVIn.Digit}d'
|
|
405
|
-
spivIn=self.disp.SPIVIn
|
|
406
|
-
dP=self.disp.dataProc
|
|
407
|
-
ind=np.ix_(np.arange(spivIn.RigaPart,spivIn.RigaPart+dP.ImgH),np.arange(spivIn.ColPart,spivIn.ColPart+dP.ImgW))
|
|
408
|
-
for p in range(spivIn.FirstImg, spivIn.LastImg+1):
|
|
409
|
-
ic=[]
|
|
410
|
-
for cam in range(self.nCams):
|
|
411
|
-
#numero='' if self.cal.data.FlagCam else f'_cam{self.cams[cam]}'
|
|
412
|
-
nomeImg=spivIn.InDir+spivIn.ImgRoot+f'{self.cams[cam]}_a{p:{formato}}'+spivIn.InExt
|
|
413
|
-
da=np.array(Image.open(nomeImg),dtype=float)
|
|
414
|
-
nomeImg=spivIn.InDir+spivIn.ImgRoot+f'{self.cams[cam]}_b{p:{formato}}'+spivIn.InExt
|
|
415
|
-
db=np.array(Image.open(nomeImg),dtype=float)
|
|
416
|
-
#pri.Info.white (f'{nomeImg}')
|
|
417
|
-
#ic.append
|
|
418
|
-
|
|
419
|
-
ic.append([np.ascontiguousarray(da[ind],dtype= np.uint16),np.ascontiguousarray(db[ind],dtype= np.uint16)])
|
|
420
|
-
self.imgs.append(ic)
|
|
421
|
-
#self.imgs.append(np.ascontiguousarray(da[spivIn.RigaPart:spivIn.RigaPart+dP.ImgH,spivIn.ColPart:spivIn.ColPart+dP.ImgW],dtype= np.uint16))
|
|
422
|
-
|
|
423
|
-
self.setLMinMax()
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
self.disp.initAllocDisp()
|
|
431
|
-
dAC=self.disp.dispAvCo
|
|
432
|
-
ve=self.disp.vect
|
|
433
|
-
|
|
434
|
-
for it in range(5):
|
|
435
|
-
self.disp.evaldXdY()
|
|
436
|
-
for i in range( spivIn.LastImg+1-spivIn.FirstImg):
|
|
437
|
-
self.disp.deWarpAndCalcCC(self.imgs[i])
|
|
438
|
-
self.disp.calcDisparity()
|
|
439
|
-
print(f"Laser plane eq {ve.PianoLaser[0]:4g}, {ve.PianoLaser[1]:4g}, {ve.PianoLaser[2]:4g} Res error cal {dAC.dOrtMean:4g} Corr Width {dAC.DeltaZ:4g} (approx {dAC.DeltaZ * dP.RisxRadd / abs(dAC.ta0Mean - dAC.ta1Mean):4g}mm)")
|
|
440
|
-
'''ve.PianoLaser[0]=0
|
|
441
|
-
ve.PianoLaser[1]=0
|
|
442
|
-
ve.PianoLaser[2]=0'''
|
|
443
|
-
#sprintf(OutErr, "Laser plane eq %g %g %g Res error cal %g Corr Width %g (approx %gmm)", datiproc->PianoLaser[0], datiproc->PianoLaser[1], datiproc->PianoLaser[2], DiAvCo->dOrtMean, DiAvCo->DeltaZ, DiAvCo->DeltaZ * datiproc->RisxRadd / ABS(DiAvCo->ta0Mean - DiAvCo->ta1Mean));
|
|
444
|
-
#self.cal.FlagPos=-5
|
|
445
|
-
|
|
446
|
-
'''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]] ])
|
|
447
|
-
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]] ]])
|
|
448
|
-
bb=np.ascontiguousarray(aaaa,dtype= np.uint16)
|
|
449
|
-
self.cal.SetImg( [ bb])
|
|
450
|
-
bb
|
|
451
|
-
da[284,202]
|
|
452
|
-
'''
|
|
453
|
-
#self.cal.setImgs(self.imgs)
|
|
454
|
-
#self.ccMask=self.cal.getMask()
|
|
455
|
-
|
|
456
|
-
def readCfgStereo(self):
|
|
457
|
-
#self.stereo.readAllCfgs(self.cfgNameStereo)
|
|
458
|
-
self.initDataStereo()
|
|
459
|
-
'''
|
|
460
|
-
try:
|
|
461
|
-
if FlagReadCfg:
|
|
462
|
-
self.disp.readAllCfgs(self.cfgName)
|
|
463
|
-
else:
|
|
464
|
-
self.initData()
|
|
465
|
-
|
|
466
|
-
except Exception as exc:
|
|
467
|
-
#traceback.print_exc()
|
|
468
|
-
#pri.Info.white(str(exc.__cause__).split('\n')[3])
|
|
469
|
-
#pri.Info.white(str(exc.args[0]).split('\n')[3])
|
|
470
|
-
raise exc
|
|
471
|
-
'''
|
|
472
|
-
self.nCams=2
|
|
473
|
-
self.cams=[0, 1]
|
|
474
|
-
self.nImgs=self.stereo.SPIVIn.LastImg+1-self.stereo.SPIVIn.FirstImg
|
|
475
|
-
# the common zone can be changed by using the following variables
|
|
476
|
-
# self.disp.dataProc.xinfZC, self.disp.dataProc.xsupZC ,self.disp.dataProc.yinfZC, self.disp.dataProc.ysupZC
|
|
477
|
-
#eg
|
|
478
|
-
#self.disp.dataProc.xinfZC=-30
|
|
479
|
-
try:
|
|
480
|
-
self.stereo.evalCommonZone()
|
|
481
|
-
|
|
482
|
-
except ValueError as exc:
|
|
483
|
-
pri.Info.white(f"{exc=}, {type(exc)=}")
|
|
484
|
-
#self.signals.textFromStereo.emit(f'{exc}') # todo come comunico con la view
|
|
485
|
-
self.cam=0
|
|
486
|
-
|
|
487
|
-
self.rectZonaCom=self.getZonaComStereo(self.cam)
|
|
488
|
-
|
|
489
|
-
def readCfg(self):
|
|
490
|
-
#self.stereo.readAllCfgs(self.cfgNameStereo)
|
|
491
|
-
try:
|
|
492
|
-
if FlagReadCfg:
|
|
493
|
-
self.disp.readAllCfgs(self.cfgName)
|
|
494
|
-
else:
|
|
495
|
-
self.initData()
|
|
496
|
-
|
|
497
|
-
except Exception as exc:
|
|
498
|
-
#traceback.print_exc()
|
|
499
|
-
#pri.Info.white(str(exc.__cause__).split('\n')[3])
|
|
500
|
-
#pri.Info.white(str(exc.args[0]).split('\n')[3])
|
|
501
|
-
raise exc
|
|
502
|
-
|
|
503
|
-
self.nCams=2
|
|
504
|
-
self.cams=[0, 1]
|
|
505
|
-
self.nImgs=self.disp.SPIVIn.LastImg+1-self.disp.SPIVIn.FirstImg
|
|
506
|
-
# the common zone can be changed by using the following variables
|
|
507
|
-
# self.disp.dataProc.xinfZC, self.disp.dataProc.xsupZC ,self.disp.dataProc.yinfZC, self.disp.dataProc.ysupZC
|
|
508
|
-
#eg
|
|
509
|
-
#self.disp.dataProc.xinfZC=-30
|
|
510
|
-
try:
|
|
511
|
-
#self.stereo.evalCommonZone()
|
|
512
|
-
self.disp.evalCommonZone()
|
|
513
|
-
except ValueError as exc:
|
|
514
|
-
pri.Info.white(f"{exc=}, {type(exc)=}")
|
|
515
|
-
#self.signals.textFromStereo.emit(f'{exc}') # todo come comunico con la view
|
|
516
|
-
self.cam=0
|
|
517
|
-
|
|
518
|
-
self.rectZonaCom=self.getZonaCom(self.cam)
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
def initData(self):
|
|
529
|
-
spiv=self.disp.SPIVIn
|
|
530
|
-
dP=self.disp.dataProc
|
|
531
|
-
dAC=self.disp.dispAvCo
|
|
532
|
-
spiv.nomecal='cal' # Root of calibration constants
|
|
533
|
-
spiv.percorsocal='../Cal/' #Path of calibration constants
|
|
534
|
-
spiv.ImgRoot='disp_cam' # Root input Images
|
|
535
|
-
spiv.InExt='.png' # Extension of the images
|
|
536
|
-
spiv.InDir='../img/' #Path of the images
|
|
537
|
-
spiv.FirstImg=1 # # of first img to be processed
|
|
538
|
-
spiv.LastImg=3 # # of first last to be processed
|
|
539
|
-
spiv.Digit=3 # number of figures i.e. zeros (MAX 10)
|
|
540
|
-
spiv.RigaPart=0 # Starting row
|
|
541
|
-
spiv.ColPart=0 # Starting column
|
|
542
|
-
dP.ImgH=1024 -spiv.RigaPart # Ending row
|
|
543
|
-
dP.ImgW=1280 -spiv.ColPart # Starting row
|
|
544
|
-
spiv.Sfas=3 # Sfasamento sub-immagini (righe a partire dall'origine): 0 per singola img: 1=a,b (finali); 2=_1,_2 (finali); 3=a,b (prima del numero sequenziale
|
|
545
|
-
spiv.FlagImgTau=1 # Img da processare: 0-entrambe; 1-solo la prima; 2-solo la seconda;PARAMETRO IGNORATO SE SFAS=0
|
|
546
|
-
|
|
547
|
-
#Output
|
|
548
|
-
spiv.OutRoot ='disp' # Root of output Files
|
|
549
|
-
spiv.OutDir ='../Cal/' # Output path
|
|
550
|
-
# Process parameters **********************
|
|
551
|
-
dP.FlagInt=57 # Metodo di raddrizzamento: 0=veloce (simp.), 1=quad…….
|
|
552
|
-
dP.FlagZonaCom=0 # Flag per la zona comune: 0=coordinate nel piano oggetto; 1=coord. nel piano img
|
|
553
|
-
spiv.Niter=-5 # Numero di iterazioni
|
|
554
|
-
if (spiv.Niter < 0) :
|
|
555
|
-
spiv.WrtFlag = 1
|
|
556
|
-
spiv.Niter = -spiv.Niter
|
|
557
|
-
else:
|
|
558
|
-
spiv.WrtFlag = 0
|
|
559
|
-
|
|
560
|
-
dAC.HCella=256 # Correlation window Height
|
|
561
|
-
dAC.WCella=256 # Correlation window Width
|
|
562
|
-
dAC.HGrid=128 # Grid distance vertical
|
|
563
|
-
dAC.WGrid=128 # Grid distance horizontal
|
|
564
|
-
dAC.N_NormEpi=40 # Semiwidth in the direction normal to the epipolar line
|
|
565
|
-
dAC.RaggioFiltro=9 # Semiwidth of the filter for the detection of the maximum in the displacement map
|
|
566
|
-
dAC.SogliaCor = 0.6 # Threshold for the determination of point used in the baricentric search of the maximum in the disp map
|
|
567
|
-
#%% Volume ********************************
|
|
568
|
-
dP.xinfZC = -28 # Coordinata x inferiore
|
|
569
|
-
dP.yinfZC = -30 # Coordinata y inferiore
|
|
570
|
-
dP.xsupZC = 20#28 # Coordinata x superiore
|
|
571
|
-
dP.ysupZC = 0#15 # Coordinata y superiore
|
|
572
|
-
# ******************************
|
|
573
|
-
flagReadCalConst=0# if true internal reading
|
|
574
|
-
if flagReadCalConst:
|
|
575
|
-
self.disp.readCalConst()
|
|
576
|
-
else:
|
|
577
|
-
c=0
|
|
578
|
-
cost=[]
|
|
579
|
-
for c in range(2):
|
|
580
|
-
fileName=f'{spiv.percorsocal}{spiv.nomecal}{c}.cal'
|
|
581
|
-
flagCal,numCostCalib,costDum=self.readCalFile(fileName)
|
|
582
|
-
if c==0:
|
|
583
|
-
dP.FlagCal=flagCal
|
|
584
|
-
dP.NumCostCalib=numCostCalib
|
|
585
|
-
else:
|
|
586
|
-
if (dP.FlagCal!=flagCal):
|
|
587
|
-
raise('error the two calibration file are not compatible')
|
|
588
|
-
cost.append(costDum)
|
|
589
|
-
self.disp.setCalConst( flagCal, numCostCalib,cost)
|
|
590
|
-
|
|
591
|
-
flagReadPlaneConst=0# if true internal reading
|
|
592
|
-
if flagReadPlaneConst:
|
|
593
|
-
if self.disp.readPlaneConst()==0:
|
|
594
|
-
pri.Callback.green('readPlaneConst ok')
|
|
595
|
-
else:
|
|
596
|
-
self.disp.vect.PianoLaser[0]=0
|
|
597
|
-
self.disp.vect.PianoLaser[1]=0
|
|
598
|
-
self.disp.vect.PianoLaser[2]=0
|
|
599
|
-
|
|
600
|
-
def initDataStereo(self):
|
|
601
|
-
spiv=self.stereo.SPIVIn
|
|
602
|
-
dP=self.stereo.dataProc
|
|
603
|
-
inPiv=self.stereo.Inp
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
# STEREO CFG file
|
|
608
|
-
# A €£ indicate that the feature is not enabled in the python wrapper
|
|
609
|
-
spiv.nomecal='Cal' # Root of calibration constants
|
|
610
|
-
spiv.NomeCostPiano='disp_1_0.5_0.1_T_1' # Root of disparity plane constants
|
|
611
|
-
spiv.percorsocal='../cal1/' # Path of calibration constants
|
|
612
|
-
spiv.FlagParallel=0 # Type of parallel process 0 horizontal 1 vertical (faster but with less information and mor RAM occupied)
|
|
613
|
-
dP.FlagInt=57 # IS for image reconstruction (only used when FlagRad==0)
|
|
614
|
-
inPiv.FlagRad=1 # 1 internal (in piv) or 0 external de-warping of the images (the latter €£)
|
|
615
|
-
dP.FlagCoordRad=0 # when equal to 0 the de-warping is carried on with the larger resolution (pix/mm)
|
|
616
|
-
# when equal to 1 (2) the x (y) axis resolution is used
|
|
617
|
-
spiv.salvarad=0 # if true and FlagRad is equal to 0 then the dewarped images are saved (€£)
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
# % ********************* Input/Output
|
|
621
|
-
spiv.FirstImg=1 # # of first img to be processed (€£)
|
|
622
|
-
spiv.LastImg=1 # # of first last to be processed (€£)
|
|
623
|
-
spiv.Digit=3 # number of figures i.e. zeros (MAX 10) (€£)
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
spiv.ImgRoot='disp_1_0.5_0.1_T_1_cam' # Root of the input Images (€£)
|
|
627
|
-
spiv.InDir='../img/' # Path of the images (€£)
|
|
628
|
-
spiv.InExt='.png' # Extension of the images (€£)
|
|
629
|
-
spiv.OutRoot ='disp_1_0.5_0.1_T_1' # Root of the output Files (€£)
|
|
630
|
-
spiv.OutDir ='../out1/' # Output path (€£)
|
|
631
|
-
spiv.OutExt ='.plt' # Output extension (€£)
|
|
632
|
-
spiv.OutFlag = 0 # type of output file : 0 binary Tecplot 1 ascii tecplot (€£)
|
|
633
|
-
spiv.WrtFlag = 1 # 0 only mean values are saved 1 all the instantaneous images are written (€£)
|
|
634
|
-
spiv.RigaPart=0 # Starting row (€£)
|
|
635
|
-
spiv.ColPart=0 # Starting Col (€£)
|
|
636
|
-
dP.ImgH=1024 -spiv.RigaPart # Ending row
|
|
637
|
-
dP.ImgW=1280 -spiv.ColPart # Starting Col
|
|
638
|
-
# % *********************** Process parameters
|
|
639
|
-
dP.FlagZonaCom=0 # Flag for common zone should be equal to 0
|
|
640
|
-
# Volume ********************************
|
|
641
|
-
dP.xinfZC = -24 # minimum x world coordinates
|
|
642
|
-
dP.yinfZC = -10 # minimum y world coordinates
|
|
643
|
-
dP.xsupZC = 24 # maximum x world coordinates
|
|
644
|
-
dP.ysupZC = 5 # maximum y world coordinates
|
|
645
|
-
spiv.FlagRis=0 # 0 displacements in m/s 1 in pixels
|
|
646
|
-
spiv.dt=1000 # time separation. If the displacements in mm are needed use 1000 (and 0 for the previous parameter)
|
|
647
|
-
spiv.Sfas=3 # in case of images in a single file the distance between images. Normally define the name (€£)
|
|
648
|
-
# 1=a,b (after number); 2=_1,_2 (after number); 3=a,b (before number)
|
|
649
|
-
# % Output
|
|
650
|
-
spiv.FlagRotImg=0 # Rotation of the img 0=no rot 1=90°, 2=180° 3= 270° clockwise (£€)
|
|
651
|
-
inPiv.FlagLog=9 # 0=no 1=video 2=log 3=video e log 4=Log short 5=video e log short (£€)
|
|
652
|
-
spiv.StatFlag =0 # stat on: 1 all the vectors 0 only the good ones
|
|
653
|
-
spiv.nomecfgPiv ='StereoProcess.cfg' # name of the cfg file for PIV
|
|
654
|
-
|
|
655
|
-
# ******************************
|
|
656
|
-
flagReadCalConst=0# if true internal reading
|
|
657
|
-
if flagReadCalConst:
|
|
658
|
-
self.stereo.readCalConst()
|
|
659
|
-
else:
|
|
660
|
-
c=0
|
|
661
|
-
cost=[]
|
|
662
|
-
for c in range(2):
|
|
663
|
-
fileName=f'{spiv.percorsocal}{spiv.nomecal}{c}.cal'
|
|
664
|
-
flagCal,numCostCalib,costDum=self.readCalFile(fileName)
|
|
665
|
-
if c==0:
|
|
666
|
-
dP.FlagCal=flagCal
|
|
667
|
-
dP.NumCostCalib=numCostCalib
|
|
668
|
-
else:
|
|
669
|
-
if (dP.FlagCal!=flagCal):
|
|
670
|
-
raise('error the two calibration file are not compatible')
|
|
671
|
-
cost.append(costDum)
|
|
672
|
-
self.stereo.setCalConst( flagCal, numCostCalib,cost)
|
|
673
|
-
|
|
674
|
-
flagReadPlaneConst=1# if true internal reading
|
|
675
|
-
if flagReadPlaneConst:
|
|
676
|
-
if self.stereo.readPlaneConst()==0:
|
|
677
|
-
pri.Callback.green('readPlaneConst ok')
|
|
678
|
-
else:
|
|
679
|
-
self.stereo.vect.PianoLaser[0]=0
|
|
680
|
-
self.stereo.vect.PianoLaser[1]=0
|
|
681
|
-
self.stereo.vect.PianoLaser[2]=0
|
|
682
|
-
#piv *******************************************************************************
|
|
683
|
-
|
|
684
|
-
self.stereo.readCfgProc(spiv.nomecfgPiv)
|
|
685
|
-
|