如何在Webot上使用相机识别对象

时间:2020-02-06 09:40:39

标签: webots

我正在尝试将https://robotbenchmark.net/上的相机用于高速公路驾驶,但是在理解相机和物体识别的手册方面有些困难。我已经能够使用camera.getRecognitionObjects()识别出一些对象,如下所示,但是我不明白如何获取特定对象的ID,距离或位置。我要帮忙的是识别道路的轮廓,以便我可以将汽车对准道路。 预先感谢。

   [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> >]

1 个答案:

答案 0 :(得分:1)

这是cameraRecognitionObject类(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):

因此,一旦调用Camera.getRecognitionObjects,您将获得一个对象数组,并且可以轻松获取id和位置(与相机相比):

firstObject = Camera.getRecognitionObjects()[0]
id = firstObject.get_id()
position = firstObject.get_position()