This function returns the x position of the object detected. You can specify the object for which the value is needed. The position is mapped with the stage coordinates.
The example demonstrates how to run an object detection on the stage and show all the objects with confidence.
Code
sprite = Sprite('Square Box')
obj = ObjectDetection()
obj.disablebox()
obj.setthreshold(0.5)
obj.analysestage()
sprite.gotoxy(0, 0)
sprite.setsize(100)
sprite.say(str(obj.count()) + " Object Detected", 2)
for object in range(1, obj.count() + 1):
sprite.setx(obj.x(object))
sprite.sety(obj.y(object))
sprite.setsize(obj.width(object))
sprite.say(obj.classname(object) + " with " + str(obj.confidence(object)), 2)
Output
- Detection at 0.3
- Detection at 0.5
- Detection at 0.8
Read More