usb_depth_sensor_windows.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  */
34 #include "usb_buffer.pb.h"
35 #include "usb_windows_utils.h"
36 
38 #include <atlstr.h>
39 #ifdef USE_GLOG
40 #include <glog/logging.h>
41 #else
42 #include <aditof/log.h>
43 #endif
44 #include <unordered_map>
45 
46 struct CalibrationData {
48  float gain;
49  float offset;
50  uint16_t *cache;
51 };
52 
55  bool opened;
56  std::unordered_map<std::string, CalibrationData> calibration_cache;
57 };
58 
59 static std::wstring s2ws(const std::string &s) {
60  int len;
61  int slength = (int)s.length() + 1;
62  len = MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, nullptr, 0);
63  wchar_t *buf = new wchar_t[len];
64  MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, buf, len);
66  delete[] buf;
67  return r;
68 }
69 
70 static aditof::Status getDevice(IBaseFilter **pVideoInputFilter,
71  const std::string &devName) {
72  using namespace aditof;
73  Status status = Status::OK;
74 
75  HRESULT hr;
76  BOOL done = FALSE;
77  ICreateDevEnum *DevEnum = nullptr;
78 
79  hr = CoCreateInstance(CLSID_SystemDeviceEnum, nullptr, CLSCTX_INPROC_SERVER,
80  IID_PPV_ARGS(&DevEnum));
81  if (FAILED(hr)) {
82  LOG(WARNING) << "Create Device Enumeration Failed";
83  return Status::GENERIC_ERROR;
84  }
85 
86  IEnumMoniker *EnumMoniker = nullptr;
87  hr = DevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory,
88  &EnumMoniker, 0);
89 
90  if (hr != S_OK) {
91  DevEnum->Release();
92  LOG(WARNING) << "Device Enumeration Error";
93  return Status::GENERIC_ERROR;
94  }
95 
96  IMoniker *Moniker = nullptr;
97  ULONG cFetched;
98  while (!done && EnumMoniker->Next(1, &Moniker, &cFetched) == S_OK) {
99  IPropertyBag *PropBag;
100  hr = Moniker->BindToStorage(nullptr, nullptr, IID_PPV_ARGS(&PropBag));
101 
102  if (SUCCEEDED(hr)) {
103  VARIANT varName;
104  VariantInit(&varName);
105  hr = PropBag->Read(L"FriendlyName", &varName, nullptr);
106 
107  if (SUCCEEDED(hr)) {
108  std::string str(static_cast<LPCTSTR>(CString(varName.bstrVal)));
109  if (str == devName) {
110  // We found it, so send it back to the caller
111  hr =
112  Moniker->BindToObject(nullptr, nullptr, IID_IBaseFilter,
113  (void **)pVideoInputFilter);
114  if (!SUCCEEDED(hr)) {
115  LOG(WARNING) << "Failed to bind video input filter";
116  }
117 
118  done = TRUE;
119  }
120  }
121  VariantClear(&varName);
122  PropBag->Release();
123  PropBag = nullptr;
124  }
125 
126  Moniker->Release();
127  Moniker = nullptr;
128  }
129 
130  EnumMoniker->Release();
131  DevEnum->Release();
132 
133  return status;
134 }
135 
136 static bool checkSingleByteFormat(GUID FormatType) {
137  bool IsSingleByteFormat = true;
138 
139  if (FormatType == MEDIASUBTYPE_Y800 || FormatType == MEDIASUBTYPE_Y8 ||
140  FormatType == MEDIASUBTYPE_GREY || FormatType == MEDIASUBTYPE_BY8) {
141  IsSingleByteFormat = true;
142  } else {
143  IsSingleByteFormat = false;
144  }
145 
146  return IsSingleByteFormat;
147 }
148 
149 static void NukeDownstream(IBaseFilter *pBF, IGraphBuilder *pGraph) {
150  IPin *pP, *pTo;
151  ULONG u;
152  IEnumPins *pins = nullptr;
153  PIN_INFO pininfo;
154  HRESULT hr = pBF->EnumPins(&pins);
155  pins->Reset();
156  while (hr == NOERROR) {
157  hr = pins->Next(1, &pP, &u);
158  if (hr == S_OK && pP) {
159  pP->ConnectedTo(&pTo);
160  if (pTo) {
161  hr = pTo->QueryPinInfo(&pininfo);
162  if (hr == NOERROR) {
163  if (pininfo.dir == PINDIR_INPUT) {
164  NukeDownstream(pininfo.pFilter, pGraph);
165  pGraph->Disconnect(pTo);
166  pGraph->Disconnect(pP);
167  pGraph->RemoveFilter(pininfo.pFilter);
168  }
169  pininfo.pFilter->Release();
170  pininfo.pFilter = nullptr;
171  }
172  pTo->Release();
173  }
174  pP->Release();
175  }
176  }
177  if (pins)
178  pins->Release();
179 }
180 
181 static void destroyGraph(IGraphBuilder *pGraph) {
182  HRESULT hr = 0;
183  int i = 0;
184 
185  while (hr == NOERROR) {
186  IEnumFilters *pEnum = nullptr;
187  ULONG cFetched;
188 
189  // We must get the enumerator again every time because removing a filter
190  // from the graph invalidates the enumerator. We always get only the
191  // first filter from each enumerator.
192  hr = pGraph->EnumFilters(&pEnum);
193 
194  IBaseFilter *pFilter = nullptr;
195 
196  if (pEnum->Next(1, &pFilter, &cFetched) == S_OK) {
197  FILTER_INFO FilterInfo;
198  memset(&FilterInfo, 0, sizeof(FilterInfo));
199  hr = pFilter->QueryFilterInfo(&FilterInfo);
200  FilterInfo.pGraph->Release();
201 
202  int count = 0;
203  char buffer[255];
204  memset(buffer, 0, 255 * sizeof(char));
205 
206  while (FilterInfo.achName[count] != 0x00) {
207  buffer[count] = (char)FilterInfo.achName[count];
208  count++;
209  }
210 
211  hr = pGraph->RemoveFilter(pFilter);
212  if (FAILED(hr)) {
213  LOG(WARNING) << "SETUP: pGraph->RemoveFilter() failed.";
214  }
215 
216  pFilter->Release();
217  pFilter = nullptr;
218  } else
219  break;
220  pEnum->Release();
221  pEnum = nullptr;
222  i++;
223  }
224 
225  return;
226 }
227 
229  const std::string &driverPath)
230  : m_driverPath(driverPath), m_implData(new UsbDepthSensor::ImplData) {
231  m_implData->handle.pMediaEvent = nullptr;
232  m_implData->opened = false;
233 
234  m_sensorDetails.connectionType = aditof::ConnectionType::USB;
235  m_sensorName = name;
236 }
237 
239  HRESULT HR = NOERROR;
240 
241  // Check to see if the graph is running, if so stop it.
242  if (m_implData->handle.pControl) {
243  HR = m_implData->handle.pControl->Pause();
244 
245  HR = m_implData->handle.pControl->Stop();
246  }
247 
248  for (auto it = m_implData->calibration_cache.begin();
249  it != m_implData->calibration_cache.begin(); ++it) {
250  delete[] it->second.cache;
251  it->second.cache = nullptr;
252  }
253 
254  // Disconnect filters from capture device
255  if (m_implData->handle.pVideoInputFilter) {
256  NukeDownstream(m_implData->handle.pVideoInputFilter,
257  m_implData->handle.pGraph);
258  }
259 
260  // Release and zero pointers to our filters etc
261  if (m_implData->handle.pDestFilter) {
262  m_implData->handle.pDestFilter->Release();
263  }
264 
265  if (m_implData->handle.pVideoInputFilter) {
266  m_implData->handle.pVideoInputFilter->Release();
267  }
268 
269  if (m_implData->handle.pGrabberF) {
270  m_implData->handle.pGrabberF->Release();
271  }
272 
273  if (m_implData->handle.pGrabber) {
274  m_implData->handle.pGrabber->Release();
275  }
276 
277  if (m_implData->handle.pControl) {
278  m_implData->handle.pControl->Release();
279  }
280 
281  if (m_implData->handle.pMediaEvent) {
282  m_implData->handle.pMediaEvent->Release();
283  }
284 
285  if (m_implData->handle.streamConf) {
286  m_implData->handle.streamConf->Release();
287  }
288 
289  if (m_implData->handle.pAmMediaType) {
290  if (m_implData->handle.pAmMediaType->cbFormat != 0) {
291  CoTaskMemFree((PVOID)m_implData->handle.pAmMediaType->pbFormat);
292  m_implData->handle.pAmMediaType->cbFormat = 0;
293  m_implData->handle.pAmMediaType->pbFormat = nullptr;
294  }
295  if (m_implData->handle.pAmMediaType->pUnk != nullptr) {
296  // Unecessary because pUnk should not be used, but safest.
297  m_implData->handle.pAmMediaType->pUnk->Release();
298  m_implData->handle.pAmMediaType->pUnk = nullptr;
299  }
300  CoTaskMemFree(m_implData->handle.pAmMediaType);
301  }
302 
303  // Destroy the graph
304  if (m_implData->handle.pGraph) {
305  destroyGraph(m_implData->handle.pGraph);
306  }
307 
308  // Release and zero our capture graph and our main graph
309  if (m_implData->handle.pCaptureGraph) {
310  m_implData->handle.pCaptureGraph->Release();
311  }
312  if (m_implData->handle.pGraph) {
313  m_implData->handle.pGraph->Release();
314  }
315 }
316 
318  using namespace aditof;
319  Status status = Status::OK;
320 
321  LOG(INFO) << "Opening device";
322 
323  HRESULT hr;
324  GUID CAPTURE_MODE = PIN_CATEGORY_CAPTURE;
325 
326  hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
327 
328  hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, nullptr,
329  CLSCTX_INPROC_SERVER, IID_ICaptureGraphBuilder2,
330  (void **)&(m_implData->handle.pCaptureGraph));
331  if (FAILED(hr)) {
332  LOG(WARNING) << "Failed CoCreateInstance(CLSID_CaptureGraphBuilder2)";
333  return Status::GENERIC_ERROR;
334  }
335 
336  hr = CoCreateInstance(CLSID_FilterGraph, nullptr, CLSCTX_INPROC_SERVER,
337  IID_IGraphBuilder,
338  (void **)&(m_implData->handle.pGraph));
339  if (FAILED(hr)) {
340  LOG(WARNING) << "Failed CoCreateInstance(CLSID_FilterGraph)";
341  return Status::GENERIC_ERROR;
342  }
343 
344  hr = m_implData->handle.pCaptureGraph->SetFiltergraph(
345  m_implData->handle.pGraph);
346  if (FAILED(hr)) {
347  LOG(WARNING) << "Failed SetFiltergraph";
348  return Status::GENERIC_ERROR;
349  }
350 
351  hr = m_implData->handle.pGraph->QueryInterface(
352  IID_IMediaControl, (void **)&(m_implData->handle.pControl));
353  if (FAILED(hr)) {
354  LOG(WARNING) << "Failed QueryInterface(IID_IMediaControl)";
355  return Status::GENERIC_ERROR;
356  }
357 
358  status = getDevice(&m_implData->handle.pVideoInputFilter, m_driverPath);
359  if (status != Status::OK) {
360  return status;
361  }
362 
363  // Query the target about the frame types that are supported by the depth sensor
364 
365  // Send request
366  usb_payload::ClientRequest requestMsg;
367  requestMsg.set_func_name(usb_payload::FunctionName::GET_AVAILABLE_MODES);
368  std::string requestStr;
369  requestMsg.SerializeToString(&requestStr);
371  m_implData->handle.pVideoInputFilter, requestStr);
372  if (status != aditof::Status::OK) {
373  LOG(ERROR) << "Request to get available frame types failed";
374  return status;
375  }
376 
377  // Read UVC gadget response
380  m_implData->handle.pVideoInputFilter, responseStr);
381  if (status != aditof::Status::OK) {
382  LOG(ERROR) << "Response for get available frame types request failed";
383  return status;
384  }
385  usb_payload::ServerResponse responseMsg;
386  bool parsed = responseMsg.ParseFromString(responseStr);
387  if (!parsed) {
388  LOG(ERROR)
389  << "Failed to deserialize string containing UVC gadget response";
391  }
392 
393  if (responseMsg.status() != usb_payload::Status::OK) {
394  LOG(ERROR)
395  << "Get available frame types operation failed on UVC gadget";
396  return static_cast<aditof::Status>(responseMsg.status());
397  }
398 
399  // If request and response went well, extract data from response
401  m_depthSensorModes, responseMsg.available_mode_details());
402 
403  std::wstring stemp = s2ws(m_driverPath);
404  hr = m_implData->handle.pGraph->AddFilter(
405  m_implData->handle.pVideoInputFilter, stemp.c_str());
406  if (FAILED(hr)) {
407  LOG(WARNING) << "ADI TOF Camera cannot be opened";
408  return Status::GENERIC_ERROR;
409  }
410 
411  IAMStreamConfig *streamConfTest = nullptr;
412  hr = m_implData->handle.pCaptureGraph->FindInterface(
413  &PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video,
414  m_implData->handle.pVideoInputFilter, IID_IAMStreamConfig,
415  (void **)&streamConfTest);
416  if (FAILED(hr)) {
417  // TO DO: old IO library allowed this to fail. Investigate why. Until then don't bother showing this error.
418  // LOG(WARNING) << "Failed FindInterface(PIN_CATEGORY_PREVIEW)";
419  } else {
420  CAPTURE_MODE = PIN_CATEGORY_PREVIEW;
421  streamConfTest->Release();
422  streamConfTest = nullptr;
423  }
424 
425  hr = m_implData->handle.pCaptureGraph->FindInterface(
426  &CAPTURE_MODE, &MEDIATYPE_Video, m_implData->handle.pVideoInputFilter,
427  IID_IAMStreamConfig, (void **)&(m_implData->handle.streamConf));
428  if (FAILED(hr)) {
429  LOG(WARNING) << "Failed FindInterface(CAPTURE_MODE)";
430  return Status::GENERIC_ERROR;
431  }
432 
433  hr = m_implData->handle.streamConf->GetFormat(
434  &(m_implData->handle.pAmMediaType));
435  if (FAILED(hr)) {
436  LOG(WARNING) << "Failed to get format from streamConf";
437  return Status::GENERIC_ERROR;
438  }
439 
440  hr = CoCreateInstance(CLSID_SampleGrabber, nullptr, CLSCTX_INPROC_SERVER,
441  IID_IBaseFilter,
442  (void **)&(m_implData->handle.pGrabberF));
443  if (FAILED(hr)) {
444  LOG(WARNING) << "Could not Create Sample Grabber - CoCreateInstance()";
445  return Status::GENERIC_ERROR;
446  }
447 
448  hr = m_implData->handle.pGraph->AddFilter(m_implData->handle.pGrabberF,
449  L"Sample Grabber");
450  if (FAILED(hr)) {
451  LOG(WARNING) << "Could not add Sample Grabber - AddFilter()";
452  return Status::GENERIC_ERROR;
453  }
454 
455  hr = m_implData->handle.pGrabberF->QueryInterface(
456  IID_ISampleGrabber, (void **)&(m_implData->handle.pGrabber));
457  if (FAILED(hr)) {
458  LOG(WARNING) << "ERROR: Could not query SampleGrabber";
459  return Status::GENERIC_ERROR;
460  }
461 
462  hr = m_implData->handle.pGrabber->SetOneShot(FALSE);
463  hr = m_implData->handle.pGrabber->SetBufferSamples(TRUE);
464  if (FAILED(hr)) {
465  LOG(WARNING) << "Fail SetBuffer";
466  return Status::GENERIC_ERROR;
467  }
468 
469  AM_MEDIA_TYPE mt;
470  ZeroMemory(&mt, sizeof(AM_MEDIA_TYPE));
471 
472  mt.majortype = MEDIATYPE_Video;
473  // Included conditional based format for Y16
474  if (checkSingleByteFormat(m_implData->handle.pAmMediaType->subtype) ||
475  (m_implData->handle.pAmMediaType->subtype == MEDIASUBTYPE_Y16)) {
476  mt.subtype = m_implData->handle.pAmMediaType->subtype;
477  } else
478  mt.subtype = MEDIASUBTYPE_RGB24; // Making it RGB24, does conversion
479  // from YUV to RGB Included conditional
480  // based format for Y16 - end
481 
482  mt.formattype = FORMAT_VideoInfo;
483 
484  hr = m_implData->handle.pGrabber->SetMediaType(&mt);
485 
486  // NULL RENDERER//
487  // used to give the video stream somewhere to go to.
488  hr = CoCreateInstance(CLSID_NullRenderer, nullptr, CLSCTX_INPROC_SERVER,
489  IID_IBaseFilter,
490  (void **)(&(m_implData->handle.pDestFilter)));
491  if (FAILED(hr)) {
492  LOG(WARNING) << "ERROR: Could not create filter - NullRenderer";
493  return Status::GENERIC_ERROR;
494  }
495 
496  hr = m_implData->handle.pGraph->AddFilter(m_implData->handle.pDestFilter,
497  L"NullRenderer");
498  if (FAILED(hr)) {
499  LOG(WARNING) << "ERROR: Could not add filter - NullRenderer";
500  return Status::GENERIC_ERROR;
501  }
502 
503  // RENDER STREAM//
504  // This is where the stream gets put together.
505  hr = m_implData->handle.pCaptureGraph->RenderStream(
506  &PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video,
507  m_implData->handle.pVideoInputFilter, m_implData->handle.pGrabberF,
508  m_implData->handle.pDestFilter);
509 
510  if (FAILED(hr)) {
511  LOG(WARNING) << "ERROR: Could not connect pins - RenderStream()";
512  return Status::GENERIC_ERROR;
513  }
514 
515  // Try setting the sync source to null - and make it run as fast as possible
516  IMediaFilter *pMediaFilter = nullptr;
517  hr = m_implData->handle.pGraph->QueryInterface(IID_IMediaFilter,
518  (void **)&pMediaFilter);
519  if (FAILED(hr)) {
520  LOG(WARNING) << "ERROR: Could not get IID_IMediaFilter interface";
521  return Status::GENERIC_ERROR;
522  } else {
523  pMediaFilter->SetSyncSource(nullptr);
524  pMediaFilter->Release();
525  }
526 
527  m_implData->handle.pCB = new SampleGrabberCallback();
528  hr = m_implData->handle.pGrabber->SetCallback(m_implData->handle.pCB, 1);
529 
530  m_implData->opened = true;
531 
532  return status;
533 }
534 
536  using namespace aditof;
537  Status status = Status::OK;
538 
539  // Construct request message
540  usb_payload::ClientRequest requestMsg;
541  requestMsg.set_func_name(usb_payload::FunctionName::START);
542 
543  // Send request
544  std::string requestStr;
545  requestMsg.SerializeToString(&requestStr);
547  m_implData->handle.pVideoInputFilter, requestStr);
548  if (status != aditof::Status::OK) {
549  LOG(ERROR) << "Request to write registers failed";
550  return status;
551  }
552 
553  // Read UVC gadget response
556  m_implData->handle.pVideoInputFilter, responseStr);
557  if (status != aditof::Status::OK) {
558  LOG(ERROR)
559  << "Failed to get response of the request to write registers";
560  return status;
561  }
562  usb_payload::ServerResponse responseMsg;
563  bool parsed = responseMsg.ParseFromString(responseStr);
564  if (!parsed) {
565  LOG(ERROR)
566  << "Failed to deserialize string containing UVC gadget response";
568  }
569 
570  if (responseMsg.status() != usb_payload::Status::OK) {
571  LOG(ERROR) << "Read registers operation failed on UVC gadget";
572  return static_cast<aditof::Status>(responseMsg.status());
573  }
574 
575  if (nullptr == m_implData->handle.pControl) {
576  LOG(WARNING) << "USB interface not active";
577  return Status::UNAVAILABLE;
578  }
579 
580  // RUN THE STREAM
581  HRESULT hr = m_implData->handle.pControl->Run();
582  if (FAILED(hr)) {
583  LOG(WARNING) << "ERROR: Could not start graph";
584  return Status::GENERIC_ERROR;
585  }
586 
587  return status;
588 }
589 
591  using namespace aditof;
592  Status status = Status::OK;
593 
594  LOG(INFO) << "Stopping device";
595 
596  if (nullptr == m_implData->handle.pControl) {
597  LOG(WARNING) << "USB interface not active";
598  return Status::UNAVAILABLE;
599  }
600 
601  HRESULT hr = m_implData->handle.pControl->Stop();
602  if (FAILED(hr)) {
603  LOG(WARNING) << "ERROR: Could not stop graph";
604  return Status::GENERIC_ERROR;
605  }
606 
607  return status;
608 }
609 
610 aditof::Status UsbDepthSensor::getAvailableModes(std::vector<uint8_t> &modes) {
611  modes.clear();
612  for (const auto &mode : m_depthSensorModes) {
613  modes.emplace_back(mode.modeNumber);
614  }
615  return aditof::Status::OK;
616 }
617 
619 UsbDepthSensor::getModeDetails(const uint8_t &mode,
621  // TO DO: Get information from the camera
622  using namespace aditof;
623  Status status = Status::OK;
624  for (const auto &modeDetails : m_depthSensorModes) {
625  if (modeDetails.modeNumber == mode) {
626  details = modeDetails;
627  break;
628  }
629  }
630  return status;
631 }
632 
635 }
636 
639  using namespace aditof;
640  Status status = Status::OK;
641  HRESULT hr = m_implData->handle.streamConf->GetFormat(
642  &(m_implData->handle.pAmMediaType));
643  if (FAILED(hr)) {
644  LOG(WARNING) << "failed 7";
645  return Status::GENERIC_ERROR;
646  }
647  // Send the frame type and all its content all the way to target
648  usb_payload::ClientRequest requestMsg;
649  auto frameTypeMsg = requestMsg.mutable_mode_details();
651  // Send request
652  requestMsg.set_func_name(usb_payload::FunctionName::SET_MODE);
653  std::string requestStr;
654  requestMsg.SerializeToString(&requestStr);
656  m_implData->handle.pVideoInputFilter, requestStr);
657  if (status != aditof::Status::OK) {
658  LOG(ERROR) << "Set frame type operation failed on UVC gadget";
659  return status;
660  }
661  VIDEOINFOHEADER *pVih = reinterpret_cast<VIDEOINFOHEADER *>(
662  m_implData->handle.pAmMediaType->pbFormat);
663  //HEADER(pVih)->biWidth = type.width * 2;
664  //HEADER(pVih)->biHeight = type.height;
665  //hr = m_implData->handle.streamConf->SetFormat(
666  // m_implData->handle.pAmMediaType);
667  //if (FAILED(hr)) {
668  // LOG(WARNING) << "Could not set requested resolution (Frame Index)\n";
669  // return Status::GENERIC_ERROR;
670  //}
671  return status;
672 }
673 
675  using namespace aditof;
676  Status status = Status::OK;
677 
678  int retryCount = 0;
679  HRESULT hr;
680 
681  usb_payload::ClientRequest requestMsg;
682  // Send request
683  requestMsg.set_func_name(usb_payload::FunctionName::PROCESS_FRAME);
684  std::string requestStr;
685  requestMsg.SerializeToString(&requestStr);
687  m_implData->handle.pVideoInputFilter, requestStr);
688  if (status != aditof::Status::OK) {
689  LOG(ERROR) << "Failed to process frame on target!";
690  return status;
691  }
692 
693  VIDEOINFOHEADER *pVi = reinterpret_cast<VIDEOINFOHEADER *>(
694  m_implData->handle.pAmMediaType->pbFormat);
695  int currentWidth = HEADER(pVi)->biWidth * 2;
696  int currentHeight = HEADER(pVi)->biHeight * 2;
697 
698  while (retryCount < 1000) {
699  if (m_implData->handle.pCB->newFrame == 1) {
700  long bufferSize = currentWidth * currentHeight * 2;
701  hr = m_implData->handle.pGrabber->GetCurrentBuffer(
702  (long *)&bufferSize, (long *)buffer);
703  if (hr != S_OK) {
704  LOG(WARNING) << "Incorrect Buffer Size allocated, Allocate "
705  "bigger buffer";
706  continue;
707  } else {
708  EnterCriticalSection(&m_implData->handle.pCB->critSection);
709  m_implData->handle.pCB->newFrame = false;
710  LeaveCriticalSection(&m_implData->handle.pCB->critSection);
711  break;
712  }
713  } else {
714  Sleep(1);
715  retryCount++;
716  }
717  }
718 
719  return retryCount >= 1000 ? Status::GENERIC_ERROR : status;
720 }
721 
723 UsbDepthSensor::getAvailableControls(std::vector<std::string> &controls) const {
724  using namespace aditof;
725 
726  Status status = Status::OK;
727 
728  // Construct request message
729  usb_payload::ClientRequest requestMsg;
730  requestMsg.set_func_name(usb_payload::FunctionName::GET_AVAILABLE_CONTROLS);
731 
732  // Send request
733  std::string requestStr;
734  requestMsg.SerializeToString(&requestStr);
736  m_implData->handle.pVideoInputFilter, requestStr);
737  if (status != aditof::Status::OK) {
738  LOG(ERROR) << "Request to get available controls failed";
739  return status;
740  }
741 
742  // Read UVC gadget response
745  m_implData->handle.pVideoInputFilter, responseStr);
746  if (status != aditof::Status::OK) {
747  LOG(ERROR) << "Failed to get response of the request to get controls";
748  return status;
749  }
750  usb_payload::ServerResponse responseMsg;
751  bool parsed = responseMsg.ParseFromString(responseStr);
752  if (!parsed) {
753  LOG(ERROR)
754  << "Failed to deserialize string containing UVC gadget response";
756  }
757 
758  if (responseMsg.status() != usb_payload::Status::OK) {
759  LOG(ERROR) << "Get available controls operation failed on UVC gadget";
760  return static_cast<aditof::Status>(responseMsg.status());
761  }
762 
763  if (status == Status::OK) {
764  controls.clear();
765 
766  for (int i = 0; i < responseMsg.strings_payload_size(); i++) {
767  std::string controlName = responseMsg.strings_payload(i);
768  controls.push_back(controlName);
769  }
770  }
771 
772  return Status::OK;
773 }
774 
776  const std::string &value) {
777  using namespace aditof;
778 
779  Status status = Status::OK;
780 
781  // Construct request message
782  usb_payload::ClientRequest requestMsg;
783  requestMsg.set_func_name(usb_payload::FunctionName::SET_CONTROL);
784  requestMsg.add_func_strings_param(control);
785  requestMsg.add_func_strings_param(value);
786 
787  // Send request
788  std::string requestStr;
789  requestMsg.SerializeToString(&requestStr);
791  m_implData->handle.pVideoInputFilter, requestStr);
792  if (status != aditof::Status::OK) {
793  LOG(ERROR) << "Request to set control failed: " << control;
794  return status;
795  }
796 
797  // Read UVC gadget response
800  m_implData->handle.pVideoInputFilter, responseStr);
801  if (status != aditof::Status::OK) {
802  LOG(ERROR) << "Failed to get response of the request to set control: "
803  << control;
804  return status;
805  }
806  usb_payload::ServerResponse responseMsg;
807  bool parsed = responseMsg.ParseFromString(responseStr);
808  if (!parsed) {
809  LOG(ERROR)
810  << "Failed to deserialize string containing UVC gadget response";
812  }
813 
814  if (responseMsg.status() != usb_payload::Status::OK) {
815  LOG(ERROR) << "Set control:" << control
816  << " operation failed on UVC gadget";
817  return static_cast<aditof::Status>(responseMsg.status());
818  }
819 
820  return Status::OK;
821 }
822 
824  std::string &value) const {
825  using namespace aditof;
826 
827  Status status = Status::OK;
828 
829  // Construct request message
830  usb_payload::ClientRequest requestMsg;
831  requestMsg.set_func_name(usb_payload::FunctionName::GET_CONTROL);
832  requestMsg.add_func_strings_param(control);
833 
834  // Send request
835  std::string requestStr;
836  requestMsg.SerializeToString(&requestStr);
838  m_implData->handle.pVideoInputFilter, requestStr);
839  if (status != aditof::Status::OK) {
840  LOG(ERROR) << "Request to get control: " << control << " failed";
841  return status;
842  }
843 
844  // Read UVC gadget response
847  m_implData->handle.pVideoInputFilter, responseStr);
848  if (status != aditof::Status::OK) {
849  LOG(ERROR) << "Failed to get response of the request to get control: "
850  << control;
851  return status;
852  }
853  usb_payload::ServerResponse responseMsg;
854  bool parsed = responseMsg.ParseFromString(responseStr);
855  if (!parsed) {
856  LOG(ERROR)
857  << "Failed to deserialize string containing UVC gadget response";
859  }
860 
861  if (responseMsg.status() != usb_payload::Status::OK) {
862  LOG(ERROR) << "Get control: " << control
863  << " operation failed on UVC gadget";
864  return static_cast<aditof::Status>(responseMsg.status());
865  }
866 
867  value = responseMsg.strings_payload(0);
868 
869  return Status::OK;
870 }
871 
874  details = m_sensorDetails;
875  return aditof::Status::OK;
876 }
877 
879  if (m_implData->opened) {
880  *handle = &m_implData->handle;
881  return aditof::Status::OK;
882  } else {
883  *handle = nullptr;
884  LOG(ERROR) << "Won't return the handle. Device hasn't been opened yet.";
886  }
887 }
888 
890  name = m_sensorName;
891  return aditof::Status::OK;
892 }
893 
896  LOG(INFO) << "Function used only on target!";
897  return aditof::Status::OK;
898 }
899 
901  unsigned int usDelay) {
902  using namespace aditof;
903 
904  Status status = Status::OK;
905 
906  // Construct request message
907  usb_payload::ClientRequest requestMsg;
908  requestMsg.set_func_name(usb_payload::FunctionName::ADSD3500_READ_CMD);
909  requestMsg.add_func_int32_param(static_cast<::google::int32>(cmd));
910 
911  // Send request
912  std::string requestStr;
913  requestMsg.SerializeToString(&requestStr);
915  m_implData->handle.pVideoInputFilter, requestStr);
916  if (status != aditof::Status::OK) {
917  LOG(ERROR) << "Request to read registers failed";
918  return status;
919  }
920 
921  // Read UVC gadget response
924  m_implData->handle.pVideoInputFilter, responseStr);
925  if (status != aditof::Status::OK) {
926  LOG(ERROR) << "Failed to get response of the request to read registers";
927  return status;
928  }
929  usb_payload::ServerResponse responseMsg;
930  bool parsed = responseMsg.ParseFromString(responseStr);
931  if (!parsed) {
932  LOG(ERROR)
933  << "Failed to deserialize string containing UVC gadget response";
935  }
936 
937  if (responseMsg.status() != usb_payload::Status::OK) {
938  LOG(ERROR) << "Read registers operation failed on UVC gadget";
939  return static_cast<aditof::Status>(responseMsg.status());
940  }
941 
942  // If request and response went well, extract data from response
943  *data = responseMsg.int32_payload(0);
944 
945  return Status::OK;
946 }
947 
949  unsigned int usDelay) {
950  using namespace aditof;
951 
952  Status status = Status::OK;
953 
954  // Construct request message
955  usb_payload::ClientRequest requestMsg;
956  requestMsg.set_func_name(usb_payload::FunctionName::ADSD3500_WRITE_CMD);
957  requestMsg.add_func_int32_param(static_cast<::google::int32>(cmd));
958  requestMsg.add_func_int32_param(static_cast<::google::int32>(data));
959 
960  // Send request
961  std::string requestStr;
962  requestMsg.SerializeToString(&requestStr);
964  m_implData->handle.pVideoInputFilter, requestStr);
965  if (status != aditof::Status::OK) {
966  LOG(ERROR) << "Request to write registers failed";
967  return status;
968  }
969 
970  // Read UVC gadget response
973  m_implData->handle.pVideoInputFilter, responseStr);
974  if (status != aditof::Status::OK) {
975  LOG(ERROR)
976  << "Failed to get response of the request to write registers";
977  return status;
978  }
979  usb_payload::ServerResponse responseMsg;
980  bool parsed = responseMsg.ParseFromString(responseStr);
981  if (!parsed) {
982  LOG(ERROR)
983  << "Failed to deserialize string containing UVC gadget response";
985  }
986 
987  if (responseMsg.status() != usb_payload::Status::OK) {
988  LOG(ERROR) << "Read registers operation failed on UVC gadget";
989  return static_cast<aditof::Status>(responseMsg.status());
990  }
991 
992  return Status::OK;
993 }
994 
996  uint8_t *readback_data,
997  uint16_t payload_len) {
998  using namespace aditof;
999 
1000  Status status = Status::OK;
1001 
1002  // Construct request message
1003  usb_payload::ClientRequest requestMsg;
1004  requestMsg.set_func_name(
1006  requestMsg.add_func_int32_param(static_cast<::google::int32>(cmd));
1007  requestMsg.add_func_int32_param(static_cast<::google::int32>(payload_len));
1008  requestMsg.add_func_bytes_param(readback_data, 4 * sizeof(uint8_t));
1009 
1010  // Send request
1011  std::string requestStr;
1012  requestMsg.SerializeToString(&requestStr);
1014  m_implData->handle.pVideoInputFilter, requestStr);
1015  if (status != aditof::Status::OK) {
1016  LOG(ERROR) << "Request to read registers failed";
1017  return status;
1018  }
1019 
1020  // Read UVC gadget response
1023  m_implData->handle.pVideoInputFilter, responseStr);
1024  if (status != aditof::Status::OK) {
1025  LOG(ERROR) << "Failed to get response of the request to read registers";
1026  return status;
1027  }
1028  usb_payload::ServerResponse responseMsg;
1029  bool parsed = responseMsg.ParseFromString(responseStr);
1030  if (!parsed) {
1031  LOG(ERROR)
1032  << "Failed to deserialize string containing UVC gadget response";
1034  }
1035 
1036  if (responseMsg.status() != usb_payload::Status::OK) {
1037  LOG(ERROR) << "Read registers operation failed on UVC gadget";
1038  return static_cast<aditof::Status>(responseMsg.status());
1039  }
1040 
1041  // If request and response went well, extract data from response
1042  memcpy(readback_data, responseMsg.bytes_payload(0).c_str(),
1043  responseMsg.bytes_payload(0).length());
1044 
1045  return Status::OK;
1046 }
1047 
1049  uint16_t payload_len) {
1050  using namespace aditof;
1051 
1052  Status status = Status::OK;
1053 
1054  // Construct request message
1055  usb_payload::ClientRequest requestMsg;
1056  requestMsg.set_func_name(usb_payload::FunctionName::ADSD3500_READ_PAYLOAD);
1057  requestMsg.add_func_int32_param(static_cast<::google::int32>(payload_len));
1058 
1059  // Send request
1060  std::string requestStr;
1061  requestMsg.SerializeToString(&requestStr);
1063  m_implData->handle.pVideoInputFilter, requestStr);
1064  if (status != aditof::Status::OK) {
1065  LOG(ERROR) << "Request to read registers failed";
1066  return status;
1067  }
1068 
1069  // Read UVC gadget response
1072  m_implData->handle.pVideoInputFilter, responseStr);
1073  if (status != aditof::Status::OK) {
1074  LOG(ERROR) << "Failed to get response of the request to read registers";
1075  return status;
1076  }
1077  usb_payload::ServerResponse responseMsg;
1078  bool parsed = responseMsg.ParseFromString(responseStr);
1079  if (!parsed) {
1080  LOG(ERROR)
1081  << "Failed to deserialize string containing UVC gadget response";
1083  }
1084 
1085  if (responseMsg.status() != usb_payload::Status::OK) {
1086  LOG(ERROR) << "Read registers operation failed on UVC gadget";
1087  return static_cast<aditof::Status>(responseMsg.status());
1088  }
1089 
1090  // If request and response went well, extract data from response
1091  memcpy(payload, responseMsg.bytes_payload(0).c_str(),
1092  responseMsg.bytes_payload(0).length());
1093 
1094  return Status::OK;
1095 }
1096 
1098 UsbDepthSensor::adsd3500_write_payload_cmd(uint32_t cmd, uint8_t *payload,
1099  uint16_t payload_len) {
1100  using namespace aditof;
1101 
1102  Status status = Status::OK;
1103 
1104  // Construct request message
1105  usb_payload::ClientRequest requestMsg;
1106  requestMsg.set_func_name(
1108  requestMsg.add_func_int32_param(static_cast<::google::int32>(cmd));
1109  requestMsg.add_func_int32_param(static_cast<::google::int32>(payload_len));
1110  requestMsg.add_func_bytes_param(payload, payload_len);
1111 
1112  // Send request
1113  std::string requestStr;
1114  requestMsg.SerializeToString(&requestStr);
1116  m_implData->handle.pVideoInputFilter, requestStr);
1117  if (status != aditof::Status::OK) {
1118  LOG(ERROR) << "Request to write registers failed";
1119  return status;
1120  }
1121 
1122  // Read UVC gadget response
1125  m_implData->handle.pVideoInputFilter, responseStr);
1126  if (status != aditof::Status::OK) {
1127  LOG(ERROR)
1128  << "Failed to get response of the request to write registers";
1129  return status;
1130  }
1131  usb_payload::ServerResponse responseMsg;
1132  bool parsed = responseMsg.ParseFromString(responseStr);
1133  if (!parsed) {
1134  LOG(ERROR)
1135  << "Failed to deserialize string containing UVC gadget response";
1137  }
1138 
1139  if (responseMsg.status() != usb_payload::Status::OK) {
1140  LOG(ERROR) << "Read registers operation failed on UVC gadget";
1141  return static_cast<aditof::Status>(responseMsg.status());
1142  }
1143 
1144  return Status::OK;
1145 }
1146 
1148  uint16_t payload_len) {
1149  using namespace aditof;
1150 
1151  Status status = Status::OK;
1152 
1153  // Construct request message
1154  usb_payload::ClientRequest requestMsg;
1155  requestMsg.set_func_name(usb_payload::FunctionName::ADSD3500_WRITE_PAYLOAD);
1156  requestMsg.add_func_int32_param(static_cast<::google::int32>(payload_len));
1157  requestMsg.add_func_bytes_param(payload, payload_len);
1158 
1159  // Send request
1160  std::string requestStr;
1161  requestMsg.SerializeToString(&requestStr);
1163  m_implData->handle.pVideoInputFilter, requestStr);
1164  if (status != aditof::Status::OK) {
1165  LOG(ERROR) << "Request to write registers failed";
1166  return status;
1167  }
1168 
1169  // Read UVC gadget response
1172  m_implData->handle.pVideoInputFilter, responseStr);
1173  if (status != aditof::Status::OK) {
1174  LOG(ERROR)
1175  << "Failed to get response of the request to write registers";
1176  return status;
1177  }
1178  usb_payload::ServerResponse responseMsg;
1179  bool parsed = responseMsg.ParseFromString(responseStr);
1180  if (!parsed) {
1181  LOG(ERROR)
1182  << "Failed to deserialize string containing UVC gadget response";
1184  }
1185 
1186  if (responseMsg.status() != usb_payload::Status::OK) {
1187  LOG(ERROR) << "Read registers operation failed on UVC gadget";
1188  return static_cast<aditof::Status>(responseMsg.status());
1189  }
1190 
1191  return Status::OK;
1192 }
1193 
1195  LOG(INFO) << "Not available!";
1196  return aditof::Status::OK;
1197 }
1198 
1201  LOG(WARNING) << "Registering an interrupt callback on a USB connection "
1202  "is not supported yet!";
1204 }
1205 
1208  LOG(WARNING) << "Unregistering an interrupt callback on a USB connection "
1209  "is not supported yet!";
1211 }
1212 
1214  int &imagerStatus) {
1215  using namespace aditof;
1216  Status status = Status::UNAVAILABLE;
1217  return status;
1218 }
1219 
1221  uint16_t iniFileLength,
1222  uint8_t *calData,
1223  uint16_t calDataLength) {
1224  using namespace aditof;
1225 
1226  Status status = Status::OK;
1227 
1228  // Construct request message
1229  usb_payload::ClientRequest requestMsg;
1230  requestMsg.set_func_name(
1232  requestMsg.add_func_int32_param(
1233  static_cast<::google::int32>(iniFileLength));
1234  requestMsg.add_func_int32_param(
1235  static_cast<::google::int32>(calDataLength));
1236  requestMsg.add_func_bytes_param(iniFile, iniFileLength);
1237  requestMsg.add_func_bytes_param(calData, calDataLength);
1238 
1239  // Send request
1240  std::string requestStr;
1241  requestMsg.SerializeToString(&requestStr);
1242 
1244  m_implData->handle.pVideoInputFilter, requestStr);
1245  if (status != aditof::Status::OK) {
1246  LOG(ERROR) << "Request to write registers failed";
1247  return status;
1248  }
1249 
1250  // Read UVC gadget response
1253  m_implData->handle.pVideoInputFilter, responseStr);
1254  if (status != aditof::Status::OK) {
1255  LOG(ERROR)
1256  << "Failed to get response of the request to write registers";
1257  return status;
1258  }
1259  usb_payload::ServerResponse responseMsg;
1260  bool parsed = responseMsg.ParseFromString(responseStr);
1261  if (!parsed) {
1262  LOG(ERROR)
1263  << "Failed to deserialize string containing UVC gadget response";
1265  }
1266 
1267  if (responseMsg.status() != usb_payload::Status::OK) {
1268  LOG(ERROR) << "Read registers operation failed on UVC gadget";
1269  return static_cast<aditof::Status>(responseMsg.status());
1270  }
1271 
1272  return Status::OK;
1273 }
1274 
1276  std::map<std::string, std::string> &params) {
1278 }
1279 
1281  const std::map<std::string, std::string> &params) {
1283  ;
1284 }
1285 
1288  // TODO: select sensor table configuration
1289  return aditof::Status::OK;
1290 }
1291 
1293  std::string &iniStr) {
1294 
1295  return aditof::Status::OK;
1296 }
usb_depth_sensor.h
INFO
const int INFO
Definition: log_severity.h:59
name
GLuint const GLchar * name
Definition: glcorearb.h:3055
aditof::SET_CONTROL
@ SET_CONTROL
Definition: gpio.h:51
UsbDepthSensor::adsd3500_read_payload
virtual aditof::Status adsd3500_read_payload(uint8_t *payload, uint16_t payload_len) override
Reads a chunk of data from adsd3500. This will perform a burst read making it useful for reading chun...
Definition: usb_depth_sensor_linux.cpp:817
UsbDepthSensor::adsd3500_unregister_interrupt_callback
virtual aditof::Status adsd3500_unregister_interrupt_callback(aditof::SensorInterruptCallback &cb) override
Unregister a function registered with adsd3500_register_interrupt_callback.
Definition: usb_depth_sensor_linux.cpp:1003
aditof::ADSD3500_WRITE_PAYLOAD
@ ADSD3500_WRITE_PAYLOAD
Definition: gpio.h:59
aditof::SensorDetails
Provides details about the device.
Definition: sensor_definitions.h:50
aditof::ADSD3500_WRITE_PAYLOAD_CMD
@ ADSD3500_WRITE_PAYLOAD_CMD
Definition: gpio.h:58
ERROR
const int ERROR
Definition: log_severity.h:60
aditof::Status::GENERIC_ERROR
@ GENERIC_ERROR
An error occured but there are no details available.
UsbUtils::depthSensorModeDetailsToProtoMsg
static void depthSensorModeDetailsToProtoMsg(const aditof::DepthSensorModeDetails &depthSensorModeDetails, usb_payload::DepthSensorModeDetails *protoMsg)
Converts a DepthSensorModeDetails to a protobuf message.
Definition: usb_utils.cpp:70
CalibrationData::cache
uint16_t * cache
Definition: network_depth_sensor.cpp:47
CalibrationData::gain
float gain
Definition: network_depth_sensor.cpp:45
s
XmlRpcServer s
mode
GLenum mode
Definition: glcorearb.h:2764
log.h
usb_windows_utils.h
UsbDepthSensor::getName
virtual aditof::Status getName(std::string &name) const override
Get the name of the sensor.
Definition: usb_depth_sensor_linux.cpp:663
UsbWindowsUtils::uvcExUnitSendRequest
static aditof::Status uvcExUnitSendRequest(IBaseFilter *pVideoInputFilter, const std::string &requestStr)
Definition: usb_windows_utils.cpp:282
UsbDepthSensor::adsd3500_write_payload
virtual aditof::Status adsd3500_write_payload(uint8_t *payload, uint16_t payload_len) override
Send a chunk of data (payload) to adsd3500. This will perform a burst write making it useful for writ...
Definition: usb_depth_sensor_linux.cpp:911
UsbDepthSensor::adsd3500_get_status
virtual aditof::Status adsd3500_get_status(int &chipStatus, int &imagerStatus) override
Returns the chip status.
Definition: usb_depth_sensor_linux.cpp:1010
string
GLsizei const GLchar *const * string
Definition: glcorearb.h:3083
UsbDepthSensor::setMode
virtual aditof::Status setMode(const aditof::DepthSensorModeDetails &type) override
Set the sensor frame mode to the given type.
Definition: usb_depth_sensor_linux.cpp:269
aditof::ADSD3500_WRITE_CMD
@ ADSD3500_WRITE_CMD
Definition: gpio.h:55
UsbDepthSensor::adsd3500_reset
virtual aditof::Status adsd3500_reset() override
Reset adsd3500 chip.
Definition: usb_depth_sensor_linux.cpp:955
aditof::Status::UNAVAILABLE
@ UNAVAILABLE
The requested action or resource is unavailable.
WARNING
const int WARNING
Definition: log_severity.h:59
NukeDownstream
static void NukeDownstream(IBaseFilter *pBF, IGraphBuilder *pGraph)
Definition: usb_depth_sensor_windows.cpp:149
UsbDepthSensor::initTargetDepthCompute
virtual aditof::Status initTargetDepthCompute(uint8_t *iniFile, uint16_t iniFileLength, uint8_t *calData, uint16_t calDataLength) override
Get the name of the sensor.
Definition: usb_depth_sensor_linux.cpp:1017
google::protobuf::util::error::UNAVAILABLE
@ UNAVAILABLE
Definition: status.h:62
aditof::GET_CONTROL
@ GET_CONTROL
Definition: gpio.h:52
SampleGrabberCallback
Definition: usb_windows_utils.h:109
checkSingleByteFormat
static bool checkSingleByteFormat(GUID FormatType)
Definition: usb_depth_sensor_windows.cpp:136
testing::internal::wstring
::std::wstring wstring
Definition: gtest-port.h:887
UsbDepthSensor::getFrame
virtual aditof::Status getFrame(uint16_t *buffer) override
Request a frame from the sensor.
Definition: usb_depth_sensor_linux.cpp:422
UsbHandle
Definition: usb_windows_utils.h:151
responseStr
ROSCPP_DECL XmlRpc::XmlRpcValue responseStr(int code, const std::string &msg, const std::string &response)
aditof::INIT_TARGET_DEPTH_COMPUTE
@ INIT_TARGET_DEPTH_COMPUTE
Definition: gpio.h:53
UsbDepthSensor
Definition: usb_depth_sensor.h:44
UsbDepthSensor::open
virtual aditof::Status open() override
Open the communication channels with the hardware.
Definition: usb_depth_sensor_linux.cpp:115
UsbDepthSensor::getDetails
virtual aditof::Status getDetails(aditof::SensorDetails &details) const override
Get a structure that contains information about the instance of the sensor.
Definition: usb_depth_sensor_linux.cpp:647
aditof::ADSD3500_READ_PAYLOAD_CMD
@ ADSD3500_READ_PAYLOAD_CMD
Definition: gpio.h:56
aditof
Namespace aditof.
Definition: adsd_errs.h:40
UsbDepthSensor::adsd3500_write_cmd
virtual aditof::Status adsd3500_write_cmd(uint16_t cmd, uint16_t data, unsigned int usDelay=0) override
Send a write command to adsd3500.
Definition: usb_depth_sensor_linux.cpp:721
aditof::ADSD3500_READ_CMD
@ ADSD3500_READ_CMD
Definition: gpio.h:54
UsbDepthSensor::getControl
virtual aditof::Status getControl(const std::string &control, std::string &value) const override
Gets the value of a specific sensor control.
Definition: usb_depth_sensor_linux.cpp:600
UsbDepthSensor::getAvailableControls
virtual aditof::Status getAvailableControls(std::vector< std::string > &controls) const override
Gets the sensors's list of controls.
Definition: usb_depth_sensor_linux.cpp:503
update_failure_list.str
str
Definition: update_failure_list.py:41
UsbDepthSensor::m_implData
std::unique_ptr< ImplData > m_implData
Definition: usb_depth_sensor.h:114
UsbDepthSensor::getAvailableModes
virtual aditof::Status getAvailableModes(std::vector< uint8_t > &modes) override
Return all modes that are supported by the sensor.
Definition: usb_depth_sensor_linux.cpp:241
google::protobuf::util::error::OK
@ OK
Definition: status.h:47
aditof::ConnectionType::USB
@ USB
connects to target via USB
UsbDepthSensor::adsd3500_read_cmd
virtual aditof::Status adsd3500_read_cmd(uint16_t cmd, uint16_t *data, unsigned int usDelay=0) override
Send a read command to adsd3500.
Definition: usb_depth_sensor_linux.cpp:674
UsbDepthSensor::adsd3500_register_interrupt_callback
virtual aditof::Status adsd3500_register_interrupt_callback(aditof::SensorInterruptCallback &cb) override
Register a function to be called when a ADSD3500 interrupt occurs.
Definition: usb_depth_sensor_linux.cpp:996
gen_gtest_pred_impl.HEADER
HEADER
Definition: gen_gtest_pred_impl.py:59
params
GLenum const GLfloat * params
Definition: glcorearb.h:2770
UsbDepthSensor::start
virtual aditof::Status start() override
Start the streaming of data from the sensor.
Definition: usb_depth_sensor_linux.cpp:183
UsbDepthSensor::~UsbDepthSensor
~UsbDepthSensor()
Definition: usb_depth_sensor_linux.cpp:86
UsbDepthSensor::m_depthSensorModes
std::vector< aditof::DepthSensorModeDetails > m_depthSensorModes
Definition: usb_depth_sensor.h:115
destroyGraph
static void destroyGraph(IGraphBuilder *pGraph)
Definition: usb_depth_sensor_windows.cpp:181
buffer
Definition: buffer_processor.h:43
UsbWindowsUtils::uvcExUnitGetResponse
static aditof::Status uvcExUnitGetResponse(IBaseFilter *pVideoInputFilter, std::string &responseStr)
Definition: usb_windows_utils.cpp:335
UsbDepthSensor::getIniParamsArrayForMode
aditof::Status getIniParamsArrayForMode(int mode, std::string &iniStr) override
Get ini parameters for Depth Compute library as string.
Definition: usb_depth_sensor_linux.cpp:1044
UsbDepthSensor::m_driverPath
std::string m_driverPath
Definition: usb_depth_sensor.h:113
buf
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glcorearb.h:4175
aditof::ADSD3500_READ_PAYLOAD
@ ADSD3500_READ_PAYLOAD
Definition: gpio.h:57
getDevice
static aditof::Status getDevice(IBaseFilter **pVideoInputFilter, const std::string &devName)
Definition: usb_depth_sensor_windows.cpp:70
UsbDepthSensor::adsd3500_write_payload_cmd
virtual aditof::Status adsd3500_write_payload_cmd(uint32_t cmd, uint8_t *payload, uint16_t payload_len) override
Send a write command to adsd3500. This will perform a burst write making it useful for writing chunks...
Definition: usb_depth_sensor_linux.cpp:863
UsbDepthSensor::ImplData::handle
UsbHandle handle
Definition: usb_depth_sensor_windows.cpp:54
s2ws
static std::wstring s2ws(const std::string &s)
Definition: usb_depth_sensor_windows.cpp:59
CalibrationData
Definition: network_depth_sensor.cpp:43
aditof::Status::INVALID_ARGUMENT
@ INVALID_ARGUMENT
Invalid arguments provided.
aditof::Status
Status
Status of any operation that the TOF sdk performs.
Definition: status_definitions.h:48
i
int i
Definition: gmock-matchers_test.cc:764
UsbDepthSensor::setHostConnectionType
virtual aditof::Status setHostConnectionType(std::string &connectionType) override
Set the host connection type for target sdk.
Definition: usb_depth_sensor_linux.cpp:669
aditof::GET_AVAILABLE_MODES
@ GET_AVAILABLE_MODES
Definition: gpio.h:45
type
GLenum type
Definition: glcorearb.h:2695
UsbUtils::protoMsgToDepthSensorModeDetails
static void protoMsgToDepthSensorModeDetails(std::vector< aditof::DepthSensorModeDetails > &depthSensorModeDetailsVector, const usb_payload::DepthSensorModeDetailsVector &protoMsg)
Converts from protobuf message to aditof type (vector of DepthSensorModeDetails)
Definition: usb_utils.cpp:40
UsbDepthSensor::getHandle
virtual aditof::Status getHandle(void **handle) override
Gets a handle to be used by other devices such as Storage, Temperature, etc. This handle will allow t...
Definition: usb_depth_sensor_linux.cpp:652
LOG
#define LOG(x)
Definition: sdk/include/aditof/log.h:72
google::int32
int32_t int32
Definition: sdk/include/aditof/log.h:54
len
int len
Definition: php/ext/google/protobuf/map.c:206
aditof::Status::OK
@ OK
Success.
UsbDepthSensor::setDepthComputeParams
virtual aditof::Status setDepthComputeParams(const std::map< std::string, std::string > &params) override
Set ini parameters for Depth Compute library.
Definition: usb_depth_sensor_linux.cpp:1031
UsbDepthSensor::setSensorConfiguration
virtual aditof::Status setSensorConfiguration(const std::string &sensorConf) override
Set sensor configutation table.
Definition: usb_depth_sensor_linux.cpp:1039
aditof::DepthSensorModeDetails
Describes the type of entire frame that a depth sensor can capture and transmit.
Definition: sensor_definitions.h:120
UsbDepthSensor::stop
virtual aditof::Status stop() override
Stop the sensor data stream.
Definition: usb_depth_sensor_linux.cpp:219
UsbDepthSensor::m_sensorName
std::string m_sensorName
Definition: usb_depth_sensor.h:110
usb_utils.h
UsbDepthSensor::ImplData::calibration_cache
std::unordered_map< std::string, CalibrationData > calibration_cache
Definition: usb_depth_sensor_linux.cpp:71
UsbDepthSensor::getModeDetails
virtual aditof::Status getModeDetails(const uint8_t &mode, aditof::DepthSensorModeDetails &details) override
Returns details of specified mode.
Definition: usb_depth_sensor_linux.cpp:251
r
GLboolean r
Definition: glcorearb.h:3228
CalibrationData::offset
float offset
Definition: network_depth_sensor.cpp:46
CalibrationData::mode
std::string mode
Definition: network_depth_sensor.cpp:44
UsbDepthSensor::adsd3500_read_payload_cmd
virtual aditof::Status adsd3500_read_payload_cmd(uint32_t cmd, uint8_t *readback_data, uint16_t payload_len) override
Send a read command to adsd3500. This will perform a burst read making it useful for reading chunks o...
Definition: usb_depth_sensor_linux.cpp:765
UsbDepthSensor::getDepthComputeParams
virtual aditof::Status getDepthComputeParams(std::map< std::string, std::string > &params) override
Get ini parameters for Depth Compute library.
Definition: usb_depth_sensor_linux.cpp:1024
aditof::GET_AVAILABLE_CONTROLS
@ GET_AVAILABLE_CONTROLS
Definition: gpio.h:50
data
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: glcorearb.h:2879
UsbDepthSensor::ImplData
Definition: usb_depth_sensor_linux.cpp:64
status_definitions.h
UsbDepthSensor::ImplData::opened
bool opened
Definition: usb_depth_sensor_linux.cpp:69
value
GLsizei const GLfloat * value
Definition: glcorearb.h:3093
UsbDepthSensor::UsbDepthSensor
UsbDepthSensor(const std::string &name, const std::string &driverPath)
Definition: usb_depth_sensor_linux.cpp:74
aditof::SET_MODE
@ SET_MODE
Definition: gpio.h:47
count
GLint GLsizei count
Definition: glcorearb.h:2830
UsbDepthSensor::m_sensorDetails
aditof::SensorDetails m_sensorDetails
Definition: usb_depth_sensor.h:112
UsbDepthSensor::setControl
virtual aditof::Status setControl(const std::string &control, const std::string &value) override
Sets a specific sensor control.
Definition: usb_depth_sensor_linux.cpp:550
it
MapIter it
Definition: php/ext/google/protobuf/map.c:205
aditof::START
@ START
Definition: gpio.h:43
aditof::SensorInterruptCallback
std::function< void(Adsd3500Status)> SensorInterruptCallback
Callback for sensor interrupts.
Definition: depth_sensor_interface.h:50


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:07:01