@@ -32,7 +32,7 @@ def OnTask(task:Task):
3232 done = True
3333 elif task .Type == "DetectCalibrationCard" :
3434 if task .State == "Completed" :
35- print ('Calibration Card Detected ' )
35+ print ('Calibration Card Detection Started ' )
3636 elif task .State == "Failed" :
3737 print ('Calibration Card Detection Failed:' , task .Error )
3838 done = True
@@ -51,15 +51,24 @@ def OnBuffer(bufferObject, buffer:bytes):
5151 if cornersTotal == 0 :
5252 cardWidth = calibrationCard .size [0 ]
5353 cardHeight = calibrationCard .size [1 ]
54- cornersTotal = (cardWidth - 1 ) * (cardHeight - 1 )
54+ if cardWidth == 0 or cardHeight == 0 :
55+ return ;
56+ cornersTotal = int ((cardWidth - 1 ) * (cardHeight - 1 ))
5557
56- detectedCorners = int (len (calibrationCard .corners ) / 2 )
57- # Camera 0
58- if bufferObject .Index == 0 :
59- cornersDetected_0 = detectedCorners
60- # Camera 1
58+ if calibrationCard .corners is not None :
59+ detectedCorners = calibrationCard .corners
60+ detectedCorners = int (len (detectedCorners ) / 2 )
61+ # Camera 0
62+ if bufferObject .Index == 0 :
63+ cornersDetected_0 = detectedCorners
64+ # Camera 1
65+ else :
66+ cornersDetected_1 = detectedCorners
6167 else :
62- cornersDetected_1 = detectedCorners
68+ if bufferObject .Index == 0 :
69+ cornersDetected_0 = 0
70+ else :
71+ cornersDetected_1 = 0
6372
6473 # No calibration card in the descriptor
6574 else :
@@ -74,23 +83,27 @@ def OnBuffer(bufferObject, buffer:bytes):
7483 scanner = Scanner (OnTask = OnTask , OnMessage = None , OnBuffer = OnBuffer )
7584 scanner .Connect ("ws://matterandform.local:8081" )
7685
77- # Start the video
78- scanner .start_video ()
86+ # # Start the video
87+ # scanner.start_video()
7988
80- # Detect the calibration card
81- print ('******* Detecting the calibration card' )
82- scanner .detect_calibration_card (3 ) # left camera only, 2 = Right camera only, 3 = Both cameras
89+ # # Detect the calibration card
90+ # print('******* Detecting the calibration card')
91+ # scanner.detect_calibration_card(3) # left camera only, 2 = Right camera only, 3 = Both cameras
8392
84- # Wait for the calibration card to be detected
85- while cornersTotal == 0 :
86- time .sleep (0.1 )
93+ # # Wait for the calibration card to be detected
94+ # print('Waiting for the calibration card to be detected')
95+ # timeout = time.time() + 10 # 10 seconds from now
96+ # while cornersTotal == 0 and time.time() < timeout:
97+ # time.sleep(0.1)
98+ # if cornersTotal == 0:
99+ # print("Timeout: Calibration card not detected within 10 seconds")
87100
88- # Detect the calibration card for 5sec
89- time .sleep (5 )
101+ # # Detect the calibration card for 5sec
102+ # time.sleep(5)
90103
91- # Stop the video
92- scanner .detect_calibration_card (0 ) # Stop the detection
93- scanner .stop_video ()
104+ # # Stop the video
105+ # scanner.detect_calibration_card(0) # Stop the detection
106+ # scanner.stop_video()
94107
95108 # Calibration the turntable
96109 print ('\n ******* Calibrating the turntable' )
0 commit comments