10
10
import sys
11
11
import os
12
12
sys .path .append (os .path .dirname (os .path .dirname (os .path .abspath (__file__ ))))
13
- from utils import getCameraFromInfo
13
+ from utils import getCameraFromInfo , drawSegmentationImage
14
14
15
15
def calcDistance (point_1 , point_2 ):
16
16
return pow (pow (point_1 [0 ] - point_2 [0 ], 2 ) + pow (point_1 [1 ] - point_2 [1 ], 2 ), 0.5 )
@@ -33,6 +33,11 @@ def __init__(self, index):
33
33
#cv2.imwrite('dump/alpha_0.5.png', np.zeros(self.depth[:, :, 0].shape).astype(np.uint8))
34
34
self .segmentation = np .load ('dump/' + str (index ) + '_segmentation.npy' )
35
35
36
+ #print(self.segmentation.shape)
37
+ self .segmentation [self .segmentation == - 1 ] = 10
38
+ cv2 .imwrite ('dump/2_segmentation.png' , drawSegmentationImage (self .segmentation , blackIndex = 10 ))
39
+ exit (1 )
40
+
36
41
width = 640
37
42
height = 480
38
43
self .depth = cv2 .resize (self .depth , (width , height ))
@@ -444,3 +449,45 @@ def calcHorizontalPlanes(self):
444
449
445
450
def getHorizontalPlanes (self ):
446
451
return self .gravityDirection , self .horizontalPlanes
452
+
453
+ def getHolePos (self ):
454
+ floorPlaneIndex = 2
455
+ closePoint = np .array ([0. , 1.22 , - 0.2 ])
456
+ plane = self .planes [floorPlaneIndex ]
457
+ planeD = np .linalg .norm (plane )
458
+ planeNormal = plane / planeD
459
+ distance = planeD - np .dot (planeNormal , closePoint )
460
+ distance *= 0.99
461
+ holePos = closePoint + planeNormal * distance
462
+
463
+ H = P = R = 0
464
+ H = - 90 + np .rad2deg (np .arctan2 (planeNormal [1 ], planeNormal [0 ]))
465
+ #P = 90 - np.rad2deg(np.arccos(np.abs(planeNormal[2])))
466
+ P = - 90 + np .rad2deg (np .arccos (np .abs (planeNormal [2 ])))
467
+ #print(H, P, R)
468
+ return holePos , np .array ([H , P , R ])
469
+
470
+
471
+ def getPortalPos (self ):
472
+ wallPlaneIndex = 1
473
+ closePoint_1 = np .array ([0.5 , 1.35 , - 0.5 ])
474
+ closePoint_2 = np .array ([- 0.4 , 1 , 0.19 ])
475
+ plane = self .planes [wallPlaneIndex ]
476
+ planeD = np .linalg .norm (plane )
477
+ planeNormal = plane / planeD
478
+
479
+ distance = planeD - np .dot (planeNormal , closePoint_1 )
480
+ distance *= 0.95
481
+ portalPos_1 = closePoint_1 + planeNormal * distance
482
+
483
+ distance = planeD - np .dot (planeNormal , closePoint_2 )
484
+ distance *= 0.95
485
+ portalPos_2 = closePoint_2 + planeNormal * distance
486
+
487
+ H = P = R = 0
488
+ H = - 90 + np .rad2deg (np .arctan2 (planeNormal [1 ], planeNormal [0 ]))
489
+ #P = 90 - np.rad2deg(np.arccos(np.abs(planeNormal[2])))
490
+ P = - 90 + np .rad2deg (np .arccos (- np .abs (planeNormal [2 ])))
491
+ #print(H, P, R)
492
+ return portalPos_1 , np .array ([H , P , R ]), portalPos_2 , np .array ([H , P , R ]), planeNormal
493
+
0 commit comments