DrivePX2开发指导0.0 Driveworks API 简介


1.  dwInitialize 

dwStatus dwInitialize(dwContextHandle_t *f_context_p, dwVersion f_header_version, const dwContextParameters *f_params_p);

创建并初始化一个SDK环境,该环境会被用于SDK module的初始化。

/**
 * Creates and initializes an SDK context. The context is required
 * for initialization of the SDK modules.
 *
 * @note The logger remains under the callee's ownership.
 *
 * @param[out] context A pointer to the context handler is returned here.
 * @param[in] header_version Specifies current driveworks API version
 *            (usually DW_VERSION).
 * @param[in] params A pointer with a set of parameters to create the SDK.
 *            Can be NULL for a default set of parameters.
 *
 * @return DW_INVALID_VERSION - If provided, version does not match the version of the library. <br>
 *         DW_INVALID_ARGUMENT - If provided, context pointer is null. <br>
 *         DW_SUCCESS
 *
 */
DW_API_PUBLIC
dwStatus dwInitialize(dwContextHandle_t *f_context_p, dwVersion f_header_version, const dwContextParameters *f_params_p);

2.  dwSAL_initialize

dwStatus dwSAL_initialize(dwSALHandle_t *f_sal_p, dwContextHandle_t f_context);

使用 f_context 创建并初始化一个SAL模块

/**
 * @brief Creates and initializes a SAL module.
 * This method loads all available sensor drivers.
 *
 * @param[out] sal A pointer to the sal handle will be returned here.
 * @param[in] context Specifies the handle to the context under which the SAL module is created.
 *
 * @return DW_INVALID_ARGUMENT - if pointer to the SAL handle is NULL. <br>
 *         DW_INVALID_HANDLE - if provided context handle is invalid. <br>
 *         DW_SUCCESS
 */
DW_API_PUBLIC
dwStatus dwSAL_initialize(dwSALHandle_t *f_sal_p, dwContextHandle_t f_context);

3. dwSAL_createSensor

dwStatus dwSAL_createSensor(dwSensorHandle_t *sensor, dwSensorParams params, dwSALHandle_t sal);

使用sal和params参数创建一个传感器,使用该函数创建的传感器必须使用`dwSAL_releaseSensor()`函数对其进行释放。

/**
 * Creates a new sensor managed by the SAL module with the given parameters.
 * The created sensor has to be released using the `dwSAL_releaseSensor()` method.
 *
 * @note This returned sensor handle must be released using the `dwSAL_releaseSensor()` method.
 *
 * @param[out] sensor A pointer to sensor handle that became valid after creation.
 * @param[in] params Specifies the parameters for sensor creation.
 * @param[in] sal Specifies the handle to the SAL module that will manage the sensor.
 *
 * @return DW_INVALID_ARGUMENT - if pointer to the sensor is NULL. <br>
 *         DW_INVALID_HANDLE - if provided SAL handle is invalid. <br>
 *         DW_SAL_NO_DRIVER_FOUND - if provided protocol name is unknown. <br>
 *         DW_SAL_SENSOR_ERROR - if a non recoverable error happens during sensor creation. For a virtual
 *                               sensor which is reading from a file it could be file I/O error. <br>
 *         DW_SUCCESS
 *
 */
DW_API_PUBLIC
dwStatus dwSAL_createSensor(dwSensorHandle_t *sensor, dwSensorParams params, dwSALHandle_t sal);

4. dwSensorCamera_getSensorProperties

dwStatus dwSensorCamera_getSensorProperties(dwCameraProperties *properties,
                                            dwSensorHandle_t sensor);

获取摄像头传感器的信息,返回的属性值为:

typedef struct dwCameraProperties {
    float32_t framerate;     /*!< Framerate in Hz */
    uint32_t siblings;       /*!< Number of sibling frames */
    int32_t outputTypes;     /*!< Or'ed list of available `dwCameraOutputType` */
    dwCameraType cameraType; /*!< Type of the camera */
    dwVector2ui resolution;  /*!< Physical resolution of the camera sensor */
    dwCameraRawFormat rawFormat; /*!< Raw bayern pattern*/
} dwCameraProperties;
/**
* Gets information about the camera sensor.
*
* @param[out] properties A pointer to the properties of the camera.
* @param[in] sensor Sensor handle of the camera sensor previously created with
*            dwSAL_createSensor().
*/
DW_API_PUBLIC
dwStatus dwSensorCamera_getSensorProperties(dwCameraProperties *properties,
                                            dwSensorHandle_t sensor);

5. dwSensorCamera_getImageProperties

dwStatus dwSensorCamera_getImageProperties(dwImageProperties *imageProperties,
                                           dwCameraOutputType type,
                                           dwSensorHandle_t sensor);

从传感器sensor中获取图像信息,返回值imageProperties的类型为:

typedef struct dwImageProperties {
    /// Specifies the type of image.
    dwImageType type;
    /// Specifies the width of the image in pixels.
    uint32_t width;
    /// Specifies the height of the image in pixels.
    uint32_t height;
    /// Specifies the pixel format of the image.
    dwImagePixelFormat pxlFormat;
    /// Specifies the pixel type of the image.
    dwTrivialDataType pxlType;
    /// Specifies the plane count of the image. For interleaved images the plane count is 1.
    uint32_t planeCount;

    /// additional meta information stored with the image. Not all images might provide it
    dwImageMetaData meta;
} dwImageProperties;
/**
* Gets information about the image properties for a given `dwCameraOutputType`.
*
* @param[out] imageProperties A pointer to image properties of the frames captured by the camera.
* @param[in] type Format of the image to get. This is an OR'ed list of dwCameraOutputType.
* @param[in] sensor Sensor handle of the camera sensor previously created with
*            dwSAL_createSensor().
*
* @note The dimensions of the returned properties corresponds to the dimension of the image returned through
*       `dwSensorCamera_getImage*` methods. However the dimensions might be different depending on the provided `type`.
*/
DW_API_PUBLIC
dwStatus dwSensorCamera_getImageProperties(dwImageProperties *imageProperties,
                                           dwCameraOutputType type,
                                           dwSensorHandle_t sensor);

6. dwSensor_start

dwStatus dwSensor_start(dwSensorHandle_t sensor);

启动前面dwSAL_createSensor函数创建的传感器,传感器成功启动之后就可以使用对应的传感器共有或特有的方法来访问传感器数据。

/**
 * Starts the sensor previously successfully created with `dwSAL_createSensor()`.
 * After a sensor is successfully started, new sensor data can be acquired using
 * corresponding sensor methods.
 *
 * @note This method might spawn a thread, depending on the sensor implementation.
 *       It is, however, guaranteed that the data returned by the sensor is valid
 *       in the calling thread. For example, a CUDA camera image is created in the same
 *       CUDA context as the callee.
 *
 * @param[in] sensor Specifies the sensor handle of the sensor previously created with `dwSAL_createSensor()`.
 *
 * @return DW_CUDA_ERROR - if the underlying sensor driver had a CUDA error. <br>
 *         DW_NVMEDIA_ERROR - if underlying sensor driver had an NvMedia error. <br>
 *         DW_INVALID_HANDLE - if given handle is not valid. <br>
 *         DW_END_OF_STREAM - if end of stream reached. <br>
 *         DW_SUCCESS
 *
**/
DW_API_PUBLIC
dwStatus dwSensor_start(dwSensorHandle_t sensor);

7. dwRenderer_initialize

dwStatus dwRenderer_initialize(dwRendererHandle_t *renderer, dwContextHandle_t context);

渲染器初始化函数,创建各种图形资源,包括着色器、顶点数据和纹理,必须使用一个有效的OpenGL环境在一个线程上初始化,当多个渲染器共存时,他们之间的资源并不共享。

/**
 * @brief Initializes a Renderer. This initialization implies creation of various graphics resources
 * including shaders, vertex data, and textures. It must be initialized on
 * a thread with a valid current OpenGL context. While multiple renderers may coexist, resources
 * among them are not shared.
 *
 * @param[out] renderer A pointer to an initialized renderer object.
 * @param[in] context Specifies a handle to the context under which it is created.
 *
 * @return DW_INVALID_ARGUMENT, DW_FAILURE, DW_SUCCESS
 */
DW_API_PUBLIC dwStatus dwRenderer_initialize(dwRendererHandle_t *renderer, dwContextHandle_t context);

设置渲染的染色,线宽和渲染区域:

dwRenderer_setColor(l_boxColor, f_renderer);
dwRenderer_setLineWidth(2.0f, f_renderer);
dwRenderer_setRect(f_screenRect, f_renderer);

8. dwRigConfiguration_initializeFromFile

dwStatus dwRigConfiguration_initializeFromFile(dwRigConfigurationHandle_t *obj,
                                               dwContextHandle_t ctx,
                                               const char *configurationFile);

初始化rig配置模块。

/**
* Initializes the Rig Configuration module.
*
* @param[out] obj A pointer to the Rig Configuration handle for the created module.
* @param[in] ctx Specifies the handler to the context under which the Rigconfiguration module is created.
* @param[in] configurationFile A pointer to the XML file that contains the rig configuration. Typically produced by the
* DriveWorks calibration tool.
*
* @return DW_INVALID_ARGUMENT, DW_INVALID_HANDLE, DW_FILE_NOT_FOUND, DW_INTERNAL_ERROR, DW_SUCCESS
*/
DW_API_PUBLIC dwStatus dwRigConfiguration_initializeFromFile(dwRigConfigurationHandle_t *obj,
                                                             dwContextHandle_t ctx,
                                                             const char *configurationFile);

 

 

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值