@@ -93,6 +93,7 @@ class ArduinoObjectDetection {
9393 ) ;
9494 } ) ;
9595
96+ // Update person detection for backward compatibility
9697 const personDetected = this . detectedObjects . some ( detectionObject =>
9798 detectionObject . label === MODEL_LABELS . PERSON
9899 ) ;
@@ -115,11 +116,17 @@ ArduinoObjectDetection.prototype.getInfo = function() {
115116 blockIconURI : iconURI ,
116117 blocks : [
117118 {
118- opcode : "whenPersonDetected " ,
119+ opcode : "whenObjectDetected " ,
119120 blockType : BlockType . HAT ,
120- text : "when person detected" ,
121- func : "whenPersonDetected" ,
122- arguments : { } ,
121+ text : "when [OBJECT] detected" ,
122+ func : "whenObjectDetected" ,
123+ arguments : {
124+ OBJECT : {
125+ type : ArgumentType . STRING ,
126+ menu : "modelsLabels" ,
127+ defaultValue : MODEL_LABELS . PERSON ,
128+ } ,
129+ } ,
123130 } ,
124131 {
125132 opcode : "startDetectionLoop" ,
@@ -205,8 +212,11 @@ ArduinoObjectDetection.prototype._loop = function() {
205212 // automatically when the detection_result event is received
206213} ;
207214
208- ArduinoObjectDetection . prototype . whenPersonDetected = function ( args ) {
209- return this . isPersonDetected ( ) ;
215+ ArduinoObjectDetection . prototype . whenObjectDetected = function ( args ) {
216+ const objectLabel = args . OBJECT ;
217+ return this . detectedObjects . some ( detectionObject =>
218+ detectionObject . label === objectLabel
219+ ) ;
210220} ;
211221
212222ArduinoObjectDetection . prototype . isPersonDetected = function ( args ) {
0 commit comments