@@ -5,11 +5,20 @@ def process_load(npyImage, objSettings):
5
5
objCommon ['intHeight' ] = npyImage .shape [0 ]
6
6
7
7
tenImage = torch .FloatTensor (numpy .ascontiguousarray (npyImage .transpose (2 , 0 , 1 )[None , :, :, :].astype (numpy .float32 ) * (1.0 / 255.0 ))).cuda ()
8
- tenDisparity = disparity_estimation (tenImage )
9
- tenDisparity = disparity_adjustment (tenImage , tenDisparity )
10
- tenDisparity = disparity_refinement (tenImage , tenDisparity )
11
- tenDisparity = tenDisparity / tenDisparity .max () * objCommon ['fltBaseline' ]
12
- tenDepth = (objCommon ['fltFocal' ] * objCommon ['fltBaseline' ]) / (tenDisparity + 0.0000001 )
8
+
9
+ if 'npyDepth' not in objSettings :
10
+ tenDisparity = disparity_estimation (tenImage )
11
+ tenDisparity = disparity_adjustment (tenImage , tenDisparity )
12
+ tenDisparity = disparity_refinement (tenImage , tenDisparity )
13
+ tenDisparity = tenDisparity / tenDisparity .max () * objCommon ['fltBaseline' ]
14
+ tenDepth = (objCommon ['fltFocal' ] * objCommon ['fltBaseline' ]) / (tenDisparity + 0.0000001 )
15
+
16
+ elif 'npyDepth' in objSettings :
17
+ tenDepth = torch .FloatTensor (numpy .ascontiguousarray (numpy .atleast_3d (objSettings ['npyDepth' ]).astype (numpy .float32 ).transpose (2 , 0 , 1 )[None , :, :, :])).cuda ()
18
+ tenDisparity = (objCommon ['fltFocal' ] * objCommon ['fltBaseline' ]) / (tenDepth + 0.0000001 )
19
+
20
+ # end
21
+
13
22
tenValid = (spatial_filter (tenDisparity / tenDisparity .max (), 'laplacian' ).abs () < 0.03 ).float ()
14
23
tenPoints = depth_to_points (tenDepth * tenValid , objCommon ['fltFocal' ])
15
24
tenUnaltered = depth_to_points (tenDepth , objCommon ['fltFocal' ])
@@ -61,7 +70,7 @@ def process_shift(objSettings):
61
70
fltShiftY = fltClosestFromY - fltClosestToY
62
71
fltShiftZ = objSettings ['fltDepthTo' ] - objSettings ['fltDepthFrom' ]
63
72
64
- tenShift = torch .FloatTensor ([ fltShiftX , fltShiftY , fltShiftZ ]). view ( 1 , 3 , 1 ). cuda ( )
73
+ tenShift = torch .tensor ( data = [[[ fltShiftX ], [ fltShiftY ], [ fltShiftZ ]]], dtype = torch . float32 , device = torch . device ( 'cuda' ) )
65
74
66
75
tenPoints = objSettings ['tenPoints' ].clone ()
67
76
@@ -140,7 +149,7 @@ def process_kenburns(objSettings):
140
149
objCommon ['tenInpaDepth' ] = objCommon ['tenRawDepth' ].view (1 , 1 , - 1 )
141
150
objCommon ['tenInpaPoints' ] = objCommon ['tenRawPoints' ].view (1 , 3 , - 1 )
142
151
143
- for fltStep in [ 0.0 , 1.0 ]:
152
+ for fltStep in [ 1.0 ]:
144
153
fltFrom = 1.0 - fltStep
145
154
fltTo = 1.0 - fltFrom
146
155
0 commit comments