Home | History | Annotate | Download | only in src
      1 /*M///////////////////////////////////////////////////////////////////////////////////////
      2 //
      3 // This file is part of OpenCV project.
      4 // It is subject to the license terms in the LICENSE file found in the top-level directory
      5 // of this distribution and at http://opencv.org/license.html.
      6 //
      7 // Copyright (C) 2014, Itseez, Inc., all rights reserved.
      8 // Third party copyrights are property of their respective owners.
      9 //
     10 //M*/
     11 
     12 #ifndef _CAP_INTELPERC_HPP_
     13 #define _CAP_INTELPERC_HPP_
     14 
     15 #include "precomp.hpp"
     16 
     17 #ifdef HAVE_INTELPERC
     18 
     19 #include "pxcsession.h"
     20 #include "pxcsmartptr.h"
     21 #include "pxccapture.h"
     22 
     23 namespace cv
     24 {
     25 
     26 class IntelPerCStreamBase
     27 {
     28 public:
     29     IntelPerCStreamBase();
     30     virtual ~IntelPerCStreamBase();
     31 
     32     bool isValid();
     33     bool grabFrame();
     34     int getProfileIDX() const;
     35 public:
     36     virtual bool initStream(PXCSession *session)            = 0;
     37     virtual double getProperty(int propIdx) const;
     38     virtual bool setProperty(int propIdx, double propVal);
     39 protected:
     40     mutable PXCSmartPtr<PXCCapture::Device> m_device;
     41     bool initDevice(PXCSession *session);
     42 
     43     PXCSmartPtr<PXCCapture::VideoStream> m_stream;
     44     void initStreamImpl(PXCImage::ImageType type);
     45 protected:
     46     std::vector<PXCCapture::VideoStream::ProfileInfo> m_profiles;
     47     int m_profileIdx;
     48     int m_frameIdx;
     49     pxcU64 m_timeStampStartNS;
     50     double m_timeStamp;
     51     PXCSmartPtr<PXCImage> m_pxcImage;
     52 
     53     virtual bool validProfile(const PXCCapture::VideoStream::ProfileInfo& /*pinfo*/);
     54     void enumProfiles();
     55 };
     56 
     57 class IntelPerCStreamImage
     58     : public IntelPerCStreamBase
     59 {
     60 public:
     61     IntelPerCStreamImage();
     62     virtual ~IntelPerCStreamImage();
     63 
     64     virtual bool initStream(PXCSession *session);
     65     virtual double getProperty(int propIdx) const;
     66     virtual bool setProperty(int propIdx, double propVal);
     67 public:
     68     bool retrieveAsOutputArray(OutputArray image);
     69 };
     70 
     71 class IntelPerCStreamDepth
     72     : public IntelPerCStreamBase
     73 {
     74 public:
     75     IntelPerCStreamDepth();
     76     virtual ~IntelPerCStreamDepth();
     77 
     78     virtual bool initStream(PXCSession *session);
     79     virtual double getProperty(int propIdx) const;
     80     virtual bool setProperty(int propIdx, double propVal);
     81 public:
     82     bool retrieveDepthAsOutputArray(OutputArray image);
     83     bool retrieveIRAsOutputArray(OutputArray image);
     84     bool retrieveUVAsOutputArray(OutputArray image);
     85 protected:
     86     virtual bool validProfile(const PXCCapture::VideoStream::ProfileInfo& pinfo);
     87 protected:
     88     bool retriveFrame(int type, int planeIdx, OutputArray frame);
     89 };
     90 
     91 class VideoCapture_IntelPerC : public IVideoCapture
     92 {
     93 public:
     94     VideoCapture_IntelPerC();
     95     virtual ~VideoCapture_IntelPerC();
     96 
     97     virtual double getProperty(int propIdx) const;
     98     virtual bool setProperty(int propIdx, double propVal);
     99 
    100     virtual bool grabFrame();
    101     virtual bool retrieveFrame(int outputType, OutputArray frame);
    102     virtual int getCaptureDomain();
    103     virtual bool isOpened() const;
    104 protected:
    105     bool m_contextOpened;
    106 
    107     PXCSmartPtr<PXCSession> m_session;
    108     IntelPerCStreamImage m_imageStream;
    109     IntelPerCStreamDepth m_depthStream;
    110 };
    111 
    112 }
    113 
    114 #endif //HAVE_INTELPERC
    115 #endif //_CAP_INTELPERC_HPP_