Merge pull request #2397 from vbystricky:intelperc
This commit is contained in:
commit
70e22b682d
@ -530,6 +530,8 @@ enum { CAP_INTELPERC_DEPTH_MAP = 0, // Each pixel is a 16-bit integ
|
|||||||
CAP_INTELPERC_IMAGE = 3
|
CAP_INTELPERC_IMAGE = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class IVideoCapture;
|
||||||
class CV_EXPORTS_W VideoCapture
|
class CV_EXPORTS_W VideoCapture
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -554,9 +556,11 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
Ptr<CvCapture> cap;
|
Ptr<CvCapture> cap;
|
||||||
|
Ptr<IVideoCapture> icap;
|
||||||
|
private:
|
||||||
|
static Ptr<IVideoCapture> createCameraCapture(int index);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class CV_EXPORTS_W VideoWriter
|
class CV_EXPORTS_W VideoWriter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
//M*/
|
//M*/
|
||||||
|
|
||||||
#include "precomp.hpp"
|
#include "precomp.hpp"
|
||||||
|
#include "cap_intelperc.hpp"
|
||||||
|
|
||||||
#if defined _M_X64 && defined _MSC_VER && !defined CV_ICC
|
#if defined _M_X64 && defined _MSC_VER && !defined CV_ICC
|
||||||
#pragma optimize("",off)
|
#pragma optimize("",off)
|
||||||
@ -345,14 +346,6 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
|
|||||||
return capture;
|
return capture;
|
||||||
break; // CV_CAP_GIGANETIX
|
break; // CV_CAP_GIGANETIX
|
||||||
#endif
|
#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()
|
VideoCapture::~VideoCapture()
|
||||||
{
|
{
|
||||||
|
icap.release();
|
||||||
cap.release();
|
cap.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -510,24 +504,36 @@ bool VideoCapture::open(const String& filename)
|
|||||||
bool VideoCapture::open(int device)
|
bool VideoCapture::open(int device)
|
||||||
{
|
{
|
||||||
if (isOpened()) release();
|
if (isOpened()) release();
|
||||||
|
icap = createCameraCapture(device);
|
||||||
|
if (!icap.empty())
|
||||||
|
return true;
|
||||||
cap.reset(cvCreateCameraCapture(device));
|
cap.reset(cvCreateCameraCapture(device));
|
||||||
return isOpened();
|
return isOpened();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VideoCapture::isOpened() const { return !cap.empty(); }
|
bool VideoCapture::isOpened() const
|
||||||
|
{
|
||||||
|
return (!cap.empty() || !icap.empty());
|
||||||
|
}
|
||||||
|
|
||||||
void VideoCapture::release()
|
void VideoCapture::release()
|
||||||
{
|
{
|
||||||
|
icap.release();
|
||||||
cap.release();
|
cap.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VideoCapture::grab()
|
bool VideoCapture::grab()
|
||||||
{
|
{
|
||||||
|
if (!icap.empty())
|
||||||
|
return icap->grabFrame();
|
||||||
return cvGrabFrame(cap) != 0;
|
return cvGrabFrame(cap) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VideoCapture::retrieve(OutputArray image, int channel)
|
bool VideoCapture::retrieve(OutputArray image, int channel)
|
||||||
{
|
{
|
||||||
|
if (!icap.empty())
|
||||||
|
return icap->retrieveFrame(channel, image);
|
||||||
|
|
||||||
IplImage* _img = cvRetrieveFrame(cap, channel);
|
IplImage* _img = cvRetrieveFrame(cap, channel);
|
||||||
if( !_img )
|
if( !_img )
|
||||||
{
|
{
|
||||||
@ -567,14 +573,62 @@ VideoCapture& VideoCapture::operator >> (UMat& image)
|
|||||||
|
|
||||||
bool VideoCapture::set(int propId, double value)
|
bool VideoCapture::set(int propId, double value)
|
||||||
{
|
{
|
||||||
|
if (!icap.empty())
|
||||||
|
return icap->setProperty(propId, value);
|
||||||
return cvSetCaptureProperty(cap, propId, value) != 0;
|
return cvSetCaptureProperty(cap, propId, value) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
double VideoCapture::get(int propId)
|
double VideoCapture::get(int propId)
|
||||||
{
|
{
|
||||||
|
if (!icap.empty())
|
||||||
|
return icap->getProperty(propId);
|
||||||
return cvGetCaptureProperty(cap, 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()
|
VideoWriter::VideoWriter()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
115
modules/highgui/src/cap_intelperc.hpp
Normal file
115
modules/highgui/src/cap_intelperc.hpp
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// This file is part of OpenCV project.
|
||||||
|
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||||
|
// of this distribution and at http://opencv.org/license.html.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2014, Itseez, Inc., all rights reserved.
|
||||||
|
// Third party copyrights are property of their respective owners.
|
||||||
|
//
|
||||||
|
//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_Android( int index );
|
||||||
CvCapture* cvCreateCameraCapture_XIMEA( int index );
|
CvCapture* cvCreateCameraCapture_XIMEA( int index );
|
||||||
CvCapture* cvCreateCameraCapture_AVFoundation(int index);
|
CvCapture* cvCreateCameraCapture_AVFoundation(int index);
|
||||||
CvCapture* cvCreateCameraCapture_IntelPerC(int index);
|
|
||||||
|
|
||||||
|
|
||||||
CVAPI(int) cvHaveImageReader(const char* filename);
|
CVAPI(int) cvHaveImageReader(const char* filename);
|
||||||
CVAPI(int) cvHaveImageWriter(const char* filename);
|
CVAPI(int) cvHaveImageWriter(const char* filename);
|
||||||
@ -198,6 +196,20 @@ double cvGetRatioWindow_GTK(const char* name);
|
|||||||
double cvGetOpenGlProp_W32(const char* name);
|
double cvGetOpenGlProp_W32(const char* name);
|
||||||
double cvGetOpenGlProp_GTK(const char* name);
|
double cvGetOpenGlProp_GTK(const char* name);
|
||||||
|
|
||||||
|
namespace cv
|
||||||
|
{
|
||||||
|
class IVideoCapture
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~IVideoCapture() {}
|
||||||
|
virtual double getProperty(int) { return 0; }
|
||||||
|
virtual bool setProperty(int, double) { return 0; }
|
||||||
|
virtual bool grabFrame() = 0;
|
||||||
|
virtual bool retrieveFrame(int, cv::OutputArray) = 0;
|
||||||
|
virtual int getCaptureDomain() { return CAP_ANY; } // Return the type of the capture object: CAP_VFW, etc...
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
//for QT
|
//for QT
|
||||||
#if defined (HAVE_QT)
|
#if defined (HAVE_QT)
|
||||||
double cvGetModeWindow_QT(const char* name);
|
double cvGetModeWindow_QT(const char* name);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user