DriveWorks SDK Reference
4.0.0 Release
For Test and Development only

src/dw/sensors/camera/docs/usecase1.md
Go to the documentation of this file.
1 # Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved.
2 
3 @page camera_usecase1 Camera Workflow
4 
5 Initialize the Sensor Abstraction Layer
6 
7 ```{.cpp}
8 dwSAL_initialize(&sal, sdk);
9 ```
10 
11 Initialize the parameter string for a camera sensor, in this case we request a processed image (yuv), a camera
12 ar0231-rccb with sf3324 module and BAE exposure type at group C. We specify a gmsl protocol and create the sensor
13 
14 ```{.cpp}
15  dwSensor cameraSensor = DW_NULL_HANDLE;
16  dwSensorParams params;
17  params.parameters = "output-format=yuv,camera-type=ar0231-rccb-bae-sf3324,camera-group=c";
18  params.protocol = "camera.gmsl";
19  dwSAL_createSensor(&cameraSensor, params, sal);
20 ```
21 
22 after starting the sensor, the camera will start acquiring frames
23 
24 ```{.cpp}
25 dwSensor_start(...);
26 
27 while(loop) {
28 ```
29 
30 We read a frame, which is stored as a `::dwCameraFrameHandle_t` and specify a timeout value in microseconds
31 
32 ```{.cpp}
33 ...
34  dwCameraFrameHandle_t frameHandle = DW_NULL_HANDLE;
35  dwTime_t timeout = 33000;
36  dwSensorCamera_readFrame(&frameHandle, timeout, cameraSensor);
37 ...
38 ```
39 
40 many outputs can be return after reading, the only extra cost are eventual streaming and conversion, depending
41 on the output chosen. Also the output type is influenced by how we created the camera. Since we specified
42 processed image (yuv), we can request a processed image as output. In order to know what properties such an image has,
43 it is possible to call `dwSensorCamera_getImageProperties()`
44 with `::dwCameraOutputType` equal to `::DW_CAMERA_OUTPUT_NATIVE_PROCESSED`.
45 
46 ```{.cpp}
47 ...
48  dwImageHandle_t imageNative;
49  dwSensorCamera_getImage(&imageNative, DW_CAMERA_IMAGE_OUTPUT_NATIVE_PROCESSED,...);
50  dwImageHandle_t imageCUDA_RGBA;
51  dwSensorCamera_getImage(&imageCUDA_RGBA, DW_CAMERA_IMAGE_OUTPUT_CUDA_RGBA,...);
52 
53  // CODE: use imageNative (maybe send to serializer)
54  // CODE: use imageCUDA_RGBA
55 ...
56 ```
57 
58 return frames to the fifo
59 
60 ```{.cpp}
61 ...
62  dwSensorCamera_returnFrame(...);
63 }
64 ```
65 
66 stop the sensor and release
67 
68 ```{.cpp}
69 dwSensor_stop(...);
70 dwSAL_releaseSensor(&cameraSensor);
71 ```
72 
73 For more details see:
74 - @ref dwx_camera_sample