0

I am trying to use the camera on https://robotbenchmark.net/ for the Highway Driving, but I have some difficulties understanding the manual of the camera and object recognition. I have been able to recognize some objects as seen below with camera.getRecognitionObjects() but I can't understand how can I get the id and distance or position of a specific object. What I am trying to accomplice is to recognize the lines of the road so i can align the car to the road. Thanks in advance.

   [highway_driving] 3
   [highway_driving] [<controller.CameraRecognitionObject; proxy of <Swig Object of type 'webots::CameraRecognitionObject 
*' at 0x7fb72c2233c0> >, <controller.CameraRecognitionObject; 
    proxy of <Swig Object of type 'webots::CameraRecognitionObject *' at 0x7fb72c2233f0> >, 
    <controller.CameraRecognitionObject; proxy of <Swig Object of type 'webots::CameraRecognitionObject *' at 0x7fb72c223420> >]
Costas Revi
  • 3
  • 1
  • 2

1 Answers1

1

Here is the definition of the cameraRecognitionObject class (https://www.cyberbotics.com/doc/reference/camera?tab-language=python#wb_camera_has_recognition)

from controller import CameraRecognitionObject

class CameraRecognitionObject:
    def get_id(self):
    def get_position(self):
    def get_orientation(self):
    def get_size(self):
    def get_position_on_image(self):
    def get_size_on_image(self):
    def get_number_of_colors(self):
    def get_colors(self):
    def get_model(self):

Therefore, once you call the Camera.getRecognitionObjects you will get an array of objects and you can easily get the id and position (compared to the camera):

firstObject = Camera.getRecognitionObjects()[0]
id = firstObject.get_id()
position = firstObject.get_position()
David Mansolino
  • 1,713
  • 7
  • 13