-
Notifications
You must be signed in to change notification settings - Fork 8
Using the SDK: CPP
At this stage the camera has not been discovered. Note, these is no need to manually reset the camera as the SDK does so if needed.
This example assumes that the first camera discovered will be used.
System system;
std::vector<std::shared_ptr<Camera>> cameras;
status = system.getCameraList(cameras);
if (status != Status::OK || cameras.empty()) {
LOG(WARNING) << "No cameras found";
return 0;
}
auto camera = cameras.front();
The callback is to intercept interrupts from the ADSD3500. Interrupts from the ADSD3500 report ADSD3500 interrupts but also the imager interrupts to the ADSD3500.
// Registering a callback to be executed when ADSD3500 issues an interrupt
std::shared_ptr<DepthSensorInterface> sensor = camera->getSensor();
aditof::SensorInterruptCallback callback = [](Adsd3500Status status) {
LOG(INFO) << "Running the callback for which the status of ADSD3500 "
"has been "
"forwarded. ADSD3500 status = "
<< status;
};
Status registerCbStatus =
sensor->adsd3500_register_interrupt_callback(callback);
if (status != Status::OK) {
LOG(WARNING) << "Could not register callback";
}
The next stage is to initialize the camera. The user can provide a configuration JSON file to initialize the system: SDK and ADSD3500. The configuration JSON file is covered in the Wiki.
if (!configFile.empty()) {
status = camera->initialize(configFile);
} else {
status = camera->initialize();
}
if (status != Status::OK) {
LOG(ERROR) << "Could not initialize camera!";
return 0;
}
At this point the user is ready to finalize configuration before starting streaming.
- getDetails is used to retrieved information about the camera. You can see the CameraDetails structure here.
- getAvailableModes is used to get the list of modes supported by the device.
- Where for example for ADCAM Crosby mode 0 is short range mega-pixel, mode 1 is long range mega-pixel, mode 2 is short range quarter mega-pixel and mode 3 is long range quarter mega-pixel. Additional modes may be available and modes differ depending on the module type.
- setMode is used to selected a mode to use.
- Only after set mode should additional tailoring such setFrameRate should be used.
aditof::CameraDetails cameraDetails;
camera->getDetails(cameraDetails);
std::vector<uint8_t> availableModes;
camera->getAvailableModes(availableModes);
if (availableModes.empty()) {
std::cout << "no mode available!";
return 0;
}
status = camera->setMode(mode);
if (status != Status::OK) {
LOG(ERROR) << "Could not set camera mode!";
return 0;
}
To receive frames:
- Start the camera.
- Request frames.
- At this point do not send command to the camera. It may interrupt frame reception. Instead rely on the callback to indicate problems upstream.
- Frames are being brought into the SDK independently of the requestFrame call. requestFrame pulls processed frames for internal SDK FIFOs.
- Stop the camera.
status = camera->start();
aditof::Frame frame;
status = camera->requestFrame(&frame);
if (status != Status::OK) {
LOG(ERROR) << "Could not request frame!";
return 0;
} else {
LOG(INFO) << "Successfully requested frame!";
}
# See the section ****Getting Data from a Frame Class Instance**** on how to extract data from the frame instance.
status = camera->stop();
if (status != Status::OK) {
LOG(ERROR) << "Could not stop the camera!";
return 0;
}
# This assumes _frame_ was populated from the requestFrame operation.
# Get the meta data for the Frame class instance: frame
Metadata metadata;
status = frame.getMetadataStruct(metadata);
if (status != Status::OK) {
LOG(ERROR) << "Could not get frame metadata!";
return 0;
}
# The frame type desired - note this are already retrieved waiting to be pulled from the Frame class instance: frame
std::string frameType = "ab"; //ab, depth, xyz
if (frame.haveDataType(frameType)) {
# Get metadata for a specific frame type
FrameDataDetails fDetails;
frame.getDataDetails(frameType, fDetails);
# Get the frame type specific data from the Frame class instance: frame. This is the actual data.
# 'data1' is not allocated here, see below for details on the frame type.
Status status = Status::OK;
status = frame.getData(frameType, &data1);
if (status != Status::OK) {
LOG(ERROR) << "Could not get frame data " + frameType + "!";
return status;
}
}
- Structures used above:
-
getData data types sizes in bytes:
- "ab": width * height * sizeof(uint16_t)
- "depth": width * height * sizeof(uint16_t)
- "xyz": width * height * sizeof(uint16_t) * 3
The SDK has a native method for record and playback of recorded frames.
Frames are save early in the SDK, in connections layer of the SDK.
connections/target saves frames via bufferprocessor.cpp.
And playback is done via _connections/offline.
Saving frames is done after processing by the depth compute algorithm.
Typical frame sizes per recording for the Dual ADSD3500 case with the megapixel imager, where metadata, depth and AB frames are stored.
| QVGA | VGA | QMP | MP | Notes | |
|---|---|---|---|---|---|
| Image Width | 320 pixels | 640 pixels | 512 pixels | 1,024 pixels | |
| Image Height | 256 pixels | 512 pixels | 512 pixels | 1,024 pixels | |
| *** | *** | *** | *** | *** | *** |
| # Frames | 1 | 1 | 1 | 1 | |
| File Header | 672 bytes | 672 bytes | 672 bytes | 672 bytes | |
| Frame Marker | 4 bytes | 4 bytes | 4 bytes | 4 bytes | |
| Buffer Size | 4 bytes | 4 bytes | 4 bytes | 4 bytes | |
| AB | 163,840 bytes | 655,360 bytes | 524,288 bytes | 2,097,152 bytes | |
| Depth | 163,840 bytes | 655,360 bytes | 524,288 bytes | 2,097,152 bytes | |
| Confidence | 327,680 bytes | 1,048,576 bytes | MegaPixel mode does not currently have confidence frames with Dual ADSD3500 | ||
| Metadata | 0 bytes | 0 bytes | 0 bytes | 0 bytes | Metadata is the first 128 bytes of the AB frame. |
| 656,040 bytes | 1,311,400 bytes | 2,097,832 bytes | 4,194,984 bytes |
status = camera->start();
// Check the camera status
status = camera->startRecording(<PATH TO SAVE RECORDING ON SSD>);
// Check the camera status
// Start getting frames to the host via requestFrame until ready to stop.
status = camera->stopRecording();
// Check the camera status
status = camera->stop();
// Check the camera status