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
|
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
|
class CV_EXPORTS_W VideoCapture
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -554,9 +566,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
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_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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user