1 #ifdef HAVE_INTELPERC
2 
3 #include "cap_intelperc.hpp"
4 
5 namespace cv
6 {
7 
8 ///////////////// IntelPerCStreamBase //////////////////
9 
IntelPerCStreamBase()10 IntelPerCStreamBase::IntelPerCStreamBase()
11     : m_profileIdx(-1)
12     , m_frameIdx(0)
13     , m_timeStampStartNS(0)
14 {
15 }
~IntelPerCStreamBase()16 IntelPerCStreamBase::~IntelPerCStreamBase()
17 {
18 }
19 
isValid()20 bool IntelPerCStreamBase::isValid()
21 {
22     return (m_device.IsValid() && m_stream.IsValid());
23 }
grabFrame()24 bool IntelPerCStreamBase::grabFrame()
25 {
26     if (!m_stream.IsValid())
27         return false;
28     if (-1 == m_profileIdx)
29     {
30         if (!setProperty(CV_CAP_PROP_INTELPERC_PROFILE_IDX, 0))
31             return false;
32     }
33     PXCSmartSP sp;
34     m_pxcImage.ReleaseRef();
35     if (PXC_STATUS_NO_ERROR > m_stream->ReadStreamAsync(&m_pxcImage, &sp))
36         return false;
37     if (PXC_STATUS_NO_ERROR > sp->Synchronize())
38         return false;
39     if (0 == m_timeStampStartNS)
40         m_timeStampStartNS = m_pxcImage->QueryTimeStamp();
41     m_timeStamp = (double)((m_pxcImage->QueryTimeStamp() - m_timeStampStartNS) / 10000);
42     m_frameIdx++;
43     return true;
44 }
getProfileIDX() const45 int IntelPerCStreamBase::getProfileIDX() const
46 {
47     return m_profileIdx;
48 }
getProperty(int propIdx) const49 double IntelPerCStreamBase::getProperty(int propIdx) const
50 {
51     double ret = 0.0;
52     switch (propIdx)
53     {
54     case CV_CAP_PROP_INTELPERC_PROFILE_COUNT:
55         ret = (double)m_profiles.size();
56         break;
57     case CV_CAP_PROP_FRAME_WIDTH :
58         if ((0 <= m_profileIdx) && (m_profileIdx < m_profiles.size()))
59             ret = (double)m_profiles[m_profileIdx].imageInfo.width;
60         break;
61     case CV_CAP_PROP_FRAME_HEIGHT :
62         if ((0 <= m_profileIdx) && (m_profileIdx < m_profiles.size()))
63             ret = (double)m_profiles[m_profileIdx].imageInfo.height;
64         break;
65     case CV_CAP_PROP_FPS :
66         if ((0 <= m_profileIdx) && (m_profileIdx < m_profiles.size()))
67         {
68             ret = ((double)m_profiles[m_profileIdx].frameRateMin.numerator / (double)m_profiles[m_profileIdx].frameRateMin.denominator
69                     + (double)m_profiles[m_profileIdx].frameRateMax.numerator / (double)m_profiles[m_profileIdx].frameRateMax.denominator) / 2.0;
70         }
71         break;
72     case CV_CAP_PROP_POS_FRAMES:
73         ret  = (double)m_frameIdx;
74         break;
75     case CV_CAP_PROP_POS_MSEC:
76         ret  = m_timeStamp;
77         break;
78     };
79     return ret;
80 }
setProperty(int propIdx,double propVal)81 bool IntelPerCStreamBase::setProperty(int propIdx, double propVal)
82 {
83     bool isSet = false;
84     switch (propIdx)
85     {
86     case CV_CAP_PROP_INTELPERC_PROFILE_IDX:
87         {
88             int propValInt = (int)propVal;
89             if (0 > propValInt)
90             {
91                 m_profileIdx = propValInt;
92                 isSet = true;
93             }
94             else if (propValInt < m_profiles.size())
95             {
96                 if (m_profileIdx != propValInt)
97                 {
98                     m_profileIdx = propValInt;
99                     if (m_stream.IsValid())
100                         m_stream->SetProfile(&m_profiles[m_profileIdx]);
101                     m_frameIdx = 0;
102                     m_timeStampStartNS = 0;
103                 }
104                 isSet = true;
105             }
106         }
107         break;
108     };
109     return isSet;
110 }
initDevice(PXCSession * session)111 bool IntelPerCStreamBase::initDevice(PXCSession *session)
112 {
113     if (NULL == session)
114         return false;
115 
116     pxcStatus sts = PXC_STATUS_NO_ERROR;
117     PXCSession::ImplDesc templat;
118     memset(&templat,0,sizeof(templat));
119     templat.group   = PXCSession::IMPL_GROUP_SENSOR;
120     templat.subgroup= PXCSession::IMPL_SUBGROUP_VIDEO_CAPTURE;
121 
122     for (int modidx = 0; PXC_STATUS_NO_ERROR <= sts; modidx++)
123     {
124         PXCSession::ImplDesc desc;
125         sts = session->QueryImpl(&templat, modidx, &desc);
126         if (PXC_STATUS_NO_ERROR > sts)
127             break;
128 
129         PXCSmartPtr<PXCCapture> capture;
130         sts = session->CreateImpl<PXCCapture>(&desc, &capture);
131         if (!capture.IsValid())
132             continue;
133 
134         /* enumerate devices */
135         for (int devidx = 0; PXC_STATUS_NO_ERROR <= sts; devidx++)
136         {
137             PXCSmartPtr<PXCCapture::Device> device;
138             sts = capture->CreateDevice(devidx, &device);
139             if (PXC_STATUS_NO_ERROR <= sts)
140             {
141                 m_device = device.ReleasePtr();
142                 return true;
143             }
144         }
145     }
146     return false;
147 }
148 
initStreamImpl(PXCImage::ImageType type)149 void IntelPerCStreamBase::initStreamImpl(PXCImage::ImageType type)
150 {
151     if (!m_device.IsValid())
152         return;
153 
154     pxcStatus sts = PXC_STATUS_NO_ERROR;
155     /* enumerate streams */
156     for (int streamidx = 0; PXC_STATUS_NO_ERROR <= sts; streamidx++)
157     {
158         PXCCapture::Device::StreamInfo sinfo;
159         sts = m_device->QueryStream(streamidx, &sinfo);
160         if (PXC_STATUS_NO_ERROR > sts)
161             break;
162         if (PXCCapture::VideoStream::CUID != sinfo.cuid)
163             continue;
164         if (type != sinfo.imageType)
165             continue;
166 
167         sts = m_device->CreateStream<PXCCapture::VideoStream>(streamidx, &m_stream);
168         if (PXC_STATUS_NO_ERROR == sts)
169             break;
170         m_stream.ReleaseRef();
171     }
172 }
validProfile(const PXCCapture::VideoStream::ProfileInfo &)173 bool IntelPerCStreamBase::validProfile(const PXCCapture::VideoStream::ProfileInfo& /*pinfo*/)
174 {
175     return true;
176 }
enumProfiles()177 void IntelPerCStreamBase::enumProfiles()
178 {
179     m_profiles.clear();
180     if (!m_stream.IsValid())
181         return;
182     pxcStatus sts = PXC_STATUS_NO_ERROR;
183     for (int profidx = 0; PXC_STATUS_NO_ERROR <= sts; profidx++)
184     {
185         PXCCapture::VideoStream::ProfileInfo pinfo;
186         sts = m_stream->QueryProfile(profidx, &pinfo);
187         if (PXC_STATUS_NO_ERROR > sts)
188             break;
189         if (validProfile(pinfo))
190             m_profiles.push_back(pinfo);
191     }
192 }
193 
194 ///////////////// IntelPerCStreamImage //////////////////
195 
IntelPerCStreamImage()196 IntelPerCStreamImage::IntelPerCStreamImage()
197 {
198 }
~IntelPerCStreamImage()199 IntelPerCStreamImage::~IntelPerCStreamImage()
200 {
201 }
202 
initStream(PXCSession * session)203 bool IntelPerCStreamImage::initStream(PXCSession *session)
204 {
205     if (!initDevice(session))
206         return false;
207     initStreamImpl(PXCImage::IMAGE_TYPE_COLOR);
208     if (!m_stream.IsValid())
209         return false;
210     enumProfiles();
211     return true;
212 }
getProperty(int propIdx) const213 double IntelPerCStreamImage::getProperty(int propIdx) const
214 {
215     switch (propIdx)
216     {
217     case CV_CAP_PROP_BRIGHTNESS:
218         {
219             if (!m_device.IsValid())
220                 return 0.0;
221             float fret = 0.0f;
222             if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_COLOR_BRIGHTNESS, &fret))
223                 return (double)fret;
224             return 0.0;
225         }
226         break;
227     case CV_CAP_PROP_CONTRAST:
228         {
229             if (!m_device.IsValid())
230                 return 0.0;
231             float fret = 0.0f;
232             if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_COLOR_CONTRAST, &fret))
233                 return (double)fret;
234             return 0.0;
235         }
236         break;
237     case CV_CAP_PROP_SATURATION:
238         {
239             if (!m_device.IsValid())
240                 return 0.0;
241             float fret = 0.0f;
242             if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_COLOR_SATURATION, &fret))
243                 return (double)fret;
244             return 0.0;
245         }
246         break;
247     case CV_CAP_PROP_HUE:
248         {
249             if (!m_device.IsValid())
250                 return 0.0;
251             float fret = 0.0f;
252             if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_COLOR_HUE, &fret))
253                 return (double)fret;
254             return 0.0;
255         }
256         break;
257     case CV_CAP_PROP_GAMMA:
258         {
259             if (!m_device.IsValid())
260                 return 0.0;
261             float fret = 0.0f;
262             if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_COLOR_GAMMA, &fret))
263                 return (double)fret;
264             return 0.0;
265         }
266         break;
267     case CV_CAP_PROP_SHARPNESS:
268         {
269             if (!m_device.IsValid())
270                 return 0.0;
271             float fret = 0.0f;
272             if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_COLOR_SHARPNESS, &fret))
273                 return (double)fret;
274             return 0.0;
275         }
276         break;
277     case CV_CAP_PROP_GAIN:
278         {
279             if (!m_device.IsValid())
280                 return 0.0;
281             float fret = 0.0f;
282             if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_COLOR_GAIN, &fret))
283                 return (double)fret;
284             return 0.0;
285         }
286         break;
287     case CV_CAP_PROP_BACKLIGHT:
288         {
289             if (!m_device.IsValid())
290                 return 0.0;
291             float fret = 0.0f;
292             if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_COLOR_BACK_LIGHT_COMPENSATION, &fret))
293                 return (double)fret;
294             return 0.0;
295         }
296         break;
297     case CV_CAP_PROP_EXPOSURE:
298         {
299             if (!m_device.IsValid())
300                 return 0.0;
301             float fret = 0.0f;
302             if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_COLOR_EXPOSURE, &fret))
303                 return (double)fret;
304             return 0.0;
305         }
306         break;
307     //Add image stream specific properties
308     }
309     return IntelPerCStreamBase::getProperty(propIdx);
310 }
setProperty(int propIdx,double propVal)311 bool IntelPerCStreamImage::setProperty(int propIdx, double propVal)
312 {
313     switch (propIdx)
314     {
315     case CV_CAP_PROP_BRIGHTNESS:
316         {
317             if (!m_device.IsValid())
318                 return false;
319             return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_COLOR_BRIGHTNESS, (float)propVal));
320         }
321         break;
322     case CV_CAP_PROP_CONTRAST:
323         {
324             if (!m_device.IsValid())
325                 return false;
326             return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_COLOR_CONTRAST, (float)propVal));
327         }
328         break;
329     case CV_CAP_PROP_SATURATION:
330         {
331             if (!m_device.IsValid())
332                 return false;
333             return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_COLOR_SATURATION, (float)propVal));
334         }
335         break;
336     case CV_CAP_PROP_HUE:
337         {
338             if (!m_device.IsValid())
339                 return false;
340             return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_COLOR_HUE, (float)propVal));
341         }
342         break;
343     case CV_CAP_PROP_GAMMA:
344         {
345             if (!m_device.IsValid())
346                 return false;
347             return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_COLOR_GAMMA, (float)propVal));
348         }
349         break;
350     case CV_CAP_PROP_SHARPNESS:
351         {
352             if (!m_device.IsValid())
353                 return false;
354             return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_COLOR_SHARPNESS, (float)propVal));
355         }
356         break;
357     case CV_CAP_PROP_GAIN:
358         {
359             if (!m_device.IsValid())
360                 return false;
361             return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_COLOR_GAIN, (float)propVal));
362         }
363         break;
364     case CV_CAP_PROP_BACKLIGHT:
365         {
366             if (!m_device.IsValid())
367                 return false;
368             return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_COLOR_BACK_LIGHT_COMPENSATION, (float)propVal));
369         }
370         break;
371     case CV_CAP_PROP_EXPOSURE:
372         {
373             if (!m_device.IsValid())
374                 return false;
375             return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_COLOR_EXPOSURE, (float)propVal));
376         }
377         break;
378     //Add image stream specific properties
379     }
380     return IntelPerCStreamBase::setProperty(propIdx, propVal);
381 }
retrieveAsOutputArray(cv::OutputArray image)382 bool IntelPerCStreamImage::retrieveAsOutputArray(cv::OutputArray image)
383 {
384     if (!m_pxcImage.IsValid())
385         return false;
386     PXCImage::ImageInfo info;
387     m_pxcImage->QueryInfo(&info);
388 
389     PXCImage::ImageData data;
390     m_pxcImage->AcquireAccess(PXCImage::ACCESS_READ, PXCImage::COLOR_FORMAT_RGB24, &data);
391 
392     if (PXCImage::SURFACE_TYPE_SYSTEM_MEMORY != data.type)
393         return false;
394 
395     cv::Mat temp(info.height, info.width, CV_8UC3, data.planes[0], data.pitches[0]);
396     temp.copyTo(image);
397 
398     m_pxcImage->ReleaseAccess(&data);
399     return true;
400 }
401 
402 ///////////////// IntelPerCStreamDepth //////////////////
403 
IntelPerCStreamDepth()404 IntelPerCStreamDepth::IntelPerCStreamDepth()
405 {
406 }
~IntelPerCStreamDepth()407 IntelPerCStreamDepth::~IntelPerCStreamDepth()
408 {
409 }
410 
initStream(PXCSession * session)411 bool IntelPerCStreamDepth::initStream(PXCSession *session)
412 {
413     if (!initDevice(session))
414         return false;
415     initStreamImpl(PXCImage::IMAGE_TYPE_DEPTH);
416     if (!m_stream.IsValid())
417         return false;
418     enumProfiles();
419     return true;
420 }
getProperty(int propIdx) const421 double IntelPerCStreamDepth::getProperty(int propIdx) const
422 {
423     switch (propIdx)
424     {
425     case CV_CAP_PROP_INTELPERC_DEPTH_LOW_CONFIDENCE_VALUE:
426         {
427             if (!m_device.IsValid())
428                 return 0.0;
429             float fret = 0.0f;
430             if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_DEPTH_LOW_CONFIDENCE_VALUE, &fret))
431                 return (double)fret;
432             return 0.0;
433         }
434         break;
435     case CV_CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE:
436         {
437             if (!m_device.IsValid())
438                 return 0.0;
439             float fret = 0.0f;
440             if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_DEPTH_SATURATION_VALUE, &fret))
441                 return (double)fret;
442             return 0.0;
443         }
444         break;
445     case CV_CAP_PROP_INTELPERC_DEPTH_CONFIDENCE_THRESHOLD:
446         {
447             if (!m_device.IsValid())
448                 return 0.0;
449             float fret = 0.0f;
450             if (PXC_STATUS_NO_ERROR == m_device->QueryProperty(PXCCapture::Device::PROPERTY_DEPTH_CONFIDENCE_THRESHOLD, &fret))
451                 return (double)fret;
452             return 0.0;
453         }
454         break;
455     case CV_CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_HORZ:
456         {
457             if (!m_device.IsValid())
458                 return 0.0f;
459             PXCPointF32 ptf;
460             if (PXC_STATUS_NO_ERROR == m_device->QueryPropertyAsPoint(PXCCapture::Device::PROPERTY_DEPTH_FOCAL_LENGTH, &ptf))
461                 return (double)ptf.x;
462             return 0.0;
463         }
464         break;
465     case CV_CAP_PROP_INTELPERC_DEPTH_FOCAL_LENGTH_VERT:
466         {
467             if (!m_device.IsValid())
468                 return 0.0f;
469             PXCPointF32 ptf;
470             if (PXC_STATUS_NO_ERROR == m_device->QueryPropertyAsPoint(PXCCapture::Device::PROPERTY_DEPTH_FOCAL_LENGTH, &ptf))
471                 return (double)ptf.y;
472             return 0.0;
473         }
474         break;
475         //Add depth stream sepcific properties
476     }
477     return IntelPerCStreamBase::getProperty(propIdx);
478 }
setProperty(int propIdx,double propVal)479 bool IntelPerCStreamDepth::setProperty(int propIdx, double propVal)
480 {
481     switch (propIdx)
482     {
483     case CV_CAP_PROP_INTELPERC_DEPTH_LOW_CONFIDENCE_VALUE:
484         {
485             if (!m_device.IsValid())
486                 return false;
487             return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_DEPTH_LOW_CONFIDENCE_VALUE, (float)propVal));
488         }
489         break;
490     case CV_CAP_PROP_INTELPERC_DEPTH_SATURATION_VALUE:
491         {
492             if (!m_device.IsValid())
493                 return false;
494             return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_DEPTH_SATURATION_VALUE, (float)propVal));
495         }
496         break;
497     case CV_CAP_PROP_INTELPERC_DEPTH_CONFIDENCE_THRESHOLD:
498         {
499             if (!m_device.IsValid())
500                 return false;
501             return (PXC_STATUS_NO_ERROR == m_device->SetProperty(PXCCapture::Device::PROPERTY_DEPTH_CONFIDENCE_THRESHOLD, (float)propVal));
502         }
503         break;
504     //Add depth stream sepcific properties
505     }
506     return IntelPerCStreamBase::setProperty(propIdx, propVal);
507 }
retrieveDepthAsOutputArray(cv::OutputArray image)508 bool IntelPerCStreamDepth::retrieveDepthAsOutputArray(cv::OutputArray image)
509 {
510     return retriveFrame(CV_16SC1, 0, image);
511 }
retrieveIRAsOutputArray(cv::OutputArray image)512 bool IntelPerCStreamDepth::retrieveIRAsOutputArray(cv::OutputArray image)
513 {
514     return retriveFrame(CV_16SC1, 1, image);
515 }
retrieveUVAsOutputArray(cv::OutputArray image)516 bool IntelPerCStreamDepth::retrieveUVAsOutputArray(cv::OutputArray image)
517 {
518     return retriveFrame(CV_32FC2, 2, image);
519 }
validProfile(const PXCCapture::VideoStream::ProfileInfo & pinfo)520 bool IntelPerCStreamDepth::validProfile(const PXCCapture::VideoStream::ProfileInfo& pinfo)
521 {
522     return (PXCImage::COLOR_FORMAT_DEPTH == pinfo.imageInfo.format);
523 }
retriveFrame(int type,int planeIdx,cv::OutputArray frame)524 bool IntelPerCStreamDepth::retriveFrame(int type, int planeIdx, cv::OutputArray frame)
525 {
526     if (!m_pxcImage.IsValid())
527         return false;
528     PXCImage::ImageInfo info;
529     m_pxcImage->QueryInfo(&info);
530 
531     PXCImage::ImageData data;
532     m_pxcImage->AcquireAccess(PXCImage::ACCESS_READ, &data);
533 
534     if (PXCImage::SURFACE_TYPE_SYSTEM_MEMORY != data.type)
535         return false;
536 
537     cv::Mat temp(info.height, info.width, type, data.planes[planeIdx], data.pitches[planeIdx]);
538     temp.copyTo(frame);
539 
540     m_pxcImage->ReleaseAccess(&data);
541     return true;
542 }
543 
544 ///////////////// VideoCapture_IntelPerC //////////////////
545 
VideoCapture_IntelPerC()546 VideoCapture_IntelPerC::VideoCapture_IntelPerC()
547     : m_contextOpened(false)
548 {
549     pxcStatus sts = PXCSession_Create(&m_session);
550     if (PXC_STATUS_NO_ERROR > sts)
551         return;
552     m_contextOpened = m_imageStream.initStream(m_session);
553     m_contextOpened &= m_depthStream.initStream(m_session);
554 }
~VideoCapture_IntelPerC()555 VideoCapture_IntelPerC::~VideoCapture_IntelPerC(){}
556 
getProperty(int propIdx) const557 double VideoCapture_IntelPerC::getProperty(int propIdx) const
558 {
559     double propValue = 0;
560     int purePropIdx = propIdx & ~CV_CAP_INTELPERC_GENERATORS_MASK;
561     if (CV_CAP_INTELPERC_IMAGE_GENERATOR == (propIdx & CV_CAP_INTELPERC_GENERATORS_MASK))
562     {
563         propValue = m_imageStream.getProperty(purePropIdx);
564     }
565     else if (CV_CAP_INTELPERC_DEPTH_GENERATOR == (propIdx & CV_CAP_INTELPERC_GENERATORS_MASK))
566     {
567         propValue = m_depthStream.getProperty(purePropIdx);
568     }
569     else
570     {
571         propValue = m_depthStream.getProperty(purePropIdx);
572     }
573     return propValue;
574 }
setProperty(int propIdx,double propVal)575 bool VideoCapture_IntelPerC::setProperty(int propIdx, double propVal)
576 {
577     bool isSet = false;
578     int purePropIdx = propIdx & ~CV_CAP_INTELPERC_GENERATORS_MASK;
579     if (CV_CAP_INTELPERC_IMAGE_GENERATOR == (propIdx & CV_CAP_INTELPERC_GENERATORS_MASK))
580     {
581         isSet = m_imageStream.setProperty(purePropIdx, propVal);
582     }
583     else if (CV_CAP_INTELPERC_DEPTH_GENERATOR == (propIdx & CV_CAP_INTELPERC_GENERATORS_MASK))
584     {
585         isSet = m_depthStream.setProperty(purePropIdx, propVal);
586     }
587     else
588     {
589         isSet = m_depthStream.setProperty(purePropIdx, propVal);
590     }
591     return isSet;
592 }
593 
grabFrame()594 bool VideoCapture_IntelPerC::grabFrame()
595 {
596     if (!isOpened())
597         return false;
598 
599     bool isGrabbed = false;
600     if (m_depthStream.isValid())
601         isGrabbed = m_depthStream.grabFrame();
602     if ((m_imageStream.isValid()) && (-1 != m_imageStream.getProfileIDX()))
603         isGrabbed &= m_imageStream.grabFrame();
604 
605     return isGrabbed;
606 }
retrieveFrame(int outputType,cv::OutputArray frame)607 bool VideoCapture_IntelPerC::retrieveFrame(int outputType, cv::OutputArray frame)
608 {
609     switch (outputType)
610     {
611     case CV_CAP_INTELPERC_DEPTH_MAP:
612         return m_depthStream.retrieveDepthAsOutputArray(frame);
613     case CV_CAP_INTELPERC_UVDEPTH_MAP:
614         return m_depthStream.retrieveUVAsOutputArray(frame);
615     case CV_CAP_INTELPERC_IR_MAP:
616         return m_depthStream.retrieveIRAsOutputArray(frame);
617     case CV_CAP_INTELPERC_IMAGE:
618         return m_imageStream.retrieveAsOutputArray(frame);
619     }
620     return false;
621 }
getCaptureDomain()622 int VideoCapture_IntelPerC::getCaptureDomain()
623 {
624     return CV_CAP_INTELPERC;
625 }
626 
isOpened() const627 bool VideoCapture_IntelPerC::isOpened() const
628 {
629     return m_contextOpened;
630 }
631 
632 }
633 
634 #endif //HAVE_INTELPERC
635