camera_itof.cpp
Go to the documentation of this file.
1 /*
2  * BSD 3-Clause License
3  *
4  * Copyright (c) 2019, Analog Devices, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright notice, this
11  * list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright notice,
14  * this list of conditions and the following disclaimer in the documentation
15  * and/or other materials provided with the distribution.
16  *
17  * 3. Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived from
19  * this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 #include "camera_itof.h"
33 #include "aditof/frame.h"
35 #include "utils_ini.h"
36 
37 #include "cJSON.h"
38 #include "crc.h"
39 #include "tofi/algorithms.h"
40 #include "tofi/floatTolin.h"
41 #include "tofi/tofi_config.h"
42 #include "utils.h"
43 #include <algorithm>
44 #include <array>
45 #include <cstdint>
46 #include <fstream>
47 #include <omp.h>
48 #include <sstream>
49 
50 #ifdef USE_GLOG
51 #include <glog/logging.h>
52 #else
53 #include <aditof/log.h>
54 #endif
55 #include <chrono>
56 #include <iomanip>
57 #include <iostream>
58 #include <iterator>
59 #include <list>
60 #include <math.h>
61 #include <string>
62 #include <thread>
63 #include <vector>
64 
65 static const int skMetaDataBytesCount = 128;
66 
68  std::shared_ptr<aditof::DepthSensorInterface> depthSensor,
69  const std::string &ubootVersion, const std::string &kernelVersion,
70  const std::string &sdCardImageVersion, const std::string &netLinkTest)
71  : m_depthSensor(depthSensor), m_devStarted(false), m_devStreaming(false),
72  m_adsd3500Enabled(false), m_loadedConfigData(false), m_xyzEnabled(true),
73  m_xyzSetViaApi(false), m_cameraFps(0), m_fsyncMode(-1),
74  m_mipiOutputSpeed(-1), m_enableTempCompenstation(-1),
75  m_enableMetaDatainAB(-1), m_enableEdgeConfidence(-1), m_modesVersion(0),
76  m_xyzTable({nullptr, nullptr, nullptr}),
77  m_imagerType(aditof::ImagerType::UNSET), m_dropFirstFrame(true),
78  m_dropFrameOnce(true), m_isOffline(false) {
79 
81  memset(&m_xyzTable, 0, sizeof(m_xyzTable));
82  m_details.mode = 0;
83  m_details.uBootVersion = ubootVersion;
84  m_details.kernelVersion = kernelVersion;
85  m_details.sdCardImageVersion = sdCardImageVersion;
86  m_netLinkTest = netLinkTest;
87 
88  // Define some of the controls of this camera
89  // For now there are none. To add one use: m_controls.emplace("your_control_name", "default_control_value");
90  // And handle the control action in setControl()
91 
92  // Check Depth Sensor
93  if (!depthSensor) {
94  LOG(WARNING) << "Invalid instance of a depth sensor";
95  return;
96  }
97 
98  aditof::SensorDetails sDetails;
99  m_depthSensor->getDetails(sDetails);
100  m_details.cameraId = sDetails.id;
101  m_details.connection = sDetails.connectionType;
102 
103  std::string sensorName;
104  m_depthSensor->getName(sensorName);
105  LOG(INFO) << "Sensor name = " << sensorName;
106  if (sensorName == "adsd3500") {
107  m_adsd3500Enabled = true;
108  } else if (sensorName == "offline") {
109  m_isOffline = true;
110  }
111 
112  m_adsd3500_master = true;
113 }
114 
116  freeConfigData();
117  // m_device->toggleFsync();
119 }
120 
122  using namespace aditof;
123  Status status = Status::OK;
124 
125  LOG(INFO) << "Initializing camera";
126 
127  if (!m_adsd3500Enabled && !m_isOffline) {
128  LOG(ERROR) << "This usecase is no longer supported.";
130  }
131 
132  m_initConfigFilePath = configFilepath;
133 
134  // Setting up the UVC filters, samplegrabber interface, Video renderer and filters
135  // Setting UVC mediaformat and Running the stream is done once mode is set
136  if (!m_devStarted) {
137  status = m_depthSensor->open();
138  if (status != Status::OK) {
139  LOG(WARNING) << "Failed to open device";
140  return status;
141  }
142  m_devStarted = true;
143  }
144 
145  if (!m_netLinkTest.empty()) {
146  m_depthSensor->setControl("netlinktest", "1");
147  }
148 
149  // get imager type that is used toghether with ADSD3500
150  std::string controlValue;
151  status = m_depthSensor->getControl("imagerType", controlValue);
152  if (status == Status::OK) {
153  if (controlValue == ControlValue.at(ImagerType::ADSD3100)) {
154  m_imagerType = ImagerType::ADSD3100;
155  } else if (controlValue == ControlValue.at(ImagerType::ADSD3030)) {
156  m_imagerType = ImagerType::ADSD3030;
157  } else if (controlValue == ControlValue.at(ImagerType::ADTF3080)) {
158  m_imagerType = ImagerType::ADTF3080;
159  } else {
160  m_imagerType = ImagerType::UNSET;
161  LOG(ERROR) << "Unkown imager type: " << controlValue;
162  return Status::UNAVAILABLE;
163  }
164 
165  status = m_depthSensor->getAvailableModes(m_availableModes);
166  if (status != Status::OK) {
167  LOG(ERROR) << "Failed to get available frame types name!";
168  return status;
169  }
170 
171  for (auto availablemodes : m_availableModes) {
172  DepthSensorModeDetails modeDetails;
173  status = m_depthSensor->getModeDetails(availablemodes, modeDetails);
174  if (status != Status::OK) {
175  LOG(ERROR) << "Failed to get available frame types details!";
176  return status;
177  }
178  m_availableSensorModeDetails.emplace_back(modeDetails);
179 
180  uint8_t intrinsics[56] = {0};
181  uint8_t dealiasParams[32] = {0};
182  TofiXYZDealiasData dealiasStruct;
183  //the first element of readback_data for adsd3500_read_payload is used for the custom command
184  //it will be overwritten by the returned data
185  uint8_t mode = modeDetails.modeNumber;
186 
187  intrinsics[0] = mode;
188  dealiasParams[0] = mode;
189  //hardcoded function values to return intrinsics
190  status =
191  m_depthSensor->adsd3500_read_payload_cmd(0x01, intrinsics, 56);
192  if (status != Status::OK) {
193  LOG(ERROR) << "Failed to read intrinsics for adsd3500!";
194  return status;
195  }
196 
197  //hardcoded function values to return dealias parameters
198  status = m_depthSensor->adsd3500_read_payload_cmd(
199  0x02, dealiasParams, 32);
200  if (status != Status::OK) {
201  LOG(ERROR) << "Failed to read dealias parameters for adsd3500!";
202  return status;
203  }
204 
205  memcpy(&dealiasStruct, dealiasParams,
206  sizeof(TofiXYZDealiasData) - sizeof(CameraIntrinsics));
207  memcpy(&dealiasStruct.camera_intrinsics, intrinsics,
208  sizeof(CameraIntrinsics));
209 
210  m_xyz_dealias_data[mode] = dealiasStruct;
211  memcpy(&m_details.intrinsics, &dealiasStruct.camera_intrinsics,
212  sizeof(CameraIntrinsics));
213  }
214 
215  if (!m_isOffline) {
216  std::string fwVersion;
217  std::string fwHash;
218 
219  status = adsd3500GetFirmwareVersion(fwVersion, fwHash);
220 
221  if (status == Status::OK) {
222  LOG(INFO) << "Current adsd3500 firmware version is: "
223  << m_adsd3500FwGitHash.first;
224  LOG(INFO) << "Current adsd3500 firmware git hash is: "
225  << m_adsd3500FwGitHash.second;
226  } else
227  return status;
228  }
229  }
230 
231  aditof::Status configStatus = loadConfigData();
232  if (configStatus == aditof::Status::OK) {
233  m_loadedConfigData = true;
234  } else {
235  LOG(ERROR) << "loadConfigData failed";
236  return Status::GENERIC_ERROR;
237  }
238 
240  if (paramsStatus != Status::OK) {
241  LOG(ERROR) << "Failed to load process parameters!";
242  return status;
243  }
244 
245  if (m_fsyncMode >= 0) {
247  if (status != Status::OK) {
248  LOG(ERROR) << "Failed to set fsyncMode.";
249  return status;
250  }
251  } else {
252  LOG(WARNING) << "fsyncMode is not being set by SDK.";
253  }
254 
255  if (m_mipiOutputSpeed >= 0) {
257  if (status != Status::OK) {
258  LOG(ERROR) << "Failed to set mipiOutputSpeed.";
259  return status;
260  }
261  } else {
262  LOG(WARNING) << "mipiSpeed is not being set by SDK.";
263  }
264 
265  if (m_enableTempCompenstation >= 0) {
266  status =
268  if (status != Status::OK) {
269  LOG(ERROR) << "Failed to set enableTempCompenstation.";
270  return status;
271  }
272  } else {
273  LOG(WARNING) << "enableTempCompenstation is not being set by SDK.";
274  }
275 
276  if (m_enableEdgeConfidence >= 0) {
278  if (status != Status::OK) {
279  LOG(ERROR) << "Failed to set enableEdgeConfidence.";
280  return status;
281  }
282  } else {
283  LOG(WARNING) << "enableEdgeConfidence is not being set by SDK.";
284  }
285 
286  std::string serialNumber;
287  status = readSerialNumber(serialNumber);
288  if (status == Status::OK) {
289  LOG(INFO) << "Module serial number: " << serialNumber;
290  } else if (status == Status::UNAVAILABLE) {
291  LOG(INFO) << "Serial read is not supported in this firmware!";
292  } else {
293  LOG(ERROR) << "Failed to read serial number!";
294  return status;
295  }
296 
297  LOG(INFO) << "Camera initialized";
298 
299  return Status::OK;
300 }
301 
303  using namespace aditof;
304 
305  Status status = m_depthSensor->start();
306  if (Status::OK != status) {
307  LOG(ERROR) << "Error starting adsd3500.";
308  return status;
309  }
310  m_devStreaming = true;
311 
312  return aditof::Status::OK;
313 }
314 
316  aditof::Status status;
317 
318  status = m_depthSensor->stop();
319  if (status != aditof::Status::OK) {
320  LOG(INFO) << "Failed to stop camera!";
321  }
322 
323  m_devStreaming = false;
324 
325  return status;
326 }
327 
329  using namespace aditof;
330  Status status = Status::OK;
331 
332  auto modeIt = std::find_if(m_availableSensorModeDetails.begin(),
334  [&mode](const DepthSensorModeDetails &d) {
335  return (d.modeNumber == mode);
336  });
337 
338  if (modeIt == m_availableSensorModeDetails.end()) {
339  LOG(WARNING) << "Mode: " << (int)mode << " not supported by camera";
341  }
342 
343  if (m_details.connection == ConnectionType::USB) {
344  status = m_depthSensor->adsd3500_reset();
345  if (status != Status::OK) {
346  LOG(WARNING) << "Failed to reset the camera!";
347  return status;
348  }
349  }
350 
353  status = m_depthSensor->setMode(mode);
354  if (status != Status::OK) {
355  LOG(WARNING) << "Failed to set frame type";
356  return status;
357  }
358 
359  status = m_depthSensor->getModeDetails(mode, m_modeDetailsCache);
360  if (status != Status::OK) {
361  LOG(ERROR) << "Failed to get frame type details!";
362  return status;
363  }
364 
366 
367  uint16_t chipCmd = 0xDA00;
368  chipCmd += mode;
369  status = m_depthSensor->adsd3500_write_cmd(chipCmd, 0x280F, 200000);
370  if (status != Status::OK) {
371  LOG(ERROR) << "Failed to switch mode in chip using host commands!";
372  return status;
373  }
374 
377  m_details.mode = mode;
378 
379  LOG(INFO) << "Using the following configuration parameters for mode "
380  << int(mode);
381  for (auto param : m_iniKeyValPairs) {
382  LOG(INFO) << param.first << " : " << param.second;
383  }
384 
385  if (m_enableMetaDatainAB > 0) {
386  if (!m_pcmFrame) {
388  if (status != Status::OK) {
389  LOG(ERROR) << "Failed to set enableMetaDatainAB.";
390  return status;
391  }
392  LOG(INFO) << "Metadata in AB is enabled and it is stored in the "
393  "first 128 bytes.";
394 
395  } else {
396  status = adsd3500SetEnableMetadatainAB(0);
397  if (status != Status::OK) {
398  LOG(ERROR) << "Failed to disable enableMetaDatainAB.";
399  return status;
400  }
401  LOG(INFO) << "Metadata in AB is disabled for this frame type.";
402  }
403 
404  } else {
406  if (status != Status::OK) {
407  LOG(ERROR) << "Failed to set enableMetaDatainAB.";
408  return status;
409  }
410 
411  LOG(WARNING) << "Metadata in AB is disabled.";
412  }
413 
414  // Store the frame details in camera details
415  m_details.mode = mode;
416  m_details.frameType.width = (*modeIt).baseResolutionWidth;
417  m_details.frameType.height = (*modeIt).baseResolutionHeight;
420  for (const auto &item : (*modeIt).frameContent) {
421  if (item == "xyz" && !m_xyzEnabled) {
422  continue;
423  }
424  if (item == "raw") { // "raw" is not supported right now
425  continue;
426  }
427 
428  FrameDataDetails fDataDetails;
429  fDataDetails.type = item;
432  fDataDetails.subelementSize = sizeof(uint16_t);
433  fDataDetails.subelementsPerElement = 1;
434 
435  if (item == "xyz") {
436  fDataDetails.subelementsPerElement = 3;
437  } else if (item == "raw") {
440  fDataDetails.subelementSize = 1;
441  fDataDetails.subelementsPerElement = 1;
442  } else if (item == "metadata") {
443  fDataDetails.subelementSize = 1;
444  fDataDetails.width = 128;
445  fDataDetails.height = 1;
446  } else if (item == "conf") {
447  fDataDetails.subelementSize = sizeof(float);
448  }
449  fDataDetails.bytesCount = fDataDetails.width * fDataDetails.height *
450  fDataDetails.subelementSize *
451  fDataDetails.subelementsPerElement;
452 
453  m_details.frameType.dataDetails.emplace_back(fDataDetails);
454  }
455 
456  // We want computed frames (Depth & AB). Tell target to initialize depth compute
457  if (!m_pcmFrame) {
458  size_t dataSize = 0;
459  unsigned char *pData = nullptr;
460 
461  if (m_depthINIDataMap.size() > 1) {
462  dataSize = m_depthINIDataMap[std::to_string(mode)].size;
463  pData = m_depthINIDataMap[std::to_string(mode)].p_data;
464  }
465 
466  std::string s(reinterpret_cast<const char *>(pData), dataSize);
467 
468  aditof::Status localStatus;
469  localStatus = m_depthSensor->initTargetDepthCompute(
470  (uint8_t *)s.c_str(), dataSize, (uint8_t *)m_xyz_dealias_data,
471  sizeof(TofiXYZDealiasData) * 10);
472  if (localStatus != aditof::Status::OK) {
473  LOG(ERROR) << "Failed to initialize depth compute on target!";
474  return localStatus;
475  }
476 
477  if (!m_isOffline) {
478  std::string depthComputeStatus;
479  localStatus = m_depthSensor->getControl("depthComputeOpenSource",
480  depthComputeStatus);
481  if (localStatus == aditof::Status::OK) {
482  if (depthComputeStatus == "0") {
483  LOG(INFO) << "Using closed source depth compute library.";
484  } else {
485  LOG(INFO) << "Using open source depth compute library.";
486  }
487  } else {
488  LOG(ERROR)
489  << "Failed to get depth compute version from target!";
490  }
491  }
492  }
493 
494  // If we compute XYZ then prepare the XYZ tables which depend on the mode
495  if (m_xyzEnabled && !m_pcmFrame) {
497 
498  const int GEN_XYZ_ITERATIONS = 20;
500 
504  &(pDealias->camera_intrinsics), pDealias->n_sensor_rows,
507  pDealias->n_offset_cols, pDealias->row_bin_factor,
509  if (ret != 0 || !m_xyzTable.p_x_table || !m_xyzTable.p_y_table ||
511  LOG(ERROR) << "Failed to generate the XYZ tables";
512  return Status::GENERIC_ERROR;
513  }
514  }
515 
516  // If a Dynamic Mode Switching sequences has been loaded from config file then configure ADSD3500
517  if (m_configDmsSequence.size() > 0) {
518  status = this->adsd3500setEnableDynamicModeSwitching(true);
519  if (status != Status::OK) {
520  LOG(WARNING) << "Could not enable 'Dynamic Mode Switching.";
521  return status;
522  }
523 
524  status =
526  m_configDmsSequence.clear();
527  if (status != Status::OK) {
528  LOG(WARNING)
529  << "Could not set a sequence for the 'Dynamic Mode Switching'.";
530  return status;
531  }
532  }
533 
534  return status;
535 }
536 
538 CameraItof::getFrameProcessParams(std::map<std::string, std::string> &params) {
539  aditof::Status status;
540  status = m_depthSensor->getDepthComputeParams(params);
541  if (status != aditof::Status::OK) {
542  LOG(ERROR) << "get ini parameters failed.";
543  }
544  return status;
545 }
546 
548 CameraItof::setFrameProcessParams(std::map<std::string, std::string> &params) {
549  aditof::Status status;
550  if (m_devStreaming)
551  LOG(WARNING) << "Setting camera parameters while streaming is one is "
552  "not recommended";
553  status = setAdsd3500IniParams(params);
554  if (status != aditof::Status::OK) {
555  LOG(ERROR) << "Failed to set ini parameters on ADSD3500";
556  }
557  status = m_depthSensor->setDepthComputeParams(params);
558  if (status != aditof::Status::OK) {
559  LOG(ERROR) << "set ini parameters failed in depth-compute.";
560  }
561  return status;
562 }
563 
565  return m_depthSensor->adsd3500_write_cmd(0x40, mode);
566 }
567 
569 CameraItof::getAvailableModes(std::vector<uint8_t> &availableModes) const {
570  using namespace aditof;
571  Status status = Status::OK;
572  availableModes.clear();
573 
574  for (const auto &mode : m_availableModes) {
575  availableModes.emplace_back(mode);
576  }
577 
578  return status;
579 }
580 
582  using namespace aditof;
583  Status status = Status::OK;
584 
585  if (frame == nullptr) {
587  }
588 
589  FrameDetails frameDetails;
590  frame->getDetails(frameDetails);
591 
592  if (m_details.frameType != frameDetails) {
594  }
595 
596  uint16_t *frameDataLocation = nullptr;
597  if (!m_pcmFrame) {
598  frame->getData("frameData", &frameDataLocation);
599  } else {
600  frame->getData("ab", &frameDataLocation);
601  }
602 
603  if (!frameDataLocation) {
604  LOG(WARNING) << "getframe failed to allocated valid frame";
605  return status;
606  }
607 
609  m_depthSensor->getFrame(frameDataLocation);
610  m_dropFrameOnce = false;
611  if (status != Status::OK) {
612  LOG(INFO) << "Failed to drop first frame!";
613  return status;
614  }
615  LOG(INFO) << "Dropped first frame";
616  }
617 
618  status = m_depthSensor->getFrame(frameDataLocation);
619  if (status != Status::OK) {
620  LOG(WARNING) << "Failed to get frame from device";
621  return status;
622  }
623 
624  // The incoming sensor frames are already processed. Need to just create XYZ data
625  if (m_xyzEnabled) {
626  uint16_t *depthFrame;
627  uint16_t *xyzFrame;
628 
629  frame->getData("depth", &depthFrame);
630  frame->getData("xyz", &xyzFrame);
631 
632  Algorithms::ComputeXYZ((const uint16_t *)depthFrame, &m_xyzTable,
633  (int16_t *)xyzFrame,
636  }
637 
639  status = frame->getMetadataStruct(metadata);
640  if (status != Status::OK) {
641  LOG(ERROR) << "Could not get frame metadata!";
642  return status;
643  }
644 
645  uint16_t *metadataLocation;
646  status = frame->getData("metadata", &metadataLocation);
647  if (status != Status::OK) {
648  LOG(ERROR) << "Failed to get metadata location";
649  return status;
650  }
651 
652  if (m_enableMetaDatainAB) {
653  uint16_t *abFrame;
654  frame->getData("ab", &abFrame);
655  memcpy(reinterpret_cast<uint8_t *>(&metadata), abFrame,
656  sizeof(metadata));
657  memset(abFrame, 0, sizeof(metadata));
658  } else {
659  // If metadata from ADSD3500 is not available/disabled, generate one here
660  memset(static_cast<void *>(&metadata), 0, sizeof(metadata));
664  metadata.bitsInDepth = m_depthBitsPerPixel;
665  metadata.bitsInAb = m_abBitsPerPixel;
666  metadata.bitsInConfidence = m_confBitsPerPixel;
667 
668  // For frame with PCM content we need to store ab bits
669  if (m_pcmFrame) {
670  metadata.bitsInAb = 16;
671  }
672  }
673 
674  metadata.xyzEnabled = m_xyzEnabled;
675  memcpy(reinterpret_cast<uint8_t *>(metadataLocation),
676  reinterpret_cast<uint8_t *>(&metadata), sizeof(metadata));
677 
678  return Status::OK;
679 }
680 
681 void CameraItof::normalizeABBuffer(uint16_t *abBuffer, uint16_t abWidth,
682  uint16_t abHeight, bool advanceScaling,
683  bool useLogScaling) {
684 
685  size_t imageSize = abHeight * abWidth;
686 
687  uint32_t min_value_of_AB_pixel = 0xFFFF;
688  uint32_t max_value_of_AB_pixel = 1;
689 
690  if (advanceScaling) {
691 
692  for (size_t dummyCtr = 0; dummyCtr < imageSize; ++dummyCtr) {
693  if (abBuffer[dummyCtr] > max_value_of_AB_pixel) {
694  max_value_of_AB_pixel = abBuffer[dummyCtr];
695  }
696  if (abBuffer[dummyCtr] < min_value_of_AB_pixel) {
697  min_value_of_AB_pixel = abBuffer[dummyCtr];
698  }
699  }
700  max_value_of_AB_pixel -= min_value_of_AB_pixel;
701  } else {
702 
703  //TODO: This is hard code, but should reflect the number of AB bits
704  // See https://github.com/analogdevicesinc/ToF/blob/7d63e2d7e0e2bb795f5a55139740b4d5870ad3d6/examples/tof-viewer/src/ADIView.cpp#L254
705  uint32_t m_maxABPixelValue = (1 << 13) - 1;
706  max_value_of_AB_pixel = m_maxABPixelValue;
707  min_value_of_AB_pixel = 0;
708  }
709 
710  uint32_t new_max_value_of_AB_pixel = 1;
711  uint32_t new_min_value_of_AB_pixel = 0xFFFF;
712 
713 #pragma omp parallel for
714  for (size_t dummyCtr = 0; dummyCtr < imageSize; ++dummyCtr) {
715 
716  abBuffer[dummyCtr] -= min_value_of_AB_pixel;
717  double pix = abBuffer[dummyCtr] * (255.0 / max_value_of_AB_pixel);
718 
719  if (pix < 0.0) {
720  pix = 0.0;
721  }
722  if (pix > 255.0) {
723  pix = 255.0;
724  }
725  abBuffer[dummyCtr] = static_cast<uint8_t>(pix);
726 
727  if (abBuffer[dummyCtr] > new_max_value_of_AB_pixel) {
728  new_max_value_of_AB_pixel = abBuffer[dummyCtr];
729  }
730  if (abBuffer[dummyCtr] < new_min_value_of_AB_pixel) {
731  new_min_value_of_AB_pixel = abBuffer[dummyCtr];
732  }
733  }
734 
735  if (useLogScaling) {
736 
737  max_value_of_AB_pixel = new_max_value_of_AB_pixel;
738  min_value_of_AB_pixel = new_min_value_of_AB_pixel;
739 
740  double maxLogVal =
741  log10(1.0 + static_cast<double>(max_value_of_AB_pixel -
742  min_value_of_AB_pixel));
743 
744 #pragma omp parallel for
745  for (size_t dummyCtr = 0; dummyCtr < imageSize; ++dummyCtr) {
746 
747  double pix =
748  static_cast<double>(abBuffer[dummyCtr] - min_value_of_AB_pixel);
749  double logPix = log10(1.0 + pix);
750  pix = (logPix / maxLogVal) * 255.0;
751  if (pix < 0.0) {
752  pix = 0.0;
753  }
754  if (pix > 255.0) {
755  pix = 255.0;
756  }
757 
758  abBuffer[dummyCtr] = (uint8_t)(pix);
759  }
760  }
761 }
762 
764  bool advanceScaling,
765  bool useLogScaling) {
766 
767  using namespace aditof;
768  Status status = Status::OK;
769  uint16_t *abVideoData;
770 
771  status = frame->getData("ab", &abVideoData);
772 
773  if (status != Status::OK) {
774  LOG(ERROR) << "Could not get frame data!";
775  return status;
776  }
777 
778  if (!abVideoData) {
779  LOG(ERROR) << "no memory allocated in frame";
781  }
782 
783  aditof::FrameDataDetails frameAbDetails;
784  frameAbDetails.height = 0;
785  frameAbDetails.width = 0;
786  frame->getDataDetails("ab", frameAbDetails);
787 
788  normalizeABBuffer(abVideoData, frameAbDetails.width, frameAbDetails.height,
789  advanceScaling, useLogScaling);
790 
791  return status;
792 }
793 
795  using namespace aditof;
796  Status status = Status::OK;
797 
798  details = m_details;
799 
800  return status;
801 }
802 
803 std::shared_ptr<aditof::DepthSensorInterface> CameraItof::getSensor() {
804  return m_depthSensor;
805 }
806 
808 CameraItof::getAvailableControls(std::vector<std::string> &controls) const {
809  using namespace aditof;
810  Status status = Status::OK;
811 
812  controls.clear();
813  controls.reserve(m_controls.size());
814  for (const auto &item : m_controls) {
815  controls.emplace_back(item.first);
816  }
817 
818  return status;
819 }
820 
822  const std::string &value) {
823  using namespace aditof;
824  Status status = Status::OK;
825 
826  if (m_controls.count(control) > 0) {
827  if (value == "call") {
828  return m_noArgCallables.at(control)();
829  } else {
830  m_controls[control] = value;
831  }
832  } else {
833  LOG(WARNING) << "Unsupported control";
835  }
836 
837  return status;
838 }
839 
841  std::string &value) const {
842  using namespace aditof;
843  Status status = Status::OK;
844 
845  if (m_controls.count(control) > 0) {
846  value = m_controls.at(control);
847  } else {
848  LOG(WARNING) << "Unsupported control";
850  }
851 
852  return status;
853 }
854 
856 
857  freeConfigData();
858  using namespace aditof;
859 
860  if (m_availableModes.size() > 0) {
861  for (auto it = m_availableModes.begin(); it != m_availableModes.end();
862  ++it) {
863 
864  std::string iniArray;
865  int mode = *it;
866  m_depthSensor->getIniParamsArrayForMode(mode, iniArray);
867 
868  unsigned char *p = NULL;
869  p = (unsigned char *)malloc(iniArray.size());
870  memcpy(p, iniArray.c_str(), iniArray.size());
871 
872  FileData fval = {(unsigned char *)p, iniArray.size()};
873 
874  m_depthINIDataMap.emplace(std::to_string(mode), fval);
875  }
876  }
877 
878  if (!m_ccb_calibrationFile.empty()) {
879  m_calData =
880  LoadFileContents(const_cast<char *>(m_ccb_calibrationFile.c_str()));
881  } else {
883  m_calData.size = 0;
884  }
885 
886  return aditof::Status::OK;
887 }
888 
890 
891  if (m_depthINIDataMap.size() > 0) {
892  for (auto it = m_depthINIDataMap.begin(); it != m_depthINIDataMap.end();
893  ++it) {
894  free((void *)(it->second.p_data));
895  }
896  m_depthINIDataMap.clear();
897  }
898  if (m_calData.p_data) {
899  free((void *)(m_calData.p_data));
900  m_calData.p_data = nullptr;
901  m_calData.size = 0;
902  }
903 }
904 
906  bool useCacheValue) {
907  using namespace aditof;
908  Status status = Status::OK;
909 
910  if (m_adsd3500FwVersionInt < 4710) {
911  LOG(WARNING) << "Serial read is not supported in this firmware!";
912  return Status::UNAVAILABLE;
913  }
914 
915  if (useCacheValue) {
916  if (!m_details.serialNumber.empty()) {
917  serialNumber = m_details.serialNumber;
918  return status;
919  } else {
920  LOG(INFO)
921  << "No serial number stored in cache. Reading from memory.";
922  }
923  }
924 
925  uint8_t serial[32] = {0};
926 
927  status = m_depthSensor->adsd3500_read_payload_cmd(0x19, serial, 32);
928  if (status != aditof::Status::OK) {
929  LOG(ERROR) << "Failed to read serial number!";
930  return status;
931  }
932 
933  m_details.serialNumber = std::string(reinterpret_cast<char *>(serial), 32);
934  serialNumber = m_details.serialNumber;
935 
936  return status;
937 }
938 
940  aditof::Status status =
941  aditof::Status::GENERIC_ERROR; //Defining with error for ccb read
942 
943  if (filepath.empty()) {
944  LOG(ERROR) << "File path where CCB should be written is empty.";
946  }
947 
948  std::string ccbContent;
949  for (int i = 0; (i < NR_READADSD3500CCB && status != aditof::Status::OK);
950  i++) {
951  LOG(INFO) << "readAdsd3500CCB read attempt nr :" << i;
952  status = readAdsd3500CCB(ccbContent);
953  }
954 
955  if (status != aditof::Status::OK) {
956  LOG(ERROR) << "Failed to read CCB from adsd3500 module after "
957  << NR_READADSD3500CCB << " reads!";
959  }
960 
961  std::ofstream destination(filepath, std::ios::binary);
962  destination << ccbContent;
963 
964  return aditof::Status::OK;
965 }
966 
968  if (filepath.empty()) {
969  LOG(ERROR) << "File path where CFG should be written is empty.";
971  }
972 
973  LOG(ERROR) << "CFG files is unavailable";
975 }
976 
978  m_xyzEnabled = enable;
979  m_xyzSetViaApi = true;
980 
981  return aditof::Status::OK;
982 }
983 
986 }
987 
988 #pragma pack(push, 1)
989 typedef union {
990  uint8_t cmd_header_byte[16];
991  struct {
992  uint8_t id8; // 0xAD
993  uint16_t chunk_size16; // 256 is flash page size
994  uint8_t cmd8; // 0x04 is the CMD for fw upgrade
995  uint32_t total_size_fw32; // 4 bytes (total size of firmware)
996  uint32_t header_checksum32; // 4 bytes header checksum
997  uint32_t crc_of_fw32; // 4 bytes CRC of the Firmware Binary
998  };
999 } cmd_header_t;
1000 #pragma pack(pop)
1001 
1004  using namespace aditof;
1005  Status status = Status::OK;
1006 
1007  m_fwUpdated = false;
1009  aditof::SensorInterruptCallback cb = [this](Adsd3500Status status) {
1010  m_adsd3500Status = status;
1011  m_fwUpdated = true;
1012  };
1013  status = m_depthSensor->adsd3500_register_interrupt_callback(cb);
1014  bool interruptsAvailable = (status == Status::OK);
1015 
1016  // Read Chip ID in STANDARD mode
1017  uint16_t chip_id;
1018  status = m_depthSensor->adsd3500_read_cmd(0x0112, &chip_id);
1019  if (status != Status::OK) {
1020  LOG(ERROR) << "Failed to read adsd3500 chip id!";
1021  return status;
1022  }
1023 
1024  LOG(INFO) << "The readback chip ID is: " << chip_id;
1025 
1026  // Switch to BURST mode.
1027  status = m_depthSensor->adsd3500_write_cmd(0x0019, 0x0000);
1028  if (status != Status::OK) {
1029  LOG(ERROR) << "Failed to switch to burst mode!";
1030  return status;
1031  }
1032 
1033  // Send FW content, each chunk is 256 bytes
1034  const int flashPageSize = 256;
1035 
1036  // Read the firmware binary file
1037  std::ifstream fw_file(fwFilePath, std::ios::binary);
1038  // copy all data into buffer
1039  std::vector<uint8_t> buffer(std::istreambuf_iterator<char>(fw_file), {});
1040 
1041  uint32_t fw_len = buffer.size();
1042  uint8_t *fw_content = buffer.data();
1043  cmd_header_t fw_upgrade_header;
1044  fw_upgrade_header.id8 = 0xAD;
1045  fw_upgrade_header.chunk_size16 = 0x0100; // 256=0x100
1046  fw_upgrade_header.cmd8 = 0x04; // FW Upgrade CMD = 0x04
1047  fw_upgrade_header.total_size_fw32 = fw_len;
1048  fw_upgrade_header.header_checksum32 = 0;
1049 
1050  for (int i = 1; i < 8; i++) {
1051  fw_upgrade_header.header_checksum32 +=
1052  fw_upgrade_header.cmd_header_byte[i];
1053  }
1054 
1055  uint32_t res = crcFast(fw_content, fw_len, true) ^ 0xFFFFFFFF;
1056  fw_upgrade_header.crc_of_fw32 = ~res;
1057 
1058  status = m_depthSensor->adsd3500_write_payload(
1059  fw_upgrade_header.cmd_header_byte, 16);
1060  if (status != Status::OK) {
1061  LOG(ERROR) << "Failed to send fw upgrade header";
1062  return status;
1063  }
1064 
1065  int packetsToSend;
1066  if ((fw_len % flashPageSize) != 0) {
1067  packetsToSend = (fw_len / flashPageSize + 1);
1068  } else {
1069  packetsToSend = (fw_len / flashPageSize);
1070  }
1071 
1072  uint8_t data_out[flashPageSize];
1073 
1074  for (int i = 0; i < packetsToSend; i++) {
1075  int start = flashPageSize * i;
1076  int end = flashPageSize * (i + 1);
1077 
1078  for (int j = start; j < end; j++) {
1079  if (j < static_cast<int>(fw_len)) {
1080  data_out[j - start] = fw_content[j];
1081  } else {
1082  // padding with 0x00
1083  data_out[j - start] = 0x00;
1084  }
1085  }
1086  status = m_depthSensor->adsd3500_write_payload(data_out, flashPageSize);
1087  if (status != Status::OK) {
1088  LOG(ERROR) << "Failed to send packet number " << i << " out of "
1089  << packetsToSend << " packets!";
1090  return status;
1091  }
1092 
1093  if (i % 25 == 0) {
1094  LOG(INFO) << "Succesfully sent " << i << " out of " << packetsToSend
1095  << " packets";
1096  }
1097  }
1098 
1099  //Commands to switch back to standard mode
1100  uint8_t switchBuf[] = {0xAD, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
1101  0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
1102  status = m_depthSensor->adsd3500_write_payload(
1103  switchBuf, sizeof(switchBuf) / sizeof(switchBuf[0]));
1104  if (status != Status::OK) {
1105  LOG(ERROR) << "Failed to switch adsd3500 to standard mode!";
1106  return status;
1107  }
1108 
1109  if (interruptsAvailable) {
1110  LOG(INFO) << "Waiting for ADSD3500 to update itself";
1111  int secondsTimeout = 60;
1112  int secondsWaited = 0;
1113  int secondsWaitingStep = 1;
1114  while (!m_fwUpdated && secondsWaited < secondsTimeout) {
1115  LOG(INFO) << ".";
1116  std::this_thread::sleep_for(
1117  std::chrono::seconds(secondsWaitingStep));
1118  secondsWaited += secondsWaitingStep;
1119  }
1120  LOG(INFO) << "Waited: " << secondsWaited << " seconds";
1121  m_depthSensor->adsd3500_unregister_interrupt_callback(cb);
1122  if (!m_fwUpdated && secondsWaited >= secondsTimeout) {
1123  LOG(WARNING) << "Adsd3500 firmware updated has timeout after: "
1124  << secondsWaited << "seconds";
1126  }
1127 
1129  m_adsd3500Status == Adsd3500Status::FIRMWARE_UPDATE_COMPLETE) {
1130  LOG(INFO) << "Adsd3500 firmware updated succesfully!";
1131  } else {
1132  LOG(ERROR) << "Adsd3500 firmware updated but with error: "
1133  << (int)m_adsd3500Status;
1134  }
1135  } else {
1136  LOG(INFO) << "Adsd3500 firmware updated succesfully! Waiting 60 "
1137  "seconds since interrupts support was not detected.";
1138  std::this_thread::sleep_for(std::chrono::seconds(60));
1139  }
1140 
1141  return aditof::Status::OK;
1142 }
1143 
1145  using namespace aditof;
1146  Status status = Status::OK;
1147 
1148  uint8_t ccbHeader[16] = {0};
1149  ccbHeader[0] = 1;
1150 
1151  //For this case adsd3500 will remain in burst mode
1152  //A manuall switch to standard mode will be required at the end of the function
1153  status = m_depthSensor->adsd3500_read_payload_cmd(0x13, ccbHeader, 16);
1154  if (status != Status::OK) {
1155  LOG(ERROR) << "Failed to get ccb command header";
1156  return status;
1157  }
1158 
1159  uint16_t chunkSize;
1160  uint32_t ccbFileSize;
1161  uint32_t crcOfCCB;
1162  uint16_t numOfChunks;
1163 
1164  memcpy(&chunkSize, ccbHeader + 1, 2);
1165  memcpy(&ccbFileSize, ccbHeader + 4, 4);
1166  memcpy(&crcOfCCB, ccbHeader + 12, 4);
1167 
1168  numOfChunks = ccbFileSize / chunkSize;
1169  uint8_t *ccbContent = new uint8_t[ccbFileSize];
1170 
1171  for (int i = 0; i < numOfChunks; i++) {
1172  status = m_depthSensor->adsd3500_read_payload(
1173  ccbContent + i * chunkSize, chunkSize);
1174  if (status != Status::OK) {
1175  LOG(ERROR) << "Failed to read chunk number " << i << " out of "
1176  << numOfChunks + 1 << " chunks for adsd3500!";
1177  return status;
1178  }
1179 
1180  if (i % 20 == 0) {
1181  LOG(INFO) << "Succesfully read chunk number " << i << " out of "
1182  << numOfChunks + 1 << " chunks for adsd3500!";
1183  }
1184  }
1185 
1186  //read last chunk. smaller size than the rest
1187  if (ccbFileSize % chunkSize != 0) {
1188  status = m_depthSensor->adsd3500_read_payload(
1189  ccbContent + numOfChunks * chunkSize, ccbFileSize % chunkSize);
1190  if (status != Status::OK) {
1191  LOG(ERROR) << "Failed to read chunk number " << numOfChunks + 1
1192  << " out of " << numOfChunks + 1
1193  << " chunks for adsd3500!";
1194  return status;
1195  }
1196  }
1197 
1198  //Commands to switch back to standard mode
1199  uint8_t switchBuf[] = {0xAD, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
1200  0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
1201  status = m_depthSensor->adsd3500_write_payload(
1202  switchBuf, sizeof(switchBuf) / sizeof(switchBuf[0]));
1203  if (status != Status::OK) {
1204  LOG(ERROR) << "Failed to switch adsd3500 to standard mode!";
1205  return status;
1206  }
1207 
1208  LOG(INFO) << "Succesfully read ccb from adsd3500. Checking crc...";
1209 
1210  uint32_t computedCrc =
1211  crcFast(ccbContent, ccbFileSize - 4, true) ^ 0xFFFFFFFF;
1212 
1213  if (crcOfCCB != ~computedCrc) {
1214  LOG(ERROR) << "Invalid crc for ccb read from memory!";
1215  return Status::GENERIC_ERROR;
1216  } else {
1217  LOG(INFO) << "Crc of ccb is valid.";
1218  }
1219 
1220  std::ofstream tempFile;
1221  std::string fileName = "temp_ccb.ccb";
1222 
1223  //remove the trailling 4 bytes containing the crc
1224  ccb = std::string((char *)ccbContent, ccbFileSize - 4);
1225 
1226  delete[] ccbContent;
1227 
1228  return status;
1229 }
1230 
1233 
1234  auto it = m_iniKeyValPairs.find("bitsInPhaseOrDepth");
1235  if (it != m_iniKeyValPairs.end()) {
1236  value = it->second;
1237  m_depthBitsPerPixel = std::stoi(value);
1238  if (value == "16")
1239  value = "6";
1240  else if (value == "14")
1241  value = "5";
1242  else if (value == "12")
1243  value = "4";
1244  else if (value == "10")
1245  value = "3";
1246  else if (value == "8")
1247  value = "2";
1248  else
1249  value = "0";
1250  m_depthSensor->setControl("phaseDepthBits", value);
1251  } else {
1252  LOG(WARNING) << "bitsInPhaseOrDepth was not found in parameter list";
1253  }
1254 
1255  it = m_iniKeyValPairs.find("bitsInConf");
1256  if (it != m_iniKeyValPairs.end()) {
1257  value = it->second;
1258  m_confBitsPerPixel = std::stoi(value);
1259  if (value == "8")
1260  value = "2";
1261  else if (value == "4")
1262  value = "1";
1263  else
1264  value = "0";
1265  m_depthSensor->setControl("confidenceBits", value);
1266  } else {
1267  LOG(WARNING) << "bitsInConf was not found in parameter list";
1268  }
1269 
1270  it = m_iniKeyValPairs.find("bitsInAB");
1271  if (it != m_iniKeyValPairs.end()) {
1272  value = it->second;
1273  m_abEnabled = 1;
1274  m_abBitsPerPixel = std::stoi(value);
1275  if (value == "16")
1276  value = "6";
1277  else if (value == "14")
1278  value = "5";
1279  else if (value == "12")
1280  value = "4";
1281  else if (value == "10")
1282  value = "3";
1283  else if (value == "8")
1284  value = "2";
1285  else {
1286  value = "0";
1287  m_abEnabled = 0;
1288  }
1289  m_depthSensor->setControl("abBits", value);
1290  } else {
1291  LOG(WARNING) << "bitsInAB was not found in parameter list";
1292  }
1293 
1294  it = m_iniKeyValPairs.find("partialDepthEnable");
1295  if (it != m_iniKeyValPairs.end()) {
1296  std::string en = (it->second == "0") ? "1" : "0";
1297  m_depthSensor->setControl("depthEnable", en);
1298  m_depthSensor->setControl("abAveraging", en);
1299  } else {
1300  LOG(WARNING) << "partialDepthEnable was not found in parameter list";
1301  }
1302 
1303  it = m_iniKeyValPairs.find("inputFormat");
1304  if (it != m_iniKeyValPairs.end()) {
1305  value = it->second;
1306  m_depthSensor->setControl("inputFormat", value);
1307  } else {
1308  LOG(WARNING) << "inputFormat was not found in parameter list";
1309  }
1310 
1311  // XYZ set through camera control takes precedence over the setting from parameter list
1312  if (!m_xyzSetViaApi) {
1313  it = m_iniKeyValPairs.find("xyzEnable");
1314  if (it != m_iniKeyValPairs.end()) {
1315  m_xyzEnabled = !(it->second == "0");
1316  } else {
1317  LOG(WARNING) << "xyzEnable was not found in parameter list";
1318  }
1319  }
1320 
1321  //Embedded header is being set from theparameter list
1322  it = m_iniKeyValPairs.find("headerSize");
1323  if (it != m_iniKeyValPairs.end()) {
1324  value = it->second;
1325  if (std::stoi(value) == 128) {
1327  } else {
1329  }
1330  } else {
1331  LOG(WARNING) << "headerSize was not found in parameter list";
1332  }
1333 }
1334 
1335 static int16_t getValueFromJSON(cJSON *config_json, std::string key) {
1336  int16_t value = -1;
1337  const cJSON *json_value =
1338  cJSON_GetObjectItemCaseSensitive(config_json, key.c_str());
1339  if (cJSON_IsString(json_value) && (json_value->valuestring != NULL)) {
1340  value = atoi(json_value->valuestring);
1341  }
1342  return value;
1343 }
1344 
1346 
1347  using namespace aditof;
1348  Status status = Status::OK;
1349 
1350  if (m_initConfigFilePath == "") {
1351 
1352  for (const auto &mode : m_availableModes) {
1353 
1354  std::string iniArray;
1355  m_depthSensor->getIniParamsArrayForMode(mode, iniArray);
1356  std::map<std::string, std::string> paramsMap;
1357  UtilsIni::getKeyValuePairsFromString(iniArray, paramsMap);
1358  m_depth_params_map.emplace(mode, paramsMap);
1359  }
1360  } else {
1362  }
1363  return status;
1364 }
1365 
1368  using namespace aditof;
1369  Status status = Status::OK;
1370 
1371  cJSON *rootjson = cJSON_CreateObject();
1372 
1373  cJSON_AddNumberToObject(rootjson, "errata1", m_dropFirstFrame ? 1 : 0);
1374 
1375  cJSON_AddNumberToObject(rootjson, "fsyncMode", m_fsyncMode);
1376  cJSON_AddNumberToObject(rootjson, "mipiOutputSpeed", m_mipiOutputSpeed);
1377  cJSON_AddNumberToObject(rootjson, "enableTempCompensation",
1379  cJSON_AddNumberToObject(rootjson, "enableEdgeConfidence",
1381 
1382  std::list<std::string> depth_compute_keys_list = {
1383  "abThreshMin", "radialThreshMax",
1384  "radialThreshMin", "depthComputeIspEnable",
1385  "partialDepthEnable", "interleavingEnable",
1386  "bitsInPhaseOrDepth", "bitsInAB",
1387  "bitsInConf", "confThresh",
1388  "phaseInvalid", "inputFormat",
1389  "jblfABThreshold", "jblfApplyFlag",
1390  "jblfExponentialTerm", "jblfGaussianSigma",
1391  "jblfMaxEdge", "jblfWindowSize"};
1392 
1393  for (auto pfile = m_depth_params_map.begin();
1394  pfile != m_depth_params_map.end(); pfile++) {
1395 
1396  std::map<std::string, std::string> iniKeyValPairs = pfile->second;
1397 
1398  if (status == Status::OK) {
1399  cJSON *json = cJSON_CreateObject();
1400  cJSON *dept_compute_group_keys = cJSON_CreateObject();
1401  cJSON *configuration_param_keys = cJSON_CreateObject();
1402 
1403  for (auto item = iniKeyValPairs.begin();
1404  item != iniKeyValPairs.end(); item++) {
1405  double valued = strtod(item->second.c_str(), NULL);
1406 
1407  auto it = std::find_if(
1408  std::begin(depth_compute_keys_list),
1409  std::end(depth_compute_keys_list),
1410  [&](const std::string key) { return item->first == key; });
1411  if (depth_compute_keys_list.end() != it) {
1412  if (isConvertibleToDouble(item->second)) {
1413  cJSON_AddNumberToObject(dept_compute_group_keys,
1414  item->first.c_str(), valued);
1415  } else {
1416  cJSON_AddStringToObject(dept_compute_group_keys,
1417  item->first.c_str(),
1418  item->second.c_str());
1419  }
1420  } else {
1421  if (isConvertibleToDouble(item->second)) {
1422  cJSON_AddNumberToObject(configuration_param_keys,
1423  item->first.c_str(), valued);
1424  } else {
1425  cJSON_AddStringToObject(configuration_param_keys,
1426  item->first.c_str(),
1427  item->second.c_str());
1428  }
1429  }
1430  }
1431  cJSON_AddItemToObject(json, "depth-compute",
1432  dept_compute_group_keys);
1433  cJSON_AddItemToObject(json, "configuration-parameters",
1434  configuration_param_keys);
1435  cJSON_AddItemToObject(rootjson,
1436  std::to_string(pfile->first).c_str(), json);
1437  }
1438  }
1439 
1440  char *json_str = cJSON_Print(rootjson);
1441 
1442  FILE *fp = fopen(savePathFile.c_str(), "w");
1443  if (fp == NULL) {
1444  LOG(WARNING) << " Unable to open the file. " << savePathFile.c_str();
1445  return Status::GENERIC_ERROR;
1446  }
1447  fputs(json_str, fp);
1448  fclose(fp);
1449 
1450  cJSON_free(json_str);
1451  cJSON_Delete(rootjson);
1452 
1453  return status;
1454 }
1455 
1458  const int16_t mode_in_use) {
1459 
1460  using namespace aditof;
1461  Status status = Status::OK;
1462  m_depth_params_map.clear();
1463 
1464  // Parse json
1465  std::ifstream ifs(pathFile.c_str());
1466  std::string content((std::istreambuf_iterator<char>(ifs)),
1467  (std::istreambuf_iterator<char>()));
1468 
1469  cJSON *config_json = cJSON_Parse(content.c_str());
1470  if (config_json != NULL) {
1471 
1472  cJSON *errata1 =
1473  cJSON_GetObjectItemCaseSensitive(config_json, "errata1");
1474  double errata1val = 1;
1475  if (cJSON_IsNumber(errata1)) {
1476  errata1val = errata1->valuedouble;
1477  }
1478  if (errata1val == 1) {
1479  m_dropFirstFrame = true;
1480  } else {
1481  m_dropFirstFrame = false;
1482  }
1483 
1484  cJSON *fsyncMode =
1485  cJSON_GetObjectItemCaseSensitive(config_json, "fsyncMode");
1486  if (cJSON_IsNumber(fsyncMode)) {
1487  m_fsyncMode = fsyncMode->valueint;
1488  }
1489 
1490  cJSON *mipiOutputSpeed =
1491  cJSON_GetObjectItemCaseSensitive(config_json, "mipiOutputSpeed");
1492  if (cJSON_IsNumber(mipiOutputSpeed)) {
1493  m_mipiOutputSpeed = mipiOutputSpeed->valueint;
1494  }
1495 
1496  cJSON *enableTempCompensation = cJSON_GetObjectItemCaseSensitive(
1497  config_json, "enableTempCompensation");
1498  if (cJSON_IsNumber(enableTempCompensation)) {
1499  m_enableTempCompenstation = enableTempCompensation->valueint;
1500  }
1501 
1502  cJSON *enableEdgeConfidence = cJSON_GetObjectItemCaseSensitive(
1503  config_json, "enableEdgeConfidence");
1504  if (cJSON_IsNumber(enableEdgeConfidence)) {
1505  m_enableEdgeConfidence = enableEdgeConfidence->valueint;
1506  }
1507 
1508  cJSON *dmsSequence = cJSON_GetObjectItemCaseSensitive(
1509  config_json, "dynamicModeSwitching");
1510  if (cJSON_IsArray(dmsSequence)) {
1511 
1512  m_configDmsSequence.clear();
1513 
1514  cJSON *dmsPair;
1515  cJSON_ArrayForEach(dmsPair, dmsSequence) {
1516  cJSON *dmsMode =
1517  cJSON_GetObjectItemCaseSensitive(dmsPair, "mode");
1518  cJSON *dmsRepeat =
1519  cJSON_GetObjectItemCaseSensitive(dmsPair, "repeat");
1520 
1521  if (cJSON_IsNumber(dmsMode) && cJSON_IsNumber(dmsRepeat)) {
1522  m_configDmsSequence.emplace_back(
1523  std::make_pair(dmsMode->valueint, dmsRepeat->valueint));
1524  }
1525  }
1526  }
1527 
1528  for (const auto &mode : m_availableModes) {
1529 
1530  if (mode_in_use >= 0 && mode != mode_in_use) {
1531  continue;
1532  }
1533 
1534  std::string modeStr = std::to_string(mode);
1535 
1536  cJSON *depthframeType =
1537  cJSON_GetObjectItemCaseSensitive(config_json, modeStr.c_str());
1538 
1539  cJSON *dept_compute_group_keys = cJSON_GetObjectItemCaseSensitive(
1540  depthframeType, "depth-compute");
1541 
1542  std::map<std::string, std::string> iniKeyValPairs;
1543 
1544  if (dept_compute_group_keys) {
1545 
1546  cJSON *elem;
1547  cJSON_ArrayForEach(elem, dept_compute_group_keys) {
1548 
1549  std::string value = "";
1550 
1551  if (elem->valuestring != nullptr) {
1552  value = std::string(elem->valuestring);
1553  } else {
1554  std::ostringstream stream;
1555  stream << std::fixed << std::setprecision(1)
1556  << elem->valuedouble;
1557  value = stream.str();
1558  std::size_t found = value.find(".0");
1559  if (found != std::string::npos) {
1560  value = std::to_string(elem->valueint);
1561  }
1562  }
1563  iniKeyValPairs.emplace(std::string(elem->string), value);
1564  }
1565  }
1566 
1567  cJSON *configuration_param_keys = cJSON_GetObjectItemCaseSensitive(
1568  depthframeType, "configuration-parameters");
1569 
1570  if (configuration_param_keys) {
1571  cJSON *elem;
1572  cJSON_ArrayForEach(elem, configuration_param_keys) {
1573 
1574  std::string value = "";
1575 
1576  if (elem->valuestring != nullptr) {
1577  value = std::string(elem->valuestring);
1578  } else {
1579  std::ostringstream stream;
1580  stream << std::fixed << std::setprecision(1)
1581  << elem->valuedouble;
1582  value = stream.str();
1583  std::size_t found = value.find(".0");
1584  if (found != std::string::npos) {
1585  value = std::to_string(elem->valueint);
1586  }
1587  }
1588  iniKeyValPairs.emplace(std::string(elem->string), value);
1589  }
1590  }
1591  m_depth_params_map.emplace(mode, iniKeyValPairs);
1592  }
1593  }
1594  return status;
1595 }
1596 
1598  bool result = false;
1599  try {
1600  std::stod(str);
1601  result = true;
1602  } catch (...) {
1603  }
1604  return result;
1605 }
1606 
1607 void CameraItof::dropFirstFrame(bool dropFrame) {
1608  m_dropFirstFrame = dropFrame;
1609 }
1610 
1613  return m_depthSensor->setSensorConfiguration(sensorConf);
1614 }
1615 
1617  /*mode = 2, adsd3500 fsync does not automatically toggle - Pin set as input (Slave)*/
1618  /*mode = 1, adsd3500 fsync automatically toggles at user specified framerate*/
1619  /*mode = 0, adsd3500 fsync does not automatically toggle*/
1620  using namespace aditof;
1621  Status status = Status::OK;
1622 
1623  status = m_depthSensor->adsd3500_write_cmd(0x0025, mode);
1624  if (status != Status::OK) {
1625  LOG(ERROR) << "Unable to set FSYNC Toggle mode!";
1626  return status;
1627  }
1628 
1629  if (mode == 2) {
1630  m_adsd3500_master = false;
1631  }
1632 
1633  return status;
1634 }
1635 
1637  using namespace aditof;
1638  Status status = Status::OK;
1639 
1640  if (!m_adsd3500_master) {
1641  LOG(ERROR) << "ADSD3500 not set as master - cannot toggle FSYNC";
1642  } else {
1643  // Toggle Fsync
1644  status = m_depthSensor->adsd3500_write_cmd(0x0026, 0x0000);
1645  if (status != Status::OK) {
1646  LOG(ERROR) << "Unable to Toggle FSYNC!";
1647  return status;
1648  }
1649  }
1650 
1651  return status;
1652 }
1653 
1655  std::string &fwHash) {
1656  using namespace aditof;
1657  Status status = Status::OK;
1658  uint8_t fwData[44] = {0};
1659  fwData[0] = uint8_t(1);
1660 
1661  status = m_depthSensor->adsd3500_read_payload_cmd(0x05, fwData, 44);
1662  if (status != Status::OK) {
1663  LOG(INFO) << "Failed to retrieve fw version and git hash for "
1664  "adsd3500!";
1665  return status;
1666  }
1667 
1668  std::string fwv;
1669 
1670  fwv = std::to_string(fwData[0]) + '.' + std::to_string(fwData[1]) + '.' +
1671  std::to_string(fwData[2]) + '.' + std::to_string(fwData[3]);
1672 
1674  std::make_pair(fwv, std::string((char *)(fwData + 4), 40));
1675 
1677  for (int i = 0; i < 4; i++) {
1679  }
1680 
1681  fwVersion = m_adsd3500FwGitHash.first;
1682  fwHash = m_adsd3500FwGitHash.second;
1683 
1684  return status;
1685 }
1686 
1688  return m_depthSensor->adsd3500_write_cmd(0x0010, threshold);
1689 }
1690 
1692  threshold = 0;
1693  return m_depthSensor->adsd3500_read_cmd(
1694  0x0015, reinterpret_cast<uint16_t *>(&threshold));
1695 }
1696 
1698  return m_depthSensor->adsd3500_write_cmd(0x0011, threshold);
1699 }
1701  threshold = 0;
1702  return m_depthSensor->adsd3500_read_cmd(
1703  0x0016, reinterpret_cast<uint16_t *>(&threshold));
1704 }
1705 
1707  return m_depthSensor->adsd3500_write_cmd(0x0013, enable ? 1 : 0);
1708 }
1710  int intEnabled = 0;
1711  aditof::Status status = m_depthSensor->adsd3500_read_cmd(
1712  0x0017, reinterpret_cast<uint16_t *>(&intEnabled));
1713  enabled = !!intEnabled;
1714  return status;
1715 }
1716 
1718  return m_depthSensor->adsd3500_write_cmd(0x0014, size);
1719 }
1721  size = 0;
1722  return m_depthSensor->adsd3500_read_cmd(
1723  0x0018, reinterpret_cast<uint16_t *>(&size));
1724 }
1725 
1727  return m_depthSensor->adsd3500_write_cmd(0x0027, threshold);
1728 }
1730  threshold = 0;
1731  return m_depthSensor->adsd3500_read_cmd(
1732  0x0028, reinterpret_cast<uint16_t *>(&threshold));
1733 }
1734 
1736  return m_depthSensor->adsd3500_write_cmd(0x0029, threshold);
1737 }
1738 
1740  threshold = 0;
1741  return m_depthSensor->adsd3500_read_cmd(
1742  0x0030, reinterpret_cast<uint16_t *>(&threshold));
1743 }
1744 
1746  return m_depthSensor->adsd3500_write_cmd(0x0031, speed);
1747 }
1748 
1750  return m_depthSensor->adsd3500_read_cmd(
1751  0x0034, reinterpret_cast<uint16_t *>(&speed));
1752 }
1753 
1755  return m_depthSensor->adsd3500_read_cmd(
1756  0x0038, reinterpret_cast<uint16_t *>(&errcode));
1757 }
1758 
1760  return m_depthSensor->adsd3500_write_cmd(0x0066, delay);
1761 }
1762 
1764  return m_depthSensor->adsd3500_read_cmd(
1765  0x0068, reinterpret_cast<uint16_t *>(&delay));
1766 }
1767 
1769  return m_depthSensor->adsd3500_write_cmd(0x0074, threshold);
1770 }
1771 
1773  return m_depthSensor->adsd3500_write_cmd(0x0075, threshold);
1774 }
1775 
1777  return m_depthSensor->adsd3500_write_cmd(0x006B, value);
1778 }
1779 
1781  value = 0;
1782  return m_depthSensor->adsd3500_read_cmd(
1783  0x0069, reinterpret_cast<uint16_t *>(&value));
1784 }
1785 
1787  return m_depthSensor->adsd3500_write_cmd(0x006C, value);
1788 }
1789 
1791  return m_depthSensor->adsd3500_read_cmd(
1792  0x006A, reinterpret_cast<uint16_t *>(&value));
1793 }
1794 
1796  return m_depthSensor->adsd3500_read_cmd(0x0023,
1797  reinterpret_cast<uint16_t *>(&fps));
1798 }
1799 
1801  if (fps == 0) {
1802  fps = 10;
1803  LOG(WARNING) << "Using a default frame rate of " << fps;
1804  }
1805 
1806  aditof::Status status =
1807  m_depthSensor->setControl("fps", std::to_string(fps));
1808  if (status != aditof::Status::OK) {
1809  LOG(ERROR) << "Failed to set fps at: " << fps << "!";
1810  } else {
1811  m_cameraFps = fps;
1812  LOG(INFO) << "Camera FPS set from parameter list at: " << m_cameraFps;
1813  }
1814  return status;
1815 }
1816 
1818  return m_depthSensor->adsd3500_write_cmd(0x0062, value);
1819 }
1820 
1823  return m_depthSensor->adsd3500_read_cmd(
1824  0x0076, reinterpret_cast<uint16_t *>(&value));
1825 }
1826 
1828  return m_depthSensor->adsd3500_write_cmd(0x0072, value);
1829 }
1830 
1833  return m_depthSensor->adsd3500_write_cmd(0x0021, value);
1834 }
1835 
1837  return m_depthSensor->adsd3500_write_cmd(0x0036, value);
1838 }
1839 
1841  return m_depthSensor->adsd3500_read_cmd(
1842  0x0037, reinterpret_cast<uint16_t *>(&value));
1843 }
1844 
1846  uint16_t value) {
1847  return m_depthSensor->adsd3500_write_cmd(reg, value);
1848 }
1849 
1851  uint16_t &value) {
1852  return m_depthSensor->adsd3500_read_cmd(
1853  reg, reinterpret_cast<uint16_t *>(&value));
1854 }
1855 
1857  return m_depthSensor->setControl("disableCCBM", std::to_string(disable));
1858 }
1859 
1861  aditof::Status status;
1862  std::string availableCCMB;
1863 
1864  status = m_depthSensor->getControl("availableCCBM", availableCCMB);
1865  if (status == aditof::Status::OK) {
1866  if (availableCCMB == "1") {
1867  supported = true;
1868  } else if (availableCCMB == "0") {
1869  supported = false;
1870  } else {
1871  LOG(ERROR) << "Invalid value for control availableCCBM: "
1872  << availableCCMB;
1874  }
1875  }
1876 
1877  return status;
1878 }
1879 
1881  int &imagerStatus) {
1882  using namespace aditof;
1883  Status status = Status::OK;
1884  status = m_depthSensor->adsd3500_get_status(chipStatus, imagerStatus);
1885  if (status != Status::OK) {
1886  LOG(ERROR) << "Failed to read chip/imager status!";
1887  return status;
1888  }
1889 
1890  if (chipStatus != 0) {
1891  LOG(ERROR) << "ADSD3500 error detected: "
1892  << m_adsdErrors.GetStringADSD3500(chipStatus);
1893 
1894  if (chipStatus == m_adsdErrors.ADSD3500_STATUS_IMAGER_ERROR) {
1895  if (m_imagerType == ImagerType::ADSD3100) {
1896  LOG(ERROR) << "ADSD3100 imager error detected: "
1897  << m_adsdErrors.GetStringADSD3100(imagerStatus);
1898  } else if (m_imagerType == ImagerType::ADSD3030) {
1899  LOG(ERROR) << "ADSD3030 imager error detected: "
1900  << m_adsdErrors.GetStringADSD3030(imagerStatus);
1901  } else if (m_imagerType == ImagerType::ADTF3080) {
1902  LOG(ERROR) << "ADSD3030 imager error detected: "
1903  << m_adsdErrors.GetStringADSD3030(imagerStatus);
1904  } else {
1905  LOG(ERROR) << "Imager error detected. Cannot be displayed "
1906  "because imager type is unknown";
1907  }
1908  }
1909  } else {
1910  LOG(INFO) << "No chip/imager errors detected.";
1911  }
1912 
1913  return status;
1914 }
1915 
1917  using namespace aditof;
1918  Status status = Status::OK;
1919 
1920  unsigned int usDelay = 0;
1921  if (m_cameraFps > 0) {
1922  usDelay =
1923  static_cast<unsigned int>((1 / (double)m_cameraFps) * 1000000);
1924  }
1925  status = m_depthSensor->adsd3500_read_cmd(0x0054, &tmpValue, usDelay);
1926  if (status != Status::OK) {
1927  LOG(ERROR) << "Can not read sensor temperature";
1928  return Status::GENERIC_ERROR;
1929  }
1930 
1931  return status;
1932 }
1934  using namespace aditof;
1935  Status status = Status::OK;
1936 
1937  unsigned int usDelay = 0;
1938  if (m_cameraFps > 0) {
1939  usDelay =
1940  static_cast<unsigned int>((1 / (double)m_cameraFps) * 1000000);
1941  }
1942  status = m_depthSensor->adsd3500_read_cmd(0x0055, &tmpValue, usDelay);
1943  if (status != Status::OK) {
1944  LOG(ERROR) << "Can not read laser temperature";
1945  return Status::GENERIC_ERROR;
1946  }
1947 
1948  return status;
1949 }
1950 
1952  const std::map<std::string, std::string> &iniKeyValPairs) {
1953 
1955 
1956  auto it = iniKeyValPairs.find("abThreshMin");
1957  if (it != iniKeyValPairs.end()) {
1958  status = adsd3500SetABinvalidationThreshold(std::stoi(it->second));
1959  if (status != aditof::Status::OK)
1960  LOG(WARNING) << "Could not set abThreshMin";
1961  } else {
1962  LOG(WARNING)
1963  << "abThreshMin was not found in parameter list, not setting.";
1964  }
1965 
1966  it = iniKeyValPairs.find("confThresh");
1967  if (it != iniKeyValPairs.end()) {
1968  status = adsd3500SetConfidenceThreshold(std::stoi(it->second));
1969  if (status != aditof::Status::OK)
1970  LOG(WARNING) << "Could not set confThresh";
1971  } else {
1972  LOG(WARNING)
1973  << "confThresh was not found in parameter list, not setting.";
1974  }
1975 
1976  it = iniKeyValPairs.find("radialThreshMin");
1977  if (it != iniKeyValPairs.end()) {
1978  status = adsd3500SetRadialThresholdMin(std::stoi(it->second));
1979  if (status != aditof::Status::OK)
1980  LOG(WARNING) << "Could not set radialThreshMin";
1981  } else {
1982  LOG(WARNING)
1983  << "radialThreshMin was not found in parameter list, not setting.";
1984  }
1985 
1986  it = iniKeyValPairs.find("radialThreshMax");
1987  if (it != iniKeyValPairs.end()) {
1988  status = adsd3500SetRadialThresholdMax(std::stoi(it->second));
1989  if (status != aditof::Status::OK)
1990  LOG(WARNING) << "Could not set radialThreshMax";
1991  } else {
1992  LOG(WARNING)
1993  << "radialThreshMax was not found in parameter list, not setting.";
1994  }
1995 
1996  it = iniKeyValPairs.find("jblfWindowSize");
1997  if (it != iniKeyValPairs.end()) {
1998  status = adsd3500SetJBLFfilterSize(std::stoi(it->second));
1999  if (status != aditof::Status::OK)
2000  LOG(WARNING) << "Could not set jblfWindowSize";
2001  } else {
2002  LOG(WARNING)
2003  << "jblfWindowSize was not found in parameter list, not setting.";
2004  }
2005 
2006  it = iniKeyValPairs.find("jblfApplyFlag");
2007  if (it != iniKeyValPairs.end()) {
2008  bool en = !(it->second == "0");
2009  status = adsd3500SetJBLFfilterEnableState(en);
2010  if (status != aditof::Status::OK)
2011  LOG(WARNING) << "Could not set jblfApplyFlag";
2012  } else {
2013  LOG(WARNING)
2014  << "jblfApplyFlag was not found in parameter list, not setting.";
2015  }
2016 
2017  it = iniKeyValPairs.find("fps");
2018  if (it != iniKeyValPairs.end()) {
2019  status = adsd3500SetFrameRate(std::stoi(it->second));
2020  if (status != aditof::Status::OK)
2021  LOG(WARNING) << "Could not set fps";
2022  } else {
2023  LOG(WARNING) << "fps was not found in parameter list, not setting.";
2024  }
2025 
2026  it = iniKeyValPairs.find("vcselDelay");
2027  if (it != iniKeyValPairs.end()) {
2028  status = adsd3500SetVCSELDelay((uint16_t)(std::stoi(it->second)));
2029  if (status != aditof::Status::OK)
2030  LOG(WARNING) << "Could not set vcselDelay";
2031  } else {
2032  LOG(WARNING)
2033  << "vcselDelay was not found in parameter list, not setting.";
2034  }
2035 
2036  it = iniKeyValPairs.find("jblfMaxEdge");
2037  if (it != iniKeyValPairs.end()) {
2038  status =
2039  adsd3500SetJBLFMaxEdgeThreshold((uint16_t)(std::stoi(it->second)));
2040  if (status != aditof::Status::OK)
2041  LOG(WARNING) << "Could not set jblfMaxEdge";
2042  } else {
2043  LOG(WARNING) << "jblfMaxEdge was not found in parameter list, "
2044  "not setting.";
2045  }
2046 
2047  it = iniKeyValPairs.find("jblfABThreshold");
2048  if (it != iniKeyValPairs.end()) {
2049  status = adsd3500SetJBLFABThreshold((uint16_t)(std::stoi(it->second)));
2050  if (status != aditof::Status::OK)
2051  LOG(WARNING) << "Could not set jblfABThreshold";
2052  } else {
2053  LOG(WARNING) << "jblfABThreshold was not found in parameter list";
2054  }
2055 
2056  it = iniKeyValPairs.find("jblfGaussianSigma");
2057  if (it != iniKeyValPairs.end()) {
2058  status =
2059  adsd3500SetJBLFGaussianSigma((uint16_t)(std::stoi(it->second)));
2060  if (status != aditof::Status::OK)
2061  LOG(WARNING) << "Could not set jblfGaussianSigma";
2062  } else {
2063  LOG(WARNING) << "jblfGaussianSigma was not found in parameter list, "
2064  "not setting.";
2065  }
2066 
2067  it = iniKeyValPairs.find("jblfExponentialTerm");
2068  if (it != iniKeyValPairs.end()) {
2069  status =
2070  adsd3500SetJBLFExponentialTerm((uint16_t)(std::stoi(it->second)));
2071  if (status != aditof::Status::OK)
2072  LOG(WARNING) << "Could not set jblfExponentialTerm";
2073  } else {
2074  LOG(WARNING) << "jblfExponentialTerm was not found in parameter list, "
2075  "not setting.";
2076  }
2077 
2078  it = iniKeyValPairs.find("enablePhaseInvalidation");
2079  if (it != iniKeyValPairs.end()) {
2080  adsd3500SetEnablePhaseInvalidation((uint16_t)(std::stoi(it->second)));
2081  if (status != aditof::Status::OK)
2082  LOG(WARNING) << "Could not set enablePhaseInvalidation";
2083  } else {
2084  LOG(WARNING)
2085  << "enablePhaseInvalidation was not found in parameter list, "
2086  "not setting.";
2087  }
2088  return aditof::Status::OK;
2089 }
2090 
2092  if (m_xyzTable.p_x_table) {
2093  free((void *)m_xyzTable.p_x_table);
2094  m_xyzTable.p_x_table = nullptr;
2095  }
2096  if (m_xyzTable.p_y_table) {
2097  free((void *)m_xyzTable.p_y_table);
2098  m_xyzTable.p_y_table = nullptr;
2099  }
2100  if (m_xyzTable.p_z_table) {
2101  free((void *)m_xyzTable.p_z_table);
2102  m_xyzTable.p_z_table = nullptr;
2103  }
2104 }
2105 
2108 
2109  return aditof::Status::OK;
2110 }
2111 
2113 
2114  return m_depthSensor->adsd3500_write_cmd(0x0080, en ? 0x0001 : 0x0000);
2115 }
2116 
2118  const std::vector<std::pair<uint8_t, uint8_t>> &sequence) {
2119  using namespace aditof;
2120 
2121  Status status;
2122  uint32_t entireSequence = 0xFFFFFFFF;
2123  uint32_t entireRepCount = 0x00000000;
2124  uint8_t *bytePtrSq = reinterpret_cast<uint8_t *>(&entireSequence);
2125  uint8_t *bytePtrRc = reinterpret_cast<uint8_t *>(&entireRepCount);
2126 
2127  for (size_t i = 0; i < sequence.size(); ++i) {
2128  if (i < 8) {
2129  if (i % 2) {
2130  *bytePtrSq = (*bytePtrSq & 0x0F) | (sequence[i].first << 4);
2131  *bytePtrRc = (*bytePtrRc & 0x0F) | (sequence[i].second << 4);
2132  } else {
2133  *bytePtrSq = (*bytePtrSq & 0xF0) | (sequence[i].first << 0);
2134  *bytePtrRc = (*bytePtrRc & 0xF0) | (sequence[i].second << 0);
2135  }
2136  bytePtrSq += i % 2;
2137  bytePtrRc += i % 2;
2138  } else {
2139  LOG(WARNING) << "More than 8 entries have been provided. Ignoring "
2140  "all entries starting from the 9th.";
2141  break;
2142  }
2143  }
2144 
2145  uint16_t *sequence0 = reinterpret_cast<uint16_t *>(&entireSequence);
2146  uint16_t *sequence1 = reinterpret_cast<uint16_t *>(&entireSequence) + 1;
2147  status = m_depthSensor->adsd3500_write_cmd(0x0081, *sequence0);
2148  if (status != Status::OK) {
2149  LOG(ERROR) << "Failed to set sequence 0 for the Dynamic Mode Switching";
2150  return status;
2151  }
2152  status = m_depthSensor->adsd3500_write_cmd(0x0082, *sequence1);
2153  if (status != Status::OK) {
2154  LOG(ERROR) << "Failed to set sequence 1 for the Dynamic Mode Switching";
2155  return status;
2156  }
2157 
2158  uint16_t *repCount0 = reinterpret_cast<uint16_t *>(&entireRepCount);
2159  uint16_t *repCount1 = reinterpret_cast<uint16_t *>(&entireRepCount) + 1;
2160  status = m_depthSensor->adsd3500_write_cmd(0x0083, *repCount0);
2161  if (status != Status::OK) {
2162  LOG(ERROR) << "Failed to set mode repeat count 0 for the Dynamic Mode "
2163  "Switching";
2164  return status;
2165  }
2166  status = m_depthSensor->adsd3500_write_cmd(0x0084, *repCount1);
2167  if (status != Status::OK) {
2168  LOG(ERROR) << "Failed to set mode repeat count 0 for the Dynamic Mode "
2169  "Switching";
2170  return status;
2171  }
2172 
2173  return Status::OK;
2174 }
CameraItof::m_modeDetailsCache
aditof::DepthSensorModeDetails m_modeDetailsCache
Definition: camera_itof.h:242
aditof::DepthSensorModeDetails::isPCM
int isPCM
set to true if the mode is PCM
Definition: sensor_definitions.h:170
CameraItof::saveModuleCCB
aditof::Status saveModuleCCB(const std::string &filepath) override
Save the CCB content which is obtained from module memory to a given file path.
Definition: camera_itof.cpp:939
cJSON::valuestring
char * valuestring
Definition: cJSON.h:116
aditof::FrameDataDetails::subelementsPerElement
unsigned int subelementsPerElement
The number of sub-elements that an element has. An element is the smallest part of the image (a....
Definition: frame_definitions.h:78
CameraItof::enableXYZframe
aditof::Status enableXYZframe(bool enable) override
Enable the generation of a XYZ frame. The XYZ frame can be enabled or disabled through ....
Definition: camera_itof.cpp:977
CameraItof::loadDepthParamsFromJsonFile
aditof::Status loadDepthParamsFromJsonFile(const std::string &pathFile, const int16_t mode_in_use=-1) override
Load adsd parameters from json file. Need setMode to apply.
Definition: camera_itof.cpp:1457
INFO
const int INFO
Definition: log_severity.h:59
CameraItof::adsd3500SetConfidenceThreshold
aditof::Status adsd3500SetConfidenceThreshold(int threshold) override
Set the confidence threshold.
Definition: camera_itof.cpp:1697
CameraItof::getDetails
aditof::Status getDetails(aditof::CameraDetails &details) const override
Gets the current details of the camera.
Definition: camera_itof.cpp:794
CameraItof::adsd3500SetToggleMode
aditof::Status adsd3500SetToggleMode(int mode) override
Enables or disables FSYNC toggle for ADSD3500.
Definition: camera_itof.cpp:1616
aditof::DepthSensorModeDetails::modeNumber
uint8_t modeNumber
Number associated with the mode.
Definition: sensor_definitions.h:125
CameraItof::m_availableModes
std::vector< uint8_t > m_availableModes
Definition: camera_itof.h:241
CameraItof::setAdsd3500IniParams
aditof::Status setAdsd3500IniParams(const std::map< std::string, std::string > &iniKeyValPairs)
Definition: camera_itof.cpp:1951
aditof::ADSDErrors::GetStringADSD3030
std::string GetStringADSD3030(uint16_t value)
Returns a string for a given target (adsdType) and error code for the ADSD3030.
Definition: adsd_errs.h:159
TofiXYZDealiasData::col_bin_factor
uint8_t col_bin_factor
Definition: tofi_camera_intrinsics.h:39
aditof::DepthSensorModeDetails::frameHeightInBytes
int frameHeightInBytes
Driver height, can be used for both chipRaw and imagerRaw.
Definition: sensor_definitions.h:150
aditof::CameraDetails::mode
std::uint8_t mode
The mode in which the camera operates.
Definition: camera_definitions.h:141
FileData
Definition: tofi_util.h:64
CameraItof::setControl
aditof::Status setControl(const std::string &control, const std::string &value) override
Sets a specific camera control.
Definition: camera_itof.cpp:821
CameraItof::m_imagerType
aditof::ImagerType m_imagerType
Definition: camera_itof.h:260
end
GLuint GLuint end
Definition: glcorearb.h:2858
algorithms.h
CameraItof::m_enableMetaDatainAB
int16_t m_enableMetaDatainAB
Definition: camera_itof.h:248
aditof::DepthSensorModeDetails::baseResolutionHeight
int baseResolutionHeight
Processed data height.
Definition: sensor_definitions.h:160
stream
GLuint GLuint stream
Definition: glcorearb.h:3946
NULL
NULL
Definition: test_security_zap.cpp:405
aditof::SensorDetails
Provides details about the device.
Definition: sensor_definitions.h:50
TofiXYZDealiasData::n_offset_cols
uint16_t n_offset_cols
Definition: tofi_camera_intrinsics.h:41
ERROR
const int ERROR
Definition: log_severity.h:60
CameraItof::requestFrame
aditof::Status requestFrame(aditof::Frame *frame) override
Captures data from the camera and assigns it to the given frame.
Definition: camera_itof.cpp:581
cJSON::string
char * string
Definition: cJSON.h:123
CameraItof::m_controls
std::unordered_map< std::string, std::string > m_controls
Definition: camera_itof.h:209
CameraItof::freeConfigData
void freeConfigData(void)
Frees the calibration member variables created while loading the CCB contents.
Definition: camera_itof.cpp:889
CameraItof::m_adsd3500_master
bool m_adsd3500_master
Definition: camera_itof.h:217
getValueFromJSON
static int16_t getValueFromJSON(cJSON *config_json, std::string key)
Definition: camera_itof.cpp:1335
CameraItof::readAdsd3500CCB
aditof::Status readAdsd3500CCB(std::string &ccb)
Read the CCB from adsd3500 memory and store in output variable ccb.
Definition: camera_itof.cpp:1144
item
cJSON * item
Definition: cJSON.h:236
cmd_header_t::chunk_size16
uint16_t chunk_size16
Definition: camera_itof.cpp:993
CameraItof::adsd3500SetEnableMetadatainAB
aditof::Status adsd3500SetEnableMetadatainAB(uint16_t value) override
Set Enable Metadata in the AB frame.
Definition: camera_itof.cpp:1836
aditof::Status::GENERIC_ERROR
@ GENERIC_ERROR
An error occured but there are no details available.
CameraItof::getImagerType
aditof::Status getImagerType(aditof::ImagerType &imagerType) const override
Provides the type of the imager.
Definition: camera_itof.cpp:2106
CameraItof::adsd3500GetJBLFGaussianSigma
aditof::Status adsd3500GetJBLFGaussianSigma(uint16_t &value) override
Get JBLF Gaussian Sigma.
Definition: camera_itof.cpp:1780
cmd_header_t::total_size_fw32
uint32_t total_size_fw32
Definition: camera_itof.cpp:995
CameraItof::m_fwUpdated
bool m_fwUpdated
Definition: camera_itof.h:255
CameraItof::adsd3500IsCCBMsupported
aditof::Status adsd3500IsCCBMsupported(bool &supported) override
Check whether CCB as master is supported or not.
Definition: camera_itof.cpp:1860
s
XmlRpcServer s
cmd_header_t::header_checksum32
uint32_t header_checksum32
Definition: camera_itof.cpp:996
CameraItof::m_details
aditof::CameraDetails m_details
Definition: camera_itof.h:207
mode
GLenum mode
Definition: glcorearb.h:2764
CameraItof::adsd3500GetSensorTemperature
aditof::Status adsd3500GetSensorTemperature(uint16_t &tmpValue) override
Get the sensor temperature.
Definition: camera_itof.cpp:1916
CameraItof::adsd3500SetEnableTemperatureCompensation
aditof::Status adsd3500SetEnableTemperatureCompensation(uint16_t value) override
Set Enable Temperature Compensation.
Definition: camera_itof.cpp:1832
benchmarks.util.result_uploader.metadata
def metadata
Definition: result_uploader.py:97
CameraItof::m_devStarted
bool m_devStarted
Definition: camera_itof.h:213
log.h
CameraItof::readSerialNumber
aditof::Status readSerialNumber(std::string &serialNumber, bool useCacheValue=false) override
Read serial number from camera and update cache.
Definition: camera_itof.cpp:905
CameraItof::configureSensorModeDetails
void configureSensorModeDetails()
Definition: camera_itof.cpp:1231
CameraItof::setSensorConfiguration
aditof::Status setSensorConfiguration(const std::string &sensorConf) override
Set sensor configutation table.
Definition: camera_itof.cpp:1612
CameraItof::adsd3500GetEnableMetadatainAB
aditof::Status adsd3500GetEnableMetadatainAB(uint16_t &value) override
Get state of Enable Metadata in the AB frame.
Definition: camera_itof.cpp:1840
CameraItof::m_netLinkTest
std::string m_netLinkTest
Definition: camera_itof.h:219
NR_READADSD3500CCB
#define NR_READADSD3500CCB
Definition: camera_itof.h:44
crc.h
aditof::FrameDataDetails::type
std::string type
The type of data that can be found in a frame. For example it could be depth data or IR data,...
Definition: frame_definitions.h:53
utils_ini.h
CameraItof::m_abEnabled
bool m_abEnabled
Definition: camera_itof.h:233
CameraItof::m_availableSensorModeDetails
std::vector< aditof::DepthSensorModeDetails > m_availableSensorModeDetails
Definition: camera_itof.h:240
TofiXYZDealiasData::camera_intrinsics
CameraIntrinsics camera_intrinsics
Definition: tofi_camera_intrinsics.h:46
CameraItof::setFrameProcessParams
aditof::Status setFrameProcessParams(std::map< std::string, std::string > &params) override
Set the Depth Compute Library ini parameters.
Definition: camera_itof.cpp:548
string
GLsizei const GLchar *const * string
Definition: glcorearb.h:3083
CameraItof::m_cameraFps
int16_t m_cameraFps
Definition: camera_itof.h:244
crcFast
uint32_t crcFast(uint8_t const message[], int nBytes, bool isMirrored)
Definition: crc.c:58
aditof::FrameDataDetails::width
unsigned int width
The width of the frame data.
Definition: frame_definitions.h:58
cJSON.h
aditof::Status::UNAVAILABLE
@ UNAVAILABLE
The requested action or resource is unavailable.
found
return found
Definition: socket_poller.cpp:456
WARNING
const int WARNING
Definition: log_severity.h:59
CameraItof::m_xyzTable
XYZTable m_xyzTable
Definition: camera_itof.h:257
aditof::Adsd3500Status
Adsd3500Status
Status of the ADSD3500 sensor.
Definition: status_definitions.h:61
CameraItof::m_xyzEnabled
bool m_xyzEnabled
Definition: camera_itof.h:237
CameraItof::m_isOffline
bool m_isOffline
Definition: camera_itof.h:218
CameraItof::adsd3500SetRadialThresholdMin
aditof::Status adsd3500SetRadialThresholdMin(int threshold) override
Set the radial threshold min.
Definition: camera_itof.cpp:1726
CameraItof::adsd3500SetJBLFfilterEnableState
aditof::Status adsd3500SetJBLFfilterEnableState(bool enable) override
Enable/disable the JBLF filter.
Definition: camera_itof.cpp:1706
CameraItof::adsd3500SetJBLFABThreshold
aditof::Status adsd3500SetJBLFABThreshold(uint16_t threshold) override
Get JBLF Max Edge Threshold.
Definition: camera_itof.cpp:1772
cJSON::valuedouble
double valuedouble
Definition: cJSON.h:120
CameraItof::m_mipiOutputSpeed
int16_t m_mipiOutputSpeed
Definition: camera_itof.h:246
cJSON_ArrayForEach
#define cJSON_ArrayForEach(element, array)
Definition: cJSON.h:342
CameraItof::adsd3500GetStatus
aditof::Status adsd3500GetStatus(int &chipStatus, int &imagerStatus) override
Returns the chip status.
Definition: camera_itof.cpp:1880
cJSON::valueint
int valueint
Definition: cJSON.h:118
aditof::ADSDErrors::GetStringADSD3100
std::string GetStringADSD3100(uint16_t value)
Returns a string for a given target (adsdType) and error code for the ADSD3100.
Definition: adsd_errs.h:141
LoadFileContents
FileData LoadFileContents(char *filename)
Definition: tofi_util.c:78
CameraItof::m_depth_params_map
std::map< int, std::map< std::string, std::string > > m_depth_params_map
Definition: camera_itof.h:232
CameraItof::enableDepthCompute
aditof::Status enableDepthCompute(bool enable) override
Enable or disable the depth processing on the frames received from the sensor Must be called after ge...
Definition: camera_itof.cpp:984
google::protobuf::util::error::UNAVAILABLE
@ UNAVAILABLE
Definition: status.h:62
CameraItof::adsd3500ToggleFsync
aditof::Status adsd3500ToggleFsync() override
Toggles ADSD3500 FSYNC once if automated FSYNC is disabled.
Definition: camera_itof.cpp:1636
CameraItof::normalizeABFrame
aditof::Status normalizeABFrame(aditof::Frame *frame, bool advanceScaling, bool useLogScaling) override
Scale AB image with logarithmic base 10 in a Frame instance.
Definition: camera_itof.cpp:763
aditof::FrameDetails::width
unsigned int width
The width of the frame.
Definition: frame_definitions.h:114
cJSON_AddItemToObject
cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item)
Definition: cJSON.c:1859
aditof::CameraDetails::serialNumber
std::string serialNumber
The serial number of camera.
Definition: camera_definitions.h:193
CameraItof::m_noArgCallables
std::map< std::string, noArgCallable > m_noArgCallables
Definition: camera_itof.h:210
enabled
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: glcorearb.h:4174
param
GLenum GLfloat param
Definition: glcorearb.h:2769
GEN_XYZ_ITERATIONS
#define GEN_XYZ_ITERATIONS
Definition: tofiCompute.cpp:13
CameraItof::adsd3500SetFrameRate
aditof::Status adsd3500SetFrameRate(uint16_t fps) override
Set Frame Rate.
Definition: camera_itof.cpp:1800
begin
static size_t begin(const upb_table *t)
Definition: php/ext/google/protobuf/upb.c:4898
CameraItof::m_depthBitsPerPixel
uint8_t m_depthBitsPerPixel
Definition: camera_itof.h:234
aditof::ADSDErrors::GetStringADSD3500
std::string GetStringADSD3500(uint16_t value)
Returns a string for a given target (adsdType) and error code for the ADSD3500.
Definition: adsd_errs.h:123
cJSON_GetObjectItemCaseSensitive
cJSON_GetObjectItemCaseSensitive(const cJSON *const object, const char *const string)
Definition: cJSON.c:1739
CameraItof::m_depthSensor
std::shared_ptr< aditof::DepthSensorInterface > m_depthSensor
Definition: camera_itof.h:208
CameraItof::adsd3500GetGenericTemplate
aditof::Status adsd3500GetGenericTemplate(uint16_t reg, uint16_t &value) override
Generic ADSD3500 function for commands not defined in the SDK (yet)
Definition: camera_itof.cpp:1850
CameraItof::adsd3500GetImagerErrorCode
aditof::Status adsd3500GetImagerErrorCode(uint16_t &errcode) override
Get error code from the imager.
Definition: camera_itof.cpp:1754
CameraItof::m_depthINIDataMap
std::map< std::string, FileData > m_depthINIDataMap
Definition: camera_itof.h:224
aditof::ImagerType::UNSET
@ UNSET
Value for when the type is unset.
CameraItof::adsd3500SetGenericTemplate
aditof::Status adsd3500SetGenericTemplate(uint16_t reg, uint16_t value) override
Generic ADSD3500 function for commands not defined in the SDK (yet)
Definition: camera_itof.cpp:1845
CameraItof::m_adsd3500Enabled
bool m_adsd3500Enabled
Definition: camera_itof.h:216
aditof::FrameDetails::dataDetails
std::vector< FrameDataDetails > dataDetails
A frame can have multiple types of data. For example it could hold data about depth and/or data about...
Definition: frame_definitions.h:104
aditof::FrameDetails
Describes the properties of a frame.
Definition: frame_definitions.h:93
CameraItof::retrieveDepthProcessParams
aditof::Status retrieveDepthProcessParams()
Definition: camera_itof.cpp:1345
aditof::FrameDetails::height
unsigned int height
The height of the frame.
Definition: frame_definitions.h:119
aditof::Metadata
Contains all of the metadata components.
Definition: frame_definitions.h:147
aditof::SensorDetails::id
std::string id
The sensor identification data to be used to differentiate between sensors. When on target,...
Definition: sensor_definitions.h:55
aditof
Namespace aditof.
Definition: adsd_errs.h:40
imageSize
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei imageSize
Definition: glcorearb.h:2879
aditof::FrameDataDetails::subelementSize
unsigned int subelementSize
The size in bytes of a sub-element. A sub-element is a sub-component of an element....
Definition: frame_definitions.h:71
buffer
GLuint buffer
Definition: glcorearb.h:2939
CameraItof::adsd3500setEnableDynamicModeSwitching
aditof::Status adsd3500setEnableDynamicModeSwitching(bool en) override
Allows enabling or disabling the Dynamic Mode Switching. NOTE: This must be enabled before configurin...
Definition: camera_itof.cpp:2112
start
GLuint start
Definition: glcorearb.h:2858
CameraItof::m_adsd3500FwGitHash
std::pair< std::string, std::string > m_adsd3500FwGitHash
Definition: camera_itof.h:252
aditof::ImagerType
ImagerType
Types of imagers.
Definition: camera_definitions.h:200
update_failure_list.str
str
Definition: update_failure_list.py:41
google::protobuf::util::error::OK
@ OK
Definition: status.h:47
CameraItof::m_devStreaming
bool m_devStreaming
Definition: camera_itof.h:214
CameraItof::m_loadedConfigData
bool m_loadedConfigData
Definition: camera_itof.h:226
CameraItof::adsd3500SetVCSELDelay
aditof::Status adsd3500SetVCSELDelay(uint16_t delay) override
Set the delay for VCSEL - ADSD3100 imager only.
Definition: camera_itof.cpp:1759
p
const char * p
Definition: gmock-matchers_test.cc:3863
CameraItof::m_dropFirstFrame
bool m_dropFirstFrame
Definition: camera_itof.h:261
CameraItof::m_enableEdgeConfidence
int16_t m_enableEdgeConfidence
Definition: camera_itof.h:249
CameraItof::initialize
aditof::Status initialize(const std::string &configFilepath={}) override
Initialize the camera. This is required before performing any operation on the camera.
Definition: camera_itof.cpp:121
CameraItof::adsd3500GetJBLFfilterSize
aditof::Status adsd3500GetJBLFfilterSize(int &size) override
Get the JBLF filter size.
Definition: camera_itof.cpp:1720
CameraItof::m_adsd3500FwVersionInt
int m_adsd3500FwVersionInt
Definition: camera_itof.h:253
aditof::Frame::setDetails
SDK_API Status setDetails(const FrameDetails &details)
Configures the frame with the given details.
Definition: frame.cpp:57
aditof::FrameDataDetails
Describes the properties of a data that embedded within the frame.
Definition: frame_definitions.h:48
CameraItof::getAvailableControls
aditof::Status getAvailableControls(std::vector< std::string > &controls) const override
Gets the camera's list of controls.
Definition: camera_itof.cpp:808
params
GLenum const GLfloat * params
Definition: glcorearb.h:2770
CameraItof::getControl
aditof::Status getControl(const std::string &control, std::string &value) const override
Gets the value of a specific camera control.
Definition: camera_itof.cpp:840
chip_id
uint16_t chip_id
Definition: adsd3500_sensor.cpp:68
CameraItof::saveModuleCFG
aditof::Status saveModuleCFG(const std::string &filepath) const override
Save the CFG content which is obtained from module memory to a given file path.
Definition: camera_itof.cpp:967
cJSON
Definition: cJSON.h:105
camera_itof.h
TofiXYZDealiasData::row_bin_factor
uint8_t row_bin_factor
Definition: tofi_camera_intrinsics.h:38
aditof::Frame::getData
SDK_API Status getData(const std::string &dataType, uint16_t **dataPtr)
Gets the address where the specified data is being stored.
Definition: frame.cpp:70
cmd_header_t::cmd8
uint8_t cmd8
Definition: camera_itof.cpp:994
buffer
Definition: buffer_processor.h:43
d
d
CameraItof::adsd3500SetEnablePhaseInvalidation
aditof::Status adsd3500SetEnablePhaseInvalidation(uint16_t value) override
Set Enable Phase Invalidation.
Definition: camera_itof.cpp:1827
aditof::CameraDetails
Describes the properties of a camera.
Definition: camera_definitions.h:132
CameraItof::getFrameProcessParams
aditof::Status getFrameProcessParams(std::map< std::string, std::string > &params) override
Get the Depth Compute Library ini parameters.
Definition: camera_itof.cpp:538
CameraItof::m_pcmFrame
bool m_pcmFrame
Definition: camera_itof.h:239
CameraItof::adsd3500SetJBLFGaussianSigma
aditof::Status adsd3500SetJBLFGaussianSigma(uint16_t value) override
Set JBLF Gaussian Sigma.
Definition: camera_itof.cpp:1776
key
const SETUP_TEARDOWN_TESTCONTEXT char * key
Definition: test_wss_transport.cpp:10
CameraItof::adsd3500ResetIniParamsForMode
aditof::Status adsd3500ResetIniParamsForMode(const uint16_t mode) override
Reset the ini parameters from the chip and sets the ones stored in CCB.
Definition: camera_itof.cpp:564
CameraItof::adsd3500GetFirmwareVersion
aditof::Status adsd3500GetFirmwareVersion(std::string &fwVersion, std::string &fwHash) override
Definition: camera_itof.cpp:1654
google::protobuf::util::error::INVALID_ARGUMENT
@ INVALID_ARGUMENT
Definition: status.h:50
CameraItof::adsd3500GetConfidenceThreshold
aditof::Status adsd3500GetConfidenceThreshold(int &threshold) override
Get the confidence threshold.
Definition: camera_itof.cpp:1700
aditof::FrameDetails::totalCaptures
uint8_t totalCaptures
totalCaptures or subframes in a frame
Definition: frame_definitions.h:124
CameraItof::adsd3500GetVCSELDelay
aditof::Status adsd3500GetVCSELDelay(uint16_t &delay) override
Get the delay for VCSEL - ADSD3100 imager only.
Definition: camera_itof.cpp:1763
aditof::Frame::getDataDetails
SDK_API Status getDataDetails(const std::string &dataType, FrameDataDetails &details) const
Gets details of a type of data within the frame.
Definition: frame.cpp:65
frame.h
CameraItof::m_enableTempCompenstation
int16_t m_enableTempCompenstation
Definition: camera_itof.h:247
aditof::Status::INVALID_ARGUMENT
@ INVALID_ARGUMENT
Invalid arguments provided.
CameraItof::m_abBitsPerPixel
uint8_t m_abBitsPerPixel
Definition: camera_itof.h:235
aditof::ADSDErrors::ADSD3500_STATUS_IMAGER_ERROR
const uint16_t ADSD3500_STATUS_IMAGER_ERROR
The imager reported an error.
Definition: adsd_errs.h:223
FileData::size
size_t size
Definition: tofi_util.h:66
aditof::Status
Status
Status of any operation that the TOF sdk performs.
Definition: status_definitions.h:48
CameraItof::m_initConfigFilePath
std::string m_initConfigFilePath
Definition: camera_itof.h:259
i
int i
Definition: gmock-matchers_test.cc:764
CameraItof::m_adsd3500Status
aditof::Adsd3500Status m_adsd3500Status
Definition: camera_itof.h:256
CameraItof::adsd3500GetRadialThresholdMin
aditof::Status adsd3500GetRadialThresholdMin(int &threshold) override
Get the radial threshold min.
Definition: camera_itof.cpp:1729
CameraItof::adsd3500GetLaserTemperature
aditof::Status adsd3500GetLaserTemperature(uint16_t &tmpValue) override
Get the laser temperature.
Definition: camera_itof.cpp:1933
CameraItof::getSensor
std::shared_ptr< aditof::DepthSensorInterface > getSensor() override
Gets the sensor of the camera. This gives direct access to low level configuration of the camera sens...
Definition: camera_itof.cpp:803
aditof::Frame::getDetails
SDK_API Status getDetails(FrameDetails &details) const
Gets the current details of the frame.
Definition: frame.cpp:61
CameraItof::m_confBitsPerPixel
uint8_t m_confBitsPerPixel
Definition: camera_itof.h:236
aditof::DepthSensorModeDetails::baseResolutionWidth
int baseResolutionWidth
Processed data witdh.
Definition: sensor_definitions.h:155
Algorithms::GenerateXYZTables
static uint32_t GenerateXYZTables(const float **pp_x_table, const float **pp_y_table, const float **pp_z_table, CameraIntrinsics *p_intr_data, uint32_t n_sensor_rows, uint32_t n_sensor_cols, uint32_t n_out_rows, uint32_t n_out_cols, uint32_t n_offset_rows, uint32_t n_offset_cols, uint8_t row_bin_factor, uint8_t col_bin_factor, uint8_t iter)
Definition: algorithms.cpp:30
CameraItof::m_dropFrameOnce
bool m_dropFrameOnce
Definition: camera_itof.h:262
LOG
#define LOG(x)
Definition: sdk/include/aditof/log.h:72
TofiXYZDealiasData::n_sensor_cols
uint16_t n_sensor_cols
Definition: tofi_camera_intrinsics.h:43
tofi_config.h
cmd_header_t::id8
uint8_t id8
Definition: camera_itof.cpp:992
FloatToLinGenerateTable
void FloatToLinGenerateTable()
Definition: floatTolin.h:40
CameraItof::m_fsyncMode
int16_t m_fsyncMode
Definition: camera_itof.h:245
CameraItof::adsd3500SetMIPIOutputSpeed
aditof::Status adsd3500SetMIPIOutputSpeed(uint16_t speed) override
Set ADSD3500 MIPI output speed.
Definition: camera_itof.cpp:1745
XYZTable::p_y_table
const float * p_y_table
Pointer to the radial correction Y Table.
Definition: tofi_config.h:36
aditof::Status::OK
@ OK
Success.
CameraItof::adsd3500GetMIPIOutputSpeed
aditof::Status adsd3500GetMIPIOutputSpeed(uint16_t &speed) override
Get ADSD3500 MIPI output speed.
Definition: camera_itof.cpp:1749
CameraItof::adsd3500GetRadialThresholdMax
aditof::Status adsd3500GetRadialThresholdMax(int &threshold) override
Get the radial threshold max.
Definition: camera_itof.cpp:1739
CameraItof::adsd3500GetTemperatureCompensationStatus
aditof::Status adsd3500GetTemperatureCompensationStatus(uint16_t &value) override
Get Temperature Compensation Status.
Definition: camera_itof.cpp:1822
CameraItof::m_adsdErrors
aditof::ADSDErrors m_adsdErrors
Definition: camera_itof.h:211
CameraItof::adsd3500SetEnableEdgeConfidence
aditof::Status adsd3500SetEnableEdgeConfidence(uint16_t value) override
Set Enable Edge Confidence.
Definition: camera_itof.cpp:1817
skMetaDataBytesCount
static const int skMetaDataBytesCount
Definition: camera_itof.cpp:65
Algorithms::ComputeXYZ
static uint32_t ComputeXYZ(const uint16_t *p_depth, XYZTable *p_xyz_data, int16_t *p_xyz_image, uint32_t n_rows, uint32_t n_cols)
Definition: algorithms.cpp:161
CameraItof::getAvailableModes
aditof::Status getAvailableModes(std::vector< uint8_t > &availableModes) const override
Returns all the modes that are supported by the camera.
Definition: camera_itof.cpp:569
size
GLsizeiptr size
Definition: glcorearb.h:2943
CameraItof::m_ccb_calibrationFile
std::string m_ccb_calibrationFile
Definition: camera_itof.h:229
aditof::DepthSensorModeDetails
Describes the type of entire frame that a depth sensor can capture and transmit.
Definition: sensor_definitions.h:120
CameraItof::~CameraItof
~CameraItof()
Definition: camera_itof.cpp:115
aditof::Frame::getMetadataStruct
virtual SDK_API Status getMetadataStruct(Metadata &metadata) const
Extracts the metadata content and returns a struct with values.
Definition: frame.cpp:74
TofiXYZDealiasData::n_offset_rows
uint16_t n_offset_rows
Definition: tofi_camera_intrinsics.h:40
cmd_header_t
Definition: camera_itof.cpp:989
aditof::CameraDetails::frameType
FrameDetails frameType
Details about the frames that camera is capturing.
Definition: camera_definitions.h:146
CameraIntrinsics
Definition: tofi_camera_intrinsics.h:16
cJSON_AddStringToObject
cJSON_AddStringToObject(cJSON *const object, const char *const name, const char *const string)
Definition: cJSON.c:1947
CameraItof::m_calData
FileData m_calData
Definition: camera_itof.h:221
first
GLint first
Definition: glcorearb.h:2830
CameraItof::start
aditof::Status start() override
Start the camera. This starts the streaming of data from the camera.
Definition: camera_itof.cpp:302
TofiXYZDealiasData::n_sensor_rows
uint16_t n_sensor_rows
Definition: tofi_camera_intrinsics.h:42
frame_operations.h
CameraItof::m_xyz_dealias_data
TofiXYZDealiasData m_xyz_dealias_data[MAX_N_MODES+1]
Definition: camera_itof.h:225
aditof::DepthSensorModeDetails::frameWidthInBytes
int frameWidthInBytes
Driver width, can be used for both chipRaw and imagerRaw.
Definition: sensor_definitions.h:145
CameraItof::adsd3500GetJBLFfilterEnableState
aditof::Status adsd3500GetJBLFfilterEnableState(bool &enabled) override
Get the JBLF enabled state.
Definition: camera_itof.cpp:1709
XYZTable::p_x_table
const float * p_x_table
Pointer to the radial correction X Table.
Definition: tofi_config.h:35
CameraItof::CameraItof
CameraItof(std::shared_ptr< aditof::DepthSensorInterface > depthSensor, const std::string &ubootVersion, const std::string &kernelVersion, const std::string &sdCardImageVersion, const std::string &netLinkTest)
Definition: camera_itof.cpp:67
TofiXYZDealiasData
Definition: tofi_camera_intrinsics.h:34
CameraItof::setMode
aditof::Status setMode(const uint8_t &mode) override
Puts the camera into the given mode.
Definition: camera_itof.cpp:328
aditof::Frame
Frame of a camera.
Definition: frame.h:50
CameraItof::adsd3500SetJBLFfilterSize
aditof::Status adsd3500SetJBLFfilterSize(int size) override
Set the JBLF filter size.
Definition: camera_itof.cpp:1717
true
#define true
Definition: cJSON.c:65
CameraItof::dropFirstFrame
void dropFirstFrame(bool dropFrame) override
Allow drop first frame.
Definition: camera_itof.cpp:1607
aditof::SensorDetails::connectionType
ConnectionType connectionType
The type of connection with the sensor.
Definition: sensor_definitions.h:60
CameraItof::adsd3500GetFrameRate
aditof::Status adsd3500GetFrameRate(uint16_t &fps) override
Get Frame Rate.
Definition: camera_itof.cpp:1795
CameraItof::normalizeABBuffer
void normalizeABBuffer(uint16_t *abBuffer, uint16_t abWidth, uint16_t abHeight, bool advanceScaling, bool useLogScaling) override
Scale AB image with logarithmic base 10.
Definition: camera_itof.cpp:681
CameraItof::stop
aditof::Status stop() override
Stop the camera. This makes the camera to stop streaming.
Definition: camera_itof.cpp:315
cmd_header_t::crc_of_fw32
uint32_t crc_of_fw32
Definition: camera_itof.cpp:997
value
GLsizei const GLfloat * value
Definition: glcorearb.h:3093
aditof::FrameDataDetails::bytesCount
unsigned int bytesCount
The total number of bytes that the data has. This can be useful when copying data to another location...
Definition: frame_definitions.h:86
CameraItof::saveDepthParamsToJsonFile
aditof::Status saveDepthParamsToJsonFile(const std::string &savePathFile) override
Save ini file to json format.
Definition: camera_itof.cpp:1367
aditof::ControlValue
const std::map< ImagerType, std::string > ControlValue
Types of imagers based on ControlValue.
Definition: camera_definitions.h:211
CameraItof::cleanupXYZtables
void cleanupXYZtables()
Delete allocated tables for X, Y, Z.
Definition: camera_itof.cpp:2091
binary
const GLuint GLenum const GLvoid * binary
Definition: glcorearb.h:3962
CameraItof::adsd3500SetRadialThresholdMax
aditof::Status adsd3500SetRadialThresholdMax(int threshold) override
Set the radial threshold max.
Definition: camera_itof.cpp:1735
CameraItof::adsd3500GetABinvalidationThreshold
aditof::Status adsd3500GetABinvalidationThreshold(int &threshold) override
Get the AB invalidation threshold.
Definition: camera_itof.cpp:1691
false
#define false
Definition: cJSON.c:70
FileData::p_data
unsigned char * p_data
Definition: tofi_util.h:65
aditof::imagerType
const std::map< ImagerType, std::string > imagerType
Types of imagers.
Definition: camera_definitions.h:218
aditof::CameraDetails::connection
ConnectionType connection
The type of connection with the camera.
Definition: camera_definitions.h:151
CameraItof::isConvertibleToDouble
bool isConvertibleToDouble(const std::string &str)
Check if string can convert to double.
Definition: camera_itof.cpp:1597
CameraItof::adsd3500SetABinvalidationThreshold
aditof::Status adsd3500SetABinvalidationThreshold(int threshold) override
Set the AB invalidation threshold.
Definition: camera_itof.cpp:1687
cJSON_AddNumberToObject
cJSON_AddNumberToObject(cJSON *const object, const char *const name, const double number)
Definition: cJSON.c:1935
aditof::FrameDataDetails::height
unsigned int height
The height of the frame data.
Definition: frame_definitions.h:63
CameraItof::m_iniKeyValPairs
std::map< std::string, std::string > m_iniKeyValPairs
Definition: camera_itof.h:250
it
MapIter it
Definition: php/ext/google/protobuf/map.c:205
floatTolin.h
CameraItof::adsd3500DisableCCBM
aditof::Status adsd3500DisableCCBM(bool disable) override
Enable/disable ccb as master.
Definition: camera_itof.cpp:1856
CameraItof::m_xyzSetViaApi
bool m_xyzSetViaApi
Definition: camera_itof.h:238
cmd_header_t::cmd_header_byte
uint8_t cmd_header_byte[16]
Definition: camera_itof.cpp:990
CameraItof::adsd3500SetJBLFExponentialTerm
aditof::Status adsd3500SetJBLFExponentialTerm(uint16_t value) override
Set JBLF Exponential Term.
Definition: camera_itof.cpp:1786
CameraItof::adsd3500SetJBLFMaxEdgeThreshold
aditof::Status adsd3500SetJBLFMaxEdgeThreshold(uint16_t threshold) override
Set JBLF Max Edge Threshold.
Definition: camera_itof.cpp:1768
CameraItof::m_configDmsSequence
std::vector< std::pair< uint8_t, uint8_t > > m_configDmsSequence
Definition: camera_itof.h:263
XYZTable::p_z_table
const float * p_z_table
Pointer to the radial correction Z Table.
Definition: tofi_config.h:37
CameraItof::adsd3500UpdateFirmware
aditof::Status adsd3500UpdateFirmware(const std::string &filePath) override
Update the firmware of ADSD3500 with the content found in the specified file.
Definition: camera_itof.cpp:1003
CameraItof::adsd3500GetJBLFExponentialTerm
aditof::Status adsd3500GetJBLFExponentialTerm(uint16_t &value) override
Get JBLF Exponential Term.
Definition: camera_itof.cpp:1790
CameraItof::adsds3500setDynamicModeSwitchingSequence
aditof::Status adsds3500setDynamicModeSwitchingSequence(const std::vector< std::pair< uint8_t, uint8_t >> &sequence) override
Configures the sequence to be captured.
Definition: camera_itof.cpp:2117
aditof::CameraDetails::intrinsics
IntrinsicParameters intrinsics
Details about the intrinsic parameters of the camera.
Definition: camera_definitions.h:156
aditof::SensorInterruptCallback
std::function< void(Adsd3500Status)> SensorInterruptCallback
Callback for sensor interrupts.
Definition: depth_sensor_interface.h:50
CameraItof::loadConfigData
aditof::Status loadConfigData(void)
Opens the CCB file passed in as part of Json file using initialize(), and loads the calibration block...
Definition: camera_itof.cpp:855


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:48