Remove implementation of CvCapture interface for Intel PerC camera. Add IVideoCapture interface and implementation of this one for Intel PerC camera
This commit is contained in:
parent
73dfc4cb8c
commit
ff8b8ef24c
@ -530,6 +530,18 @@ enum { CAP_INTELPERC_DEPTH_MAP = 0, // Each pixel is a 16-bit integ
|
||||
CAP_INTELPERC_IMAGE = 3
|
||||
};
|
||||
|
||||
|
||||
class IVideoCapture
|
||||
{
|
||||
public:
|
||||
virtual ~IVideoCapture() {}
|
||||
virtual double getProperty(int) { return 0; }
|
||||
virtual bool setProperty(int, double) { return 0; }
|
||||
virtual bool grabFrame() { return true; }
|
||||
virtual bool retrieveFrame(int, cv::OutputArray) { return 0; }
|
||||
virtual int getCaptureDomain() { return CAP_ANY; } // Return the type of the capture object: CAP_VFW, etc...
|
||||
};
|
||||
|
||||
class CV_EXPORTS_W VideoCapture
|
||||
{
|
||||
public:
|
||||
@ -554,9 +566,11 @@ public:
|
||||
|
||||
protected:
|
||||
Ptr<CvCapture> cap;
|
||||
Ptr<IVideoCapture> icap;
|
||||
private:
|
||||
static Ptr<IVideoCapture> createCameraCapture(int index);
|
||||
};
|
||||
|
||||
|
||||
class CV_EXPORTS_W VideoWriter
|
||||
{
|
||||
public:
|
||||
|
@ -40,6 +40,7 @@
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "cap_intelperc.hpp"
|
||||
|
||||
#if defined _M_X64 && defined _MSC_VER && !defined CV_ICC
|
||||
#pragma optimize("",off)
|
||||
@ -345,14 +346,6 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
|
||||
return capture;
|
||||
break; // CV_CAP_GIGANETIX
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_INTELPERC
|
||||
case CV_CAP_INTELPERC:
|
||||
capture = cvCreateCameraCapture_IntelPerC(index);
|
||||
if (capture)
|
||||
return capture;
|
||||
break; // CV_CAP_INTEL_PERC
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -497,6 +490,7 @@ VideoCapture::VideoCapture(int device)
|
||||
|
||||
VideoCapture::~VideoCapture()
|
||||
{
|
||||
icap.release();
|
||||
cap.release();
|
||||
}
|
||||
|
||||
@ -510,24 +504,36 @@ bool VideoCapture::open(const String& filename)
|
||||
bool VideoCapture::open(int device)
|
||||
{
|
||||
if (isOpened()) release();
|
||||
icap = createCameraCapture(device);
|
||||
if (!icap.empty())
|
||||
return true;
|
||||
cap.reset(cvCreateCameraCapture(device));
|
||||
return isOpened();
|
||||
}
|
||||
|
||||
bool VideoCapture::isOpened() const { return !cap.empty(); }
|
||||
bool VideoCapture::isOpened() const
|
||||
{
|
||||
return (!cap.empty() || !icap.empty());
|
||||
}
|
||||
|
||||
void VideoCapture::release()
|
||||
{
|
||||
icap.release();
|
||||
cap.release();
|
||||
}
|
||||
|
||||
bool VideoCapture::grab()
|
||||
{
|
||||
if (!icap.empty())
|
||||
return icap->grabFrame();
|
||||
return cvGrabFrame(cap) != 0;
|
||||
}
|
||||
|
||||
bool VideoCapture::retrieve(OutputArray image, int channel)
|
||||
{
|
||||
if (!icap.empty())
|
||||
return icap->retrieveFrame(channel, image);
|
||||
|
||||
IplImage* _img = cvRetrieveFrame(cap, channel);
|
||||
if( !_img )
|
||||
{
|
||||
@ -567,14 +573,62 @@ VideoCapture& VideoCapture::operator >> (UMat& image)
|
||||
|
||||
bool VideoCapture::set(int propId, double value)
|
||||
{
|
||||
if (!icap.empty())
|
||||
return icap->setProperty(propId, value);
|
||||
return cvSetCaptureProperty(cap, propId, value) != 0;
|
||||
}
|
||||
|
||||
double VideoCapture::get(int propId)
|
||||
{
|
||||
if (!icap.empty())
|
||||
return icap->getProperty(propId);
|
||||
return cvGetCaptureProperty(cap, propId);
|
||||
}
|
||||
|
||||
Ptr<IVideoCapture> VideoCapture::createCameraCapture(int index)
|
||||
{
|
||||
int domains[] =
|
||||
{
|
||||
#ifdef HAVE_INTELPERC
|
||||
CV_CAP_INTELPERC,
|
||||
#endif
|
||||
-1, -1
|
||||
};
|
||||
|
||||
// interpret preferred interface (0 = autodetect)
|
||||
int pref = (index / 100) * 100;
|
||||
if (pref)
|
||||
{
|
||||
domains[0]=pref;
|
||||
index %= 100;
|
||||
domains[1]=-1;
|
||||
}
|
||||
|
||||
// try every possibly installed camera API
|
||||
for (int i = 0; domains[i] >= 0; i++)
|
||||
{
|
||||
#if defined(HAVE_INTELPERC) || \
|
||||
(0)
|
||||
Ptr<IVideoCapture> capture;
|
||||
|
||||
switch (domains[i])
|
||||
{
|
||||
#ifdef HAVE_INTELPERC
|
||||
case CV_CAP_INTELPERC:
|
||||
capture = Ptr<IVideoCapture>(new cv::VideoCapture_IntelPerC());
|
||||
if (capture)
|
||||
return capture;
|
||||
break; // CV_CAP_INTEL_PERC
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// failed open a camera
|
||||
return Ptr<IVideoCapture>();
|
||||
}
|
||||
|
||||
|
||||
VideoWriter::VideoWriter()
|
||||
{}
|
||||
|
||||
|
@ -1,44 +1,28 @@
|
||||
#include "precomp.hpp"
|
||||
|
||||
#ifdef HAVE_INTELPERC
|
||||
|
||||
#include "pxcsession.h"
|
||||
#include "pxcsmartptr.h"
|
||||
#include "pxccapture.h"
|
||||
#include "cap_intelperc.hpp"
|
||||
|
||||
class CvIntelPerCStreamBase
|
||||
namespace cv
|
||||
{
|
||||
protected:
|
||||
struct FrameInternal
|
||||
{
|
||||
IplImage* retrieveFrame()
|
||||
{
|
||||
if (m_mat.empty())
|
||||
return NULL;
|
||||
m_iplHeader = IplImage(m_mat);
|
||||
return &m_iplHeader;
|
||||
}
|
||||
cv::Mat m_mat;
|
||||
private:
|
||||
IplImage m_iplHeader;
|
||||
};
|
||||
public:
|
||||
CvIntelPerCStreamBase()
|
||||
|
||||
///////////////// IntelPerCStreamBase //////////////////
|
||||
|
||||
IntelPerCStreamBase::IntelPerCStreamBase()
|
||||
: m_profileIdx(-1)
|
||||
, m_frameIdx(0)
|
||||
, m_timeStampStartNS(0)
|
||||
{
|
||||
}
|
||||
virtual ~CvIntelPerCStreamBase()
|
||||
{
|
||||
}
|
||||
{
|
||||
}
|
||||
IntelPerCStreamBase::~IntelPerCStreamBase()
|
||||
{
|
||||
}
|
||||
|
||||
bool isValid()
|
||||
{
|
||||
bool IntelPerCStreamBase::isValid()
|
||||
{
|
||||
return (m_device.IsValid() && m_stream.IsValid());
|
||||
}
|
||||
bool grabFrame()
|
||||
{
|
||||
}
|
||||
bool IntelPerCStreamBase::grabFrame()
|
||||
{
|
||||
if (!m_stream.IsValid())
|
||||
return false;
|
||||
if (-1 == m_profileIdx)
|
||||
@ -46,25 +30,24 @@ public:
|
||||
if (!setProperty(CV_CAP_PROP_INTELPERC_PROFILE_IDX, 0))
|
||||
return false;
|
||||
}
|
||||
PXCSmartPtr<PXCImage> pxcImage; PXCSmartSP sp;
|
||||
if (PXC_STATUS_NO_ERROR > m_stream->ReadStreamAsync(&pxcImage, &sp))
|
||||
PXCSmartSP sp;
|
||||
m_pxcImage.ReleaseRef();
|
||||
if (PXC_STATUS_NO_ERROR > m_stream->ReadStreamAsync(&m_pxcImage, &sp))
|
||||
return false;
|
||||
if (PXC_STATUS_NO_ERROR > sp->Synchronize())
|
||||
return false;
|
||||
if (0 == m_timeStampStartNS)
|
||||
m_timeStampStartNS = pxcImage->QueryTimeStamp();
|
||||
m_timeStamp = (double)((pxcImage->QueryTimeStamp() - m_timeStampStartNS) / 10000);
|
||||
m_timeStampStartNS = m_pxcImage->QueryTimeStamp();
|
||||
m_timeStamp = (double)((m_pxcImage->QueryTimeStamp() - m_timeStampStartNS) / 10000);
|
||||
m_frameIdx++;
|
||||
return prepareIplImage(pxcImage);
|
||||
}
|
||||
int getProfileIDX() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
int IntelPerCStreamBase::getProfileIDX() const
|
||||
{
|
||||
return m_profileIdx;
|
||||
}
|
||||
public:
|
||||
virtual bool initStream(PXCSession *session) = 0;
|
||||
virtual double getProperty(int propIdx)
|
||||
{
|
||||
}
|
||||
double IntelPerCStreamBase::getProperty(int propIdx)
|
||||
{
|
||||
double ret = 0.0;
|
||||
switch (propIdx)
|
||||
{
|
||||
@ -94,16 +77,21 @@ public:
|
||||
break;
|
||||
};
|
||||
return ret;
|
||||
}
|
||||
virtual bool setProperty(int propIdx, double propVal)
|
||||
{
|
||||
}
|
||||
bool IntelPerCStreamBase::setProperty(int propIdx, double propVal)
|
||||
{
|
||||
bool isSet = false;
|
||||
switch (propIdx)
|
||||
{
|
||||
case CV_CAP_PROP_INTELPERC_PROFILE_IDX:
|
||||
{
|
||||
int propValInt = (int)propVal;
|
||||
if ((0 <= propValInt) && (propValInt < m_profiles.size()))
|
||||
if (0 > propValInt)
|
||||
{
|
||||
m_profileIdx = propValInt;
|
||||
isSet = true;
|
||||
}
|
||||
else if (propValInt < m_profiles.size())
|
||||
{
|
||||
if (m_profileIdx != propValInt)
|
||||
{
|
||||
@ -119,11 +107,9 @@ public:
|
||||
break;
|
||||
};
|
||||
return isSet;
|
||||
}
|
||||
protected:
|
||||
PXCSmartPtr<PXCCapture::Device> m_device;
|
||||
bool initDevice(PXCSession *session)
|
||||
{
|
||||
}
|
||||
bool IntelPerCStreamBase::initDevice(PXCSession *session)
|
||||
{
|
||||
if (NULL == session)
|
||||
return false;
|
||||
|
||||
@ -158,11 +144,10 @@ protected:
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
PXCSmartPtr<PXCCapture::VideoStream> m_stream;
|
||||
void initStreamImpl(PXCImage::ImageType type)
|
||||
{
|
||||
void IntelPerCStreamBase::initStreamImpl(PXCImage::ImageType type)
|
||||
{
|
||||
if (!m_device.IsValid())
|
||||
return;
|
||||
|
||||
@ -184,20 +169,13 @@ protected:
|
||||
break;
|
||||
m_stream.ReleaseRef();
|
||||
}
|
||||
}
|
||||
protected:
|
||||
std::vector<PXCCapture::VideoStream::ProfileInfo> m_profiles;
|
||||
int m_profileIdx;
|
||||
int m_frameIdx;
|
||||
pxcU64 m_timeStampStartNS;
|
||||
double m_timeStamp;
|
||||
|
||||
virtual bool validProfile(const PXCCapture::VideoStream::ProfileInfo& /*pinfo*/)
|
||||
{
|
||||
}
|
||||
bool IntelPerCStreamBase::validProfile(const PXCCapture::VideoStream::ProfileInfo& /*pinfo*/)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
void enumProfiles()
|
||||
{
|
||||
}
|
||||
void IntelPerCStreamBase::enumProfiles()
|
||||
{
|
||||
m_profiles.clear();
|
||||
if (!m_stream.IsValid())
|
||||
return;
|
||||
@ -211,23 +189,19 @@ protected:
|
||||
if (validProfile(pinfo))
|
||||
m_profiles.push_back(pinfo);
|
||||
}
|
||||
}
|
||||
virtual bool prepareIplImage(PXCImage *pxcImage) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
class CvIntelPerCStreamImage
|
||||
: public CvIntelPerCStreamBase
|
||||
///////////////// IntelPerCStreamImage //////////////////
|
||||
|
||||
IntelPerCStreamImage::IntelPerCStreamImage()
|
||||
{
|
||||
public:
|
||||
CvIntelPerCStreamImage()
|
||||
{
|
||||
}
|
||||
virtual ~CvIntelPerCStreamImage()
|
||||
{
|
||||
}
|
||||
}
|
||||
IntelPerCStreamImage::~IntelPerCStreamImage()
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool initStream(PXCSession *session)
|
||||
{
|
||||
bool IntelPerCStreamImage::initStream(PXCSession *session)
|
||||
{
|
||||
if (!initDevice(session))
|
||||
return false;
|
||||
initStreamImpl(PXCImage::IMAGE_TYPE_COLOR);
|
||||
@ -235,9 +209,9 @@ public:
|
||||
return false;
|
||||
enumProfiles();
|
||||
return true;
|
||||
}
|
||||
virtual double getProperty(int propIdx)
|
||||
{
|
||||
}
|
||||
double IntelPerCStreamImage::getProperty(int propIdx)
|
||||
{
|
||||
switch (propIdx)
|
||||
{
|
||||
case CV_CAP_PROP_BRIGHTNESS:
|
||||
@ -332,10 +306,10 @@ public:
|
||||
break;
|
||||
//Add image stream specific properties
|
||||
}
|
||||
return CvIntelPerCStreamBase::getProperty(propIdx);
|
||||
}
|
||||
virtual bool setProperty(int propIdx, double propVal)
|
||||
{
|
||||
return IntelPerCStreamBase::getProperty(propIdx);
|
||||
}
|
||||
bool IntelPerCStreamImage::setProperty(int propIdx, double propVal)
|
||||
{
|
||||
switch (propIdx)
|
||||
{
|
||||
case CV_CAP_PROP_BRIGHTNESS:
|
||||
@ -403,49 +377,39 @@ public:
|
||||
break;
|
||||
//Add image stream specific properties
|
||||
}
|
||||
return CvIntelPerCStreamBase::setProperty(propIdx, propVal);
|
||||
}
|
||||
public:
|
||||
IplImage* retrieveFrame()
|
||||
{
|
||||
return m_frame.retrieveFrame();
|
||||
}
|
||||
protected:
|
||||
FrameInternal m_frame;
|
||||
bool prepareIplImage(PXCImage *pxcImage)
|
||||
{
|
||||
if (NULL == pxcImage)
|
||||
return IntelPerCStreamBase::setProperty(propIdx, propVal);
|
||||
}
|
||||
bool IntelPerCStreamImage::retrieveAsOutputArray(cv::OutputArray image)
|
||||
{
|
||||
if (!m_pxcImage.IsValid())
|
||||
return false;
|
||||
PXCImage::ImageInfo info;
|
||||
pxcImage->QueryInfo(&info);
|
||||
m_pxcImage->QueryInfo(&info);
|
||||
|
||||
PXCImage::ImageData data;
|
||||
pxcImage->AcquireAccess(PXCImage::ACCESS_READ, PXCImage::COLOR_FORMAT_RGB24, &data);
|
||||
m_pxcImage->AcquireAccess(PXCImage::ACCESS_READ, PXCImage::COLOR_FORMAT_RGB24, &data);
|
||||
|
||||
if (PXCImage::SURFACE_TYPE_SYSTEM_MEMORY != data.type)
|
||||
return false;
|
||||
|
||||
cv::Mat temp(info.height, info.width, CV_8UC3, data.planes[0], data.pitches[0]);
|
||||
temp.copyTo(m_frame.m_mat);
|
||||
temp.copyTo(image);
|
||||
|
||||
pxcImage->ReleaseAccess(&data);
|
||||
m_pxcImage->ReleaseAccess(&data);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
class CvIntelPerCStreamDepth
|
||||
: public CvIntelPerCStreamBase
|
||||
///////////////// IntelPerCStreamDepth //////////////////
|
||||
|
||||
IntelPerCStreamDepth::IntelPerCStreamDepth()
|
||||
{
|
||||
public:
|
||||
CvIntelPerCStreamDepth()
|
||||
{
|
||||
}
|
||||
virtual ~CvIntelPerCStreamDepth()
|
||||
{
|
||||
}
|
||||
}
|
||||
IntelPerCStreamDepth::~IntelPerCStreamDepth()
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool initStream(PXCSession *session)
|
||||
{
|
||||
bool IntelPerCStreamDepth::initStream(PXCSession *session)
|
||||
{
|
||||
if (!initDevice(session))
|
||||
return false;
|
||||
initStreamImpl(PXCImage::IMAGE_TYPE_DEPTH);
|
||||
@ -453,9 +417,9 @@ public:
|
||||
return false;
|
||||
enumProfiles();
|
||||
return true;
|
||||
}
|
||||
virtual double getProperty(int propIdx)
|
||||
{
|
||||
}
|
||||
double IntelPerCStreamDepth::getProperty(int propIdx)
|
||||
{
|
||||
switch (propIdx)
|
||||
{
|
||||
case CV_CAP_PROP_INTELPERC_DEPTH_LOW_CONFIDENCE_VALUE:
|
||||
@ -510,10 +474,10 @@ public:
|
||||
break;
|
||||
//Add depth stream sepcific properties
|
||||
}
|
||||
return CvIntelPerCStreamBase::getProperty(propIdx);
|
||||
}
|
||||
virtual bool setProperty(int propIdx, double propVal)
|
||||
{
|
||||
return IntelPerCStreamBase::getProperty(propIdx);
|
||||
}
|
||||
bool IntelPerCStreamDepth::setProperty(int propIdx, double propVal)
|
||||
{
|
||||
switch (propIdx)
|
||||
{
|
||||
case CV_CAP_PROP_INTELPERC_DEPTH_LOW_CONFIDENCE_VALUE:
|
||||
@ -539,82 +503,59 @@ public:
|
||||
break;
|
||||
//Add depth stream sepcific properties
|
||||
}
|
||||
return CvIntelPerCStreamBase::setProperty(propIdx, propVal);
|
||||
}
|
||||
public:
|
||||
IplImage* retrieveDepthFrame()
|
||||
{
|
||||
return m_frameDepth.retrieveFrame();
|
||||
}
|
||||
IplImage* retrieveIRFrame()
|
||||
{
|
||||
return m_frameIR.retrieveFrame();
|
||||
}
|
||||
IplImage* retrieveUVFrame()
|
||||
{
|
||||
return m_frameUV.retrieveFrame();
|
||||
}
|
||||
protected:
|
||||
virtual bool validProfile(const PXCCapture::VideoStream::ProfileInfo& pinfo)
|
||||
{
|
||||
return IntelPerCStreamBase::setProperty(propIdx, propVal);
|
||||
}
|
||||
bool IntelPerCStreamDepth::retrieveDepthAsOutputArray(cv::OutputArray image)
|
||||
{
|
||||
return retriveFrame(CV_16SC1, 0, image);
|
||||
}
|
||||
bool IntelPerCStreamDepth::retrieveIRAsOutputArray(cv::OutputArray image)
|
||||
{
|
||||
return retriveFrame(CV_16SC1, 1, image);
|
||||
}
|
||||
bool IntelPerCStreamDepth::retrieveUVAsOutputArray(cv::OutputArray image)
|
||||
{
|
||||
return retriveFrame(CV_32FC2, 2, image);
|
||||
}
|
||||
bool IntelPerCStreamDepth::validProfile(const PXCCapture::VideoStream::ProfileInfo& pinfo)
|
||||
{
|
||||
return (PXCImage::COLOR_FORMAT_DEPTH == pinfo.imageInfo.format);
|
||||
}
|
||||
protected:
|
||||
FrameInternal m_frameDepth;
|
||||
FrameInternal m_frameIR;
|
||||
FrameInternal m_frameUV;
|
||||
|
||||
bool prepareIplImage(PXCImage *pxcImage)
|
||||
{
|
||||
if (NULL == pxcImage)
|
||||
}
|
||||
bool IntelPerCStreamDepth::retriveFrame(int type, int planeIdx, cv::OutputArray frame)
|
||||
{
|
||||
if (!m_pxcImage.IsValid())
|
||||
return false;
|
||||
PXCImage::ImageInfo info;
|
||||
pxcImage->QueryInfo(&info);
|
||||
m_pxcImage->QueryInfo(&info);
|
||||
|
||||
PXCImage::ImageData data;
|
||||
pxcImage->AcquireAccess(PXCImage::ACCESS_READ, &data);
|
||||
m_pxcImage->AcquireAccess(PXCImage::ACCESS_READ, &data);
|
||||
|
||||
if (PXCImage::SURFACE_TYPE_SYSTEM_MEMORY != data.type)
|
||||
return false;
|
||||
|
||||
if (PXCImage::COLOR_FORMAT_DEPTH != data.format)
|
||||
return false;
|
||||
cv::Mat temp(info.height, info.width, type, data.planes[planeIdx], data.pitches[planeIdx]);
|
||||
temp.copyTo(frame);
|
||||
|
||||
{
|
||||
cv::Mat temp(info.height, info.width, CV_16SC1, data.planes[0], data.pitches[0]);
|
||||
temp.copyTo(m_frameDepth.m_mat);
|
||||
}
|
||||
{
|
||||
cv::Mat temp(info.height, info.width, CV_16SC1, data.planes[1], data.pitches[1]);
|
||||
temp.copyTo(m_frameIR.m_mat);
|
||||
}
|
||||
{
|
||||
cv::Mat temp(info.height, info.width, CV_32FC2, data.planes[2], data.pitches[2]);
|
||||
temp.copyTo(m_frameUV.m_mat);
|
||||
}
|
||||
|
||||
pxcImage->ReleaseAccess(&data);
|
||||
m_pxcImage->ReleaseAccess(&data);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
class CvCapture_IntelPerC : public CvCapture
|
||||
{
|
||||
public:
|
||||
CvCapture_IntelPerC(int /*index*/)
|
||||
///////////////// VideoCapture_IntelPerC //////////////////
|
||||
|
||||
VideoCapture_IntelPerC::VideoCapture_IntelPerC()
|
||||
: m_contextOpened(false)
|
||||
{
|
||||
{
|
||||
pxcStatus sts = PXCSession_Create(&m_session);
|
||||
if (PXC_STATUS_NO_ERROR > sts)
|
||||
return;
|
||||
m_contextOpened = m_imageStream.initStream(m_session);
|
||||
m_contextOpened &= m_depthStream.initStream(m_session);
|
||||
}
|
||||
virtual ~CvCapture_IntelPerC(){}
|
||||
}
|
||||
VideoCapture_IntelPerC::~VideoCapture_IntelPerC(){}
|
||||
|
||||
virtual double getProperty(int propIdx)
|
||||
{
|
||||
double VideoCapture_IntelPerC::getProperty(int propIdx)
|
||||
{
|
||||
double propValue = 0;
|
||||
int purePropIdx = propIdx & ~CV_CAP_INTELPERC_GENERATORS_MASK;
|
||||
if (CV_CAP_INTELPERC_IMAGE_GENERATOR == (propIdx & CV_CAP_INTELPERC_GENERATORS_MASK))
|
||||
@ -630,9 +571,9 @@ public:
|
||||
propValue = m_depthStream.getProperty(purePropIdx);
|
||||
}
|
||||
return propValue;
|
||||
}
|
||||
virtual bool setProperty(int propIdx, double propVal)
|
||||
{
|
||||
}
|
||||
bool VideoCapture_IntelPerC::setProperty(int propIdx, double propVal)
|
||||
{
|
||||
bool isSet = false;
|
||||
int purePropIdx = propIdx & ~CV_CAP_INTELPERC_GENERATORS_MASK;
|
||||
if (CV_CAP_INTELPERC_IMAGE_GENERATOR == (propIdx & CV_CAP_INTELPERC_GENERATORS_MASK))
|
||||
@ -648,10 +589,10 @@ public:
|
||||
isSet = m_depthStream.setProperty(purePropIdx, propVal);
|
||||
}
|
||||
return isSet;
|
||||
}
|
||||
}
|
||||
|
||||
bool grabFrame()
|
||||
{
|
||||
bool VideoCapture_IntelPerC::grabFrame()
|
||||
{
|
||||
if (!isOpened())
|
||||
return false;
|
||||
|
||||
@ -662,53 +603,32 @@ public:
|
||||
isGrabbed &= m_imageStream.grabFrame();
|
||||
|
||||
return isGrabbed;
|
||||
}
|
||||
|
||||
virtual IplImage* retrieveFrame(int outputType)
|
||||
{
|
||||
IplImage* image = 0;
|
||||
}
|
||||
bool VideoCapture_IntelPerC::retrieveFrame(int outputType, cv::OutputArray frame)
|
||||
{
|
||||
switch (outputType)
|
||||
{
|
||||
case CV_CAP_INTELPERC_DEPTH_MAP:
|
||||
image = m_depthStream.retrieveDepthFrame();
|
||||
break;
|
||||
return m_depthStream.retrieveDepthAsOutputArray(frame);
|
||||
case CV_CAP_INTELPERC_UVDEPTH_MAP:
|
||||
image = m_depthStream.retrieveUVFrame();
|
||||
break;
|
||||
return m_depthStream.retrieveUVAsOutputArray(frame);
|
||||
case CV_CAP_INTELPERC_IR_MAP:
|
||||
image = m_depthStream.retrieveIRFrame();
|
||||
break;
|
||||
return m_depthStream.retrieveIRAsOutputArray(frame);
|
||||
case CV_CAP_INTELPERC_IMAGE:
|
||||
image = m_imageStream.retrieveFrame();
|
||||
break;
|
||||
return m_imageStream.retrieveAsOutputArray(frame);
|
||||
}
|
||||
CV_Assert(NULL != image);
|
||||
return image;
|
||||
}
|
||||
|
||||
bool isOpened() const
|
||||
{
|
||||
return m_contextOpened;
|
||||
}
|
||||
protected:
|
||||
bool m_contextOpened;
|
||||
|
||||
PXCSmartPtr<PXCSession> m_session;
|
||||
CvIntelPerCStreamImage m_imageStream;
|
||||
CvIntelPerCStreamDepth m_depthStream;
|
||||
};
|
||||
|
||||
|
||||
CvCapture* cvCreateCameraCapture_IntelPerC(int index)
|
||||
return false;
|
||||
}
|
||||
int VideoCapture_IntelPerC::getCaptureDomain()
|
||||
{
|
||||
CvCapture_IntelPerC* capture = new CvCapture_IntelPerC(index);
|
||||
|
||||
if( capture->isOpened() )
|
||||
return capture;
|
||||
|
||||
delete capture;
|
||||
return 0;
|
||||
return CV_CAP_INTELPERC;
|
||||
}
|
||||
|
||||
bool VideoCapture_IntelPerC::isOpened() const
|
||||
{
|
||||
return m_contextOpened;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //HAVE_INTELPERC
|
||||
|
145
modules/highgui/src/cap_intelperc.hpp
Normal file
145
modules/highgui/src/cap_intelperc.hpp
Normal file
@ -0,0 +1,145 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef _CAP_INTELPERC_HPP_
|
||||
#define _CAP_INTELPERC_HPP_
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#ifdef HAVE_INTELPERC
|
||||
|
||||
#include "pxcsession.h"
|
||||
#include "pxcsmartptr.h"
|
||||
#include "pxccapture.h"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
class IntelPerCStreamBase
|
||||
{
|
||||
public:
|
||||
IntelPerCStreamBase();
|
||||
virtual ~IntelPerCStreamBase();
|
||||
|
||||
bool isValid();
|
||||
bool grabFrame();
|
||||
int getProfileIDX() const;
|
||||
public:
|
||||
virtual bool initStream(PXCSession *session) = 0;
|
||||
virtual double getProperty(int propIdx);
|
||||
virtual bool setProperty(int propIdx, double propVal);
|
||||
protected:
|
||||
PXCSmartPtr<PXCCapture::Device> m_device;
|
||||
bool initDevice(PXCSession *session);
|
||||
|
||||
PXCSmartPtr<PXCCapture::VideoStream> m_stream;
|
||||
void initStreamImpl(PXCImage::ImageType type);
|
||||
protected:
|
||||
std::vector<PXCCapture::VideoStream::ProfileInfo> m_profiles;
|
||||
int m_profileIdx;
|
||||
int m_frameIdx;
|
||||
pxcU64 m_timeStampStartNS;
|
||||
double m_timeStamp;
|
||||
PXCSmartPtr<PXCImage> m_pxcImage;
|
||||
|
||||
virtual bool validProfile(const PXCCapture::VideoStream::ProfileInfo& /*pinfo*/);
|
||||
void enumProfiles();
|
||||
};
|
||||
|
||||
class IntelPerCStreamImage
|
||||
: public IntelPerCStreamBase
|
||||
{
|
||||
public:
|
||||
IntelPerCStreamImage();
|
||||
virtual ~IntelPerCStreamImage();
|
||||
|
||||
virtual bool initStream(PXCSession *session);
|
||||
virtual double getProperty(int propIdx);
|
||||
virtual bool setProperty(int propIdx, double propVal);
|
||||
public:
|
||||
bool retrieveAsOutputArray(OutputArray image);
|
||||
};
|
||||
|
||||
class IntelPerCStreamDepth
|
||||
: public IntelPerCStreamBase
|
||||
{
|
||||
public:
|
||||
IntelPerCStreamDepth();
|
||||
virtual ~IntelPerCStreamDepth();
|
||||
|
||||
virtual bool initStream(PXCSession *session);
|
||||
virtual double getProperty(int propIdx);
|
||||
virtual bool setProperty(int propIdx, double propVal);
|
||||
public:
|
||||
bool retrieveDepthAsOutputArray(OutputArray image);
|
||||
bool retrieveIRAsOutputArray(OutputArray image);
|
||||
bool retrieveUVAsOutputArray(OutputArray image);
|
||||
protected:
|
||||
virtual bool validProfile(const PXCCapture::VideoStream::ProfileInfo& pinfo);
|
||||
protected:
|
||||
bool retriveFrame(int type, int planeIdx, OutputArray frame);
|
||||
};
|
||||
|
||||
class VideoCapture_IntelPerC : public IVideoCapture
|
||||
{
|
||||
public:
|
||||
VideoCapture_IntelPerC();
|
||||
virtual ~VideoCapture_IntelPerC();
|
||||
|
||||
virtual double getProperty(int propIdx);
|
||||
virtual bool setProperty(int propIdx, double propVal);
|
||||
|
||||
virtual bool grabFrame();
|
||||
virtual bool retrieveFrame(int outputType, OutputArray frame);
|
||||
virtual int getCaptureDomain();
|
||||
bool isOpened() const;
|
||||
protected:
|
||||
bool m_contextOpened;
|
||||
|
||||
PXCSmartPtr<PXCSession> m_session;
|
||||
IntelPerCStreamImage m_imageStream;
|
||||
IntelPerCStreamDepth m_depthStream;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //HAVE_INTELPERC
|
||||
#endif //_CAP_INTELPERC_HPP_
|
@ -136,8 +136,6 @@ CvCapture* cvCreateFileCapture_OpenNI( const char* filename );
|
||||
CvCapture* cvCreateCameraCapture_Android( int index );
|
||||
CvCapture* cvCreateCameraCapture_XIMEA( int index );
|
||||
CvCapture* cvCreateCameraCapture_AVFoundation(int index);
|
||||
CvCapture* cvCreateCameraCapture_IntelPerC(int index);
|
||||
|
||||
|
||||
CVAPI(int) cvHaveImageReader(const char* filename);
|
||||
CVAPI(int) cvHaveImageWriter(const char* filename);
|
||||
|
Loading…
x
Reference in New Issue
Block a user