Skip to content
Snippets Groups Projects
Commit 3092299c authored by Gaël Cartier-Michaud's avatar Gaël Cartier-Michaud
Browse files

simplify harvest callback

parent 7f9895d1
No related branches found
No related tags found
No related merge requests found
# Configuration pour le laptop
detector:
harvest : False
frame_before_exit : 30
homography_path : './demo/homography_matrix.csv'
cam :
dev_num : 2
img_sz : [1280, 720]
pix_format : 'GREY'
brightness : 15
model :
path : './demo/model/model_demo.pt'
img_sz : [1280,1280]
show : True
verbose : False
ip :
detectorIP : '192.168.125.42'
armIP : '192.168.125.1'
port : 50000
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
detector: detector:
harvest : True harvest : True
frame_before_exit : 30 frame_before_exit : 25
homography_path : './demo/homography_matrix.csv' homography_path : './demo/homography_matrix.csv'
cam : cam :
......
...@@ -27,25 +27,25 @@ class Detector : ...@@ -27,25 +27,25 @@ class Detector :
return config return config
def __harvestCallback( self, predictor ) : def __harvestCallback( self, predictor ) :
nothing = True if not self.harvest_job.is_alive() :
classes, coordinates = predictor.results[0].boxes.cls.cpu().numpy(), predictor.results[0].cpu().boxes.xywh.numpy() nothing = True
for cl, coord in zip( classes, coordinates ) : classes, coordinates = predictor.results[0].boxes.cls.cpu().numpy(), predictor.results[0].cpu().boxes.xywh.numpy()
arm_coord = self.myArm.point_projection( (coord[0], coord[1]) ) for cl, coord in zip( classes, coordinates ) :
if not self.myArm.coordReachable( arm_coord ) or self.myModel.labelNum2Str( cl ) == 'hand' : pass arm_coord = self.myArm.point_projection( (coord[0], coord[1]) )
else : if not self.myArm.coordReachable( arm_coord ) or self.myModel.labelNum2Str( cl ) == 'hand' : pass
nothing = False else :
if not self.harvest_job.is_alive() : nothing = False
print( "\n{} : x: {}, y: {}".format( self.myModel.labelNum2Str(cl), arm_coord[0], arm_coord[1] ) ) print( "\n{} : x: {}, y: {}".format( self.myModel.labelNum2Str(cl), arm_coord[0], arm_coord[1] ) )
self.myArm.target = ( arm_coord[0], arm_coord[1], cl ) self.myArm.target = ( arm_coord[0], arm_coord[1], cl )
self.startHarvestJob() self.startHarvestJob()
break break
if nothing : self.nothing_counter += 1 if nothing : self.nothing_counter += 1
if self.isHarvestEnd() : if self.isHarvestEnd() :
if not self.harvest_job.is_alive() : if not self.harvest_job.is_alive() :
print( "\n##### THE END #####\n") print( "\n##### THE END #####\n")
self.myArm.target = ( 0, 0, self.myArm.end_value ) self.myArm.target = ( 0, 0, self.myArm.end_value )
self.startHarvestJob() self.startHarvestJob()
self.exit_status = True self.exit_status = True
def startHarvestJob( self ) : def startHarvestJob( self ) :
self.harvest_job = Thread( target = self.myArm.harvest, args = ( self.myArm.target, ) ) self.harvest_job = Thread( target = self.myArm.harvest, args = ( self.myArm.target, ) )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment