Merge pull request #502 from jet47:opengl-updates
This commit is contained in:
@@ -90,10 +90,18 @@ class Mat;
|
||||
class SparseMat;
|
||||
typedef Mat MatND;
|
||||
|
||||
namespace ogl {
|
||||
class Buffer;
|
||||
class Texture2D;
|
||||
class Arrays;
|
||||
}
|
||||
|
||||
// < Deprecated
|
||||
class GlBuffer;
|
||||
class GlTexture;
|
||||
class GlArrays;
|
||||
class GlCamera;
|
||||
// >
|
||||
|
||||
namespace gpu {
|
||||
class GpuMat;
|
||||
@@ -1327,15 +1335,23 @@ public:
|
||||
template<typename _Tp, int m, int n> _InputArray(const Matx<_Tp, m, n>& matx);
|
||||
_InputArray(const Scalar& s);
|
||||
_InputArray(const double& val);
|
||||
// < Deprecated
|
||||
_InputArray(const GlBuffer& buf);
|
||||
_InputArray(const GlTexture& tex);
|
||||
// >
|
||||
_InputArray(const gpu::GpuMat& d_mat);
|
||||
_InputArray(const ogl::Buffer& buf);
|
||||
_InputArray(const ogl::Texture2D& tex);
|
||||
|
||||
virtual Mat getMat(int i=-1) const;
|
||||
virtual void getMatVector(vector<Mat>& mv) const;
|
||||
// < Deprecated
|
||||
virtual GlBuffer getGlBuffer() const;
|
||||
virtual GlTexture getGlTexture() const;
|
||||
// >
|
||||
virtual gpu::GpuMat getGpuMat() const;
|
||||
/*virtual*/ ogl::Buffer getOGlBuffer() const;
|
||||
/*virtual*/ ogl::Texture2D getOGlTexture2D() const;
|
||||
|
||||
virtual int kind() const;
|
||||
virtual Size size(int i=-1) const;
|
||||
@@ -1387,6 +1403,8 @@ public:
|
||||
template<typename _Tp, int m, int n> _OutputArray(Matx<_Tp, m, n>& matx);
|
||||
template<typename _Tp> _OutputArray(_Tp* vec, int n);
|
||||
_OutputArray(gpu::GpuMat& d_mat);
|
||||
_OutputArray(ogl::Buffer& buf);
|
||||
_OutputArray(ogl::Texture2D& tex);
|
||||
|
||||
_OutputArray(const Mat& m);
|
||||
template<typename _Tp> _OutputArray(const vector<_Tp>& vec);
|
||||
@@ -1397,12 +1415,16 @@ public:
|
||||
template<typename _Tp, int m, int n> _OutputArray(const Matx<_Tp, m, n>& matx);
|
||||
template<typename _Tp> _OutputArray(const _Tp* vec, int n);
|
||||
_OutputArray(const gpu::GpuMat& d_mat);
|
||||
_OutputArray(const ogl::Buffer& buf);
|
||||
_OutputArray(const ogl::Texture2D& tex);
|
||||
|
||||
virtual bool fixedSize() const;
|
||||
virtual bool fixedType() const;
|
||||
virtual bool needed() const;
|
||||
virtual Mat& getMatRef(int i=-1) const;
|
||||
/*virtual*/ gpu::GpuMat& getGpuMatRef() const;
|
||||
/*virtual*/ ogl::Buffer& getOGlBufferRef() const;
|
||||
/*virtual*/ ogl::Texture2D& getOGlTexture2DRef() const;
|
||||
virtual void create(Size sz, int type, int i=-1, bool allowTransposed=false, int fixedDepthMask=0) const;
|
||||
virtual void create(int rows, int cols, int type, int i=-1, bool allowTransposed=false, int fixedDepthMask=0) const;
|
||||
virtual void create(int dims, const int* size, int type, int i=-1, bool allowTransposed=false, int fixedDepthMask=0) const;
|
||||
|
@@ -751,7 +751,9 @@ typedef struct CvBigFuncTable
|
||||
(tab).fn_2d[CV_64F] = (void*)FUNCNAME##_64f##FLAG
|
||||
|
||||
#ifdef __cplusplus
|
||||
//! OpenGL extension table
|
||||
|
||||
// < Deprecated
|
||||
|
||||
class CV_EXPORTS CvOpenGlFuncTab
|
||||
{
|
||||
public:
|
||||
@@ -777,10 +779,16 @@ CV_EXPORTS void icvSetOpenGlFuncTab(const CvOpenGlFuncTab* tab);
|
||||
|
||||
CV_EXPORTS bool icvCheckGlError(const char* file, const int line, const char* func = "");
|
||||
|
||||
// >
|
||||
|
||||
namespace cv { namespace ogl {
|
||||
CV_EXPORTS bool checkError(const char* file, const int line, const char* func = "");
|
||||
}}
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define CV_CheckGlError() CV_DbgAssert( (::icvCheckGlError(__FILE__, __LINE__, __func__)) )
|
||||
#define CV_CheckGlError() CV_DbgAssert( (cv::ogl::checkError(__FILE__, __LINE__, __func__)) )
|
||||
#else
|
||||
#define CV_CheckGlError() CV_DbgAssert( (::icvCheckGlError(__FILE__, __LINE__)) )
|
||||
#define CV_CheckGlError() CV_DbgAssert( (cv::ogl::checkError(__FILE__, __LINE__)) )
|
||||
#endif
|
||||
|
||||
#endif //__cplusplus
|
||||
|
@@ -46,289 +46,238 @@
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/core/opengl_interop_deprecated.hpp"
|
||||
|
||||
namespace cv { namespace ogl {
|
||||
|
||||
/////////////////// OpenGL Objects ///////////////////
|
||||
|
||||
namespace cv
|
||||
{
|
||||
//! Smart pointer for OpenGL buffer memory with reference counting.
|
||||
class CV_EXPORTS GlBuffer
|
||||
class CV_EXPORTS Buffer
|
||||
{
|
||||
public:
|
||||
enum Usage
|
||||
enum Target
|
||||
{
|
||||
ARRAY_BUFFER = 0x8892, // buffer will use for OpenGL arrays (vertices, colors, normals, etc)
|
||||
TEXTURE_BUFFER = 0x88EC // buffer will ise for OpenGL textures
|
||||
ARRAY_BUFFER = 0x8892, //!< The buffer will be used as a source for vertex data
|
||||
ELEMENT_ARRAY_BUFFER = 0x8893, //!< The buffer will be used for indices (in glDrawElements, for example)
|
||||
PIXEL_PACK_BUFFER = 0x88EB, //!< The buffer will be used for reading from OpenGL textures
|
||||
PIXEL_UNPACK_BUFFER = 0x88EC //!< The buffer will be used for writing to OpenGL textures
|
||||
};
|
||||
|
||||
enum Access
|
||||
{
|
||||
READ_ONLY = 0x88B8,
|
||||
WRITE_ONLY = 0x88B9,
|
||||
READ_WRITE = 0x88BA
|
||||
};
|
||||
|
||||
//! create empty buffer
|
||||
explicit GlBuffer(Usage usage);
|
||||
Buffer();
|
||||
|
||||
//! create buffer from existed buffer id
|
||||
Buffer(int arows, int acols, int atype, unsigned int abufId, bool autoRelease = false);
|
||||
Buffer(Size asize, int atype, unsigned int abufId, bool autoRelease = false);
|
||||
|
||||
//! create buffer
|
||||
GlBuffer(int rows, int cols, int type, Usage usage);
|
||||
GlBuffer(Size size, int type, Usage usage);
|
||||
Buffer(int arows, int acols, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false);
|
||||
Buffer(Size asize, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false);
|
||||
|
||||
//! copy from host/device memory
|
||||
GlBuffer(InputArray mat, Usage usage);
|
||||
explicit Buffer(InputArray arr, Target target = ARRAY_BUFFER, bool autoRelease = false);
|
||||
|
||||
void create(int rows, int cols, int type, Usage usage);
|
||||
void create(Size size, int type, Usage usage);
|
||||
void create(int rows, int cols, int type);
|
||||
void create(Size size, int type);
|
||||
//! create buffer
|
||||
void create(int arows, int acols, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false);
|
||||
void create(Size asize, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false) { create(asize.height, asize.width, atype, target, autoRelease); }
|
||||
|
||||
//! release memory and delete buffer object
|
||||
void release();
|
||||
|
||||
//! copy from host/device memory
|
||||
void copyFrom(InputArray mat);
|
||||
//! set auto release mode (if true, release will be called in object's destructor)
|
||||
void setAutoRelease(bool flag);
|
||||
|
||||
void bind() const;
|
||||
void unbind() const;
|
||||
//! copy from host/device memory
|
||||
void copyFrom(InputArray arr, Target target = ARRAY_BUFFER, bool autoRelease = false);
|
||||
|
||||
//! copy to host/device memory
|
||||
void copyTo(OutputArray arr, Target target = ARRAY_BUFFER, bool autoRelease = false) const;
|
||||
|
||||
//! create copy of current buffer
|
||||
Buffer clone(Target target = ARRAY_BUFFER, bool autoRelease = false) const;
|
||||
|
||||
//! bind buffer for specified target
|
||||
void bind(Target target) const;
|
||||
|
||||
//! unbind any buffers from specified target
|
||||
static void unbind(Target target);
|
||||
|
||||
//! map to host memory
|
||||
Mat mapHost();
|
||||
Mat mapHost(Access access);
|
||||
void unmapHost();
|
||||
|
||||
//! map to device memory
|
||||
gpu::GpuMat mapDevice();
|
||||
void unmapDevice();
|
||||
|
||||
inline int rows() const { return rows_; }
|
||||
inline int cols() const { return cols_; }
|
||||
inline Size size() const { return Size(cols_, rows_); }
|
||||
inline bool empty() const { return rows_ == 0 || cols_ == 0; }
|
||||
int rows() const { return rows_; }
|
||||
int cols() const { return cols_; }
|
||||
Size size() const { return Size(cols_, rows_); }
|
||||
bool empty() const { return rows_ == 0 || cols_ == 0; }
|
||||
|
||||
inline int type() const { return type_; }
|
||||
inline int depth() const { return CV_MAT_DEPTH(type_); }
|
||||
inline int channels() const { return CV_MAT_CN(type_); }
|
||||
inline int elemSize() const { return CV_ELEM_SIZE(type_); }
|
||||
inline int elemSize1() const { return CV_ELEM_SIZE1(type_); }
|
||||
int type() const { return type_; }
|
||||
int depth() const { return CV_MAT_DEPTH(type_); }
|
||||
int channels() const { return CV_MAT_CN(type_); }
|
||||
int elemSize() const { return CV_ELEM_SIZE(type_); }
|
||||
int elemSize1() const { return CV_ELEM_SIZE1(type_); }
|
||||
|
||||
inline Usage usage() const { return usage_; }
|
||||
unsigned int bufId() const;
|
||||
|
||||
class Impl;
|
||||
|
||||
private:
|
||||
Ptr<Impl> impl_;
|
||||
int rows_;
|
||||
int cols_;
|
||||
int type_;
|
||||
Usage usage_;
|
||||
|
||||
Ptr<Impl> impl_;
|
||||
};
|
||||
|
||||
template <> CV_EXPORTS void Ptr<GlBuffer::Impl>::delete_obj();
|
||||
|
||||
//! Smart pointer for OpenGL 2d texture memory with reference counting.
|
||||
class CV_EXPORTS GlTexture
|
||||
//! Smart pointer for OpenGL 2D texture memory with reference counting.
|
||||
class CV_EXPORTS Texture2D
|
||||
{
|
||||
public:
|
||||
enum Format
|
||||
{
|
||||
NONE = 0,
|
||||
DEPTH_COMPONENT = 0x1902, //!< Depth
|
||||
RGB = 0x1907, //!< Red, Green, Blue
|
||||
RGBA = 0x1908 //!< Red, Green, Blue, Alpha
|
||||
};
|
||||
|
||||
//! create empty texture
|
||||
GlTexture();
|
||||
Texture2D();
|
||||
|
||||
//! create texture from existed texture id
|
||||
Texture2D(int arows, int acols, Format aformat, unsigned int atexId, bool autoRelease = false);
|
||||
Texture2D(Size asize, Format aformat, unsigned int atexId, bool autoRelease = false);
|
||||
|
||||
//! create texture
|
||||
GlTexture(int rows, int cols, int type);
|
||||
GlTexture(Size size, int type);
|
||||
Texture2D(int arows, int acols, Format aformat, bool autoRelease = false);
|
||||
Texture2D(Size asize, Format aformat, bool autoRelease = false);
|
||||
|
||||
//! copy from host/device memory
|
||||
explicit GlTexture(InputArray mat, bool bgra = true);
|
||||
explicit Texture2D(InputArray arr, bool autoRelease = false);
|
||||
|
||||
void create(int rows, int cols, int type);
|
||||
void create(Size size, int type);
|
||||
//! create texture
|
||||
void create(int arows, int acols, Format aformat, bool autoRelease = false);
|
||||
void create(Size asize, Format aformat, bool autoRelease = false) { create(asize.height, asize.width, aformat, autoRelease); }
|
||||
|
||||
//! release memory and delete texture object
|
||||
void release();
|
||||
|
||||
//! set auto release mode (if true, release will be called in object's destructor)
|
||||
void setAutoRelease(bool flag);
|
||||
|
||||
//! copy from host/device memory
|
||||
void copyFrom(InputArray mat, bool bgra = true);
|
||||
void copyFrom(InputArray arr, bool autoRelease = false);
|
||||
|
||||
//! copy to host/device memory
|
||||
void copyTo(OutputArray arr, int ddepth = CV_32F, bool autoRelease = false) const;
|
||||
|
||||
//! bind texture to current active texture unit for GL_TEXTURE_2D target
|
||||
void bind() const;
|
||||
void unbind() const;
|
||||
|
||||
inline int rows() const { return rows_; }
|
||||
inline int cols() const { return cols_; }
|
||||
inline Size size() const { return Size(cols_, rows_); }
|
||||
inline bool empty() const { return rows_ == 0 || cols_ == 0; }
|
||||
int rows() const { return rows_; }
|
||||
int cols() const { return cols_; }
|
||||
Size size() const { return Size(cols_, rows_); }
|
||||
bool empty() const { return rows_ == 0 || cols_ == 0; }
|
||||
|
||||
inline int type() const { return type_; }
|
||||
inline int depth() const { return CV_MAT_DEPTH(type_); }
|
||||
inline int channels() const { return CV_MAT_CN(type_); }
|
||||
inline int elemSize() const { return CV_ELEM_SIZE(type_); }
|
||||
inline int elemSize1() const { return CV_ELEM_SIZE1(type_); }
|
||||
Format format() const { return format_; }
|
||||
|
||||
unsigned int texId() const;
|
||||
|
||||
class Impl;
|
||||
|
||||
private:
|
||||
Ptr<Impl> impl_;
|
||||
int rows_;
|
||||
int cols_;
|
||||
int type_;
|
||||
|
||||
Ptr<Impl> impl_;
|
||||
GlBuffer buf_;
|
||||
Format format_;
|
||||
};
|
||||
|
||||
template <> CV_EXPORTS void Ptr<GlTexture::Impl>::delete_obj();
|
||||
|
||||
//! OpenGL Arrays
|
||||
class CV_EXPORTS GlArrays
|
||||
class CV_EXPORTS Arrays
|
||||
{
|
||||
public:
|
||||
inline GlArrays()
|
||||
: vertex_(GlBuffer::ARRAY_BUFFER), color_(GlBuffer::ARRAY_BUFFER), bgra_(true), normal_(GlBuffer::ARRAY_BUFFER), texCoord_(GlBuffer::ARRAY_BUFFER)
|
||||
{
|
||||
}
|
||||
Arrays();
|
||||
|
||||
void setVertexArray(InputArray vertex);
|
||||
inline void resetVertexArray() { vertex_.release(); }
|
||||
void resetVertexArray();
|
||||
|
||||
void setColorArray(InputArray color, bool bgra = true);
|
||||
inline void resetColorArray() { color_.release(); }
|
||||
void setColorArray(InputArray color);
|
||||
void resetColorArray();
|
||||
|
||||
void setNormalArray(InputArray normal);
|
||||
inline void resetNormalArray() { normal_.release(); }
|
||||
void resetNormalArray();
|
||||
|
||||
void setTexCoordArray(InputArray texCoord);
|
||||
inline void resetTexCoordArray() { texCoord_.release(); }
|
||||
void resetTexCoordArray();
|
||||
|
||||
void release();
|
||||
|
||||
void setAutoRelease(bool flag);
|
||||
|
||||
void bind() const;
|
||||
void unbind() const;
|
||||
|
||||
inline int rows() const { return vertex_.rows(); }
|
||||
inline int cols() const { return vertex_.cols(); }
|
||||
inline Size size() const { return vertex_.size(); }
|
||||
inline bool empty() const { return vertex_.empty(); }
|
||||
int size() const { return size_; }
|
||||
bool empty() const { return size_ == 0; }
|
||||
|
||||
private:
|
||||
GlBuffer vertex_;
|
||||
GlBuffer color_;
|
||||
bool bgra_;
|
||||
GlBuffer normal_;
|
||||
GlBuffer texCoord_;
|
||||
int size_;
|
||||
Buffer vertex_;
|
||||
Buffer color_;
|
||||
Buffer normal_;
|
||||
Buffer texCoord_;
|
||||
};
|
||||
|
||||
//! OpenGL Font
|
||||
class CV_EXPORTS GlFont
|
||||
{
|
||||
public:
|
||||
enum Weight
|
||||
{
|
||||
WEIGHT_LIGHT = 300,
|
||||
WEIGHT_NORMAL = 400,
|
||||
WEIGHT_SEMIBOLD = 600,
|
||||
WEIGHT_BOLD = 700,
|
||||
WEIGHT_BLACK = 900
|
||||
};
|
||||
|
||||
enum Style
|
||||
{
|
||||
STYLE_NORMAL = 0,
|
||||
STYLE_ITALIC = 1,
|
||||
STYLE_UNDERLINE = 2
|
||||
};
|
||||
|
||||
static Ptr<GlFont> get(const std::string& family, int height = 12, Weight weight = WEIGHT_NORMAL, Style style = STYLE_NORMAL);
|
||||
|
||||
void draw(const char* str, int len) const;
|
||||
|
||||
inline const std::string& family() const { return family_; }
|
||||
inline int height() const { return height_; }
|
||||
inline Weight weight() const { return weight_; }
|
||||
inline Style style() const { return style_; }
|
||||
|
||||
private:
|
||||
GlFont(const std::string& family, int height, Weight weight, Style style);
|
||||
|
||||
std::string family_;
|
||||
int height_;
|
||||
Weight weight_;
|
||||
Style style_;
|
||||
|
||||
unsigned int base_;
|
||||
|
||||
GlFont(const GlFont&);
|
||||
GlFont& operator =(const GlFont&);
|
||||
};
|
||||
|
||||
//! render functions
|
||||
/////////////////// Render Functions ///////////////////
|
||||
|
||||
//! render texture rectangle in window
|
||||
CV_EXPORTS void render(const GlTexture& tex,
|
||||
CV_EXPORTS void render(const Texture2D& tex,
|
||||
Rect_<double> wndRect = Rect_<double>(0.0, 0.0, 1.0, 1.0),
|
||||
Rect_<double> texRect = Rect_<double>(0.0, 0.0, 1.0, 1.0));
|
||||
|
||||
//! render mode
|
||||
namespace RenderMode {
|
||||
enum {
|
||||
POINTS = 0x0000,
|
||||
LINES = 0x0001,
|
||||
LINE_LOOP = 0x0002,
|
||||
LINE_STRIP = 0x0003,
|
||||
TRIANGLES = 0x0004,
|
||||
TRIANGLE_STRIP = 0x0005,
|
||||
TRIANGLE_FAN = 0x0006,
|
||||
QUADS = 0x0007,
|
||||
QUAD_STRIP = 0x0008,
|
||||
POLYGON = 0x0009
|
||||
};
|
||||
}
|
||||
|
||||
//! render OpenGL arrays
|
||||
CV_EXPORTS void render(const GlArrays& arr, int mode = RenderMode::POINTS, Scalar color = Scalar::all(255));
|
||||
|
||||
CV_EXPORTS void render(const std::string& str, const Ptr<GlFont>& font, Scalar color, Point2d pos);
|
||||
|
||||
//! OpenGL camera
|
||||
class CV_EXPORTS GlCamera
|
||||
{
|
||||
public:
|
||||
GlCamera();
|
||||
|
||||
void lookAt(Point3d eye, Point3d center, Point3d up);
|
||||
void setCameraPos(Point3d pos, double yaw, double pitch, double roll);
|
||||
|
||||
void setScale(Point3d scale);
|
||||
|
||||
void setProjectionMatrix(const Mat& projectionMatrix, bool transpose = true);
|
||||
void setPerspectiveProjection(double fov, double aspect, double zNear, double zFar);
|
||||
void setOrthoProjection(double left, double right, double bottom, double top, double zNear, double zFar);
|
||||
|
||||
void setupProjectionMatrix() const;
|
||||
void setupModelViewMatrix() const;
|
||||
|
||||
private:
|
||||
Point3d eye_;
|
||||
Point3d center_;
|
||||
Point3d up_;
|
||||
|
||||
Point3d pos_;
|
||||
double yaw_;
|
||||
double pitch_;
|
||||
double roll_;
|
||||
|
||||
bool useLookAtParams_;
|
||||
|
||||
Point3d scale_;
|
||||
|
||||
Mat projectionMatrix_;
|
||||
|
||||
double fov_;
|
||||
double aspect_;
|
||||
|
||||
double left_;
|
||||
double right_;
|
||||
double bottom_;
|
||||
double top_;
|
||||
|
||||
double zNear_;
|
||||
double zFar_;
|
||||
|
||||
bool perspectiveProjection_;
|
||||
enum {
|
||||
POINTS = 0x0000,
|
||||
LINES = 0x0001,
|
||||
LINE_LOOP = 0x0002,
|
||||
LINE_STRIP = 0x0003,
|
||||
TRIANGLES = 0x0004,
|
||||
TRIANGLE_STRIP = 0x0005,
|
||||
TRIANGLE_FAN = 0x0006,
|
||||
QUADS = 0x0007,
|
||||
QUAD_STRIP = 0x0008,
|
||||
POLYGON = 0x0009
|
||||
};
|
||||
|
||||
inline void GlBuffer::create(Size _size, int _type, Usage _usage) { create(_size.height, _size.width, _type, _usage); }
|
||||
inline void GlBuffer::create(int _rows, int _cols, int _type) { create(_rows, _cols, _type, usage()); }
|
||||
inline void GlBuffer::create(Size _size, int _type) { create(_size.height, _size.width, _type, usage()); }
|
||||
inline void GlTexture::create(Size _size, int _type) { create(_size.height, _size.width, _type); }
|
||||
//! render OpenGL arrays
|
||||
CV_EXPORTS void render(const Arrays& arr, int mode = POINTS, Scalar color = Scalar::all(255));
|
||||
CV_EXPORTS void render(const Arrays& arr, InputArray indices, int mode = POINTS, Scalar color = Scalar::all(255));
|
||||
|
||||
}} // namespace cv::gl
|
||||
|
||||
namespace cv { namespace gpu {
|
||||
|
||||
//! set a CUDA device to use OpenGL interoperability
|
||||
CV_EXPORTS void setGlDevice(int device = 0);
|
||||
|
||||
}}
|
||||
|
||||
namespace cv {
|
||||
|
||||
template <> CV_EXPORTS void Ptr<cv::ogl::Buffer::Impl>::delete_obj();
|
||||
template <> CV_EXPORTS void Ptr<cv::ogl::Texture2D::Impl>::delete_obj();
|
||||
|
||||
namespace gpu
|
||||
{
|
||||
//! set a CUDA device to use OpenGL interoperability
|
||||
CV_EXPORTS void setGlDevice(int device = 0);
|
||||
}
|
||||
} // namespace cv
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
|
330
modules/core/include/opencv2/core/opengl_interop_deprecated.hpp
Normal file
330
modules/core/include/opencv2/core/opengl_interop_deprecated.hpp
Normal file
@@ -0,0 +1,330 @@
|
||||
/*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.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., 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 GpuMaterials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders 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 __OPENCV_OPENGL_INTEROP_DEPRECATED_HPP__
|
||||
#define __OPENCV_OPENGL_INTEROP_DEPRECATED_HPP__
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "opencv2/core/core.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
//! Smart pointer for OpenGL buffer memory with reference counting.
|
||||
class CV_EXPORTS GlBuffer
|
||||
{
|
||||
public:
|
||||
enum Usage
|
||||
{
|
||||
ARRAY_BUFFER = 0x8892, // buffer will use for OpenGL arrays (vertices, colors, normals, etc)
|
||||
TEXTURE_BUFFER = 0x88EC // buffer will ise for OpenGL textures
|
||||
};
|
||||
|
||||
//! create empty buffer
|
||||
explicit GlBuffer(Usage usage);
|
||||
|
||||
//! create buffer
|
||||
GlBuffer(int rows, int cols, int type, Usage usage);
|
||||
GlBuffer(Size size, int type, Usage usage);
|
||||
|
||||
//! copy from host/device memory
|
||||
GlBuffer(InputArray mat, Usage usage);
|
||||
|
||||
void create(int rows, int cols, int type, Usage usage);
|
||||
void create(Size size, int type, Usage usage);
|
||||
void create(int rows, int cols, int type);
|
||||
void create(Size size, int type);
|
||||
|
||||
void release();
|
||||
|
||||
//! copy from host/device memory
|
||||
void copyFrom(InputArray mat);
|
||||
|
||||
void bind() const;
|
||||
void unbind() const;
|
||||
|
||||
//! map to host memory
|
||||
Mat mapHost();
|
||||
void unmapHost();
|
||||
|
||||
//! map to device memory
|
||||
gpu::GpuMat mapDevice();
|
||||
void unmapDevice();
|
||||
|
||||
inline int rows() const { return rows_; }
|
||||
inline int cols() const { return cols_; }
|
||||
inline Size size() const { return Size(cols_, rows_); }
|
||||
inline bool empty() const { return rows_ == 0 || cols_ == 0; }
|
||||
|
||||
inline int type() const { return type_; }
|
||||
inline int depth() const { return CV_MAT_DEPTH(type_); }
|
||||
inline int channels() const { return CV_MAT_CN(type_); }
|
||||
inline int elemSize() const { return CV_ELEM_SIZE(type_); }
|
||||
inline int elemSize1() const { return CV_ELEM_SIZE1(type_); }
|
||||
|
||||
inline Usage usage() const { return usage_; }
|
||||
|
||||
class Impl;
|
||||
private:
|
||||
int rows_;
|
||||
int cols_;
|
||||
int type_;
|
||||
Usage usage_;
|
||||
|
||||
Ptr<Impl> impl_;
|
||||
};
|
||||
|
||||
template <> CV_EXPORTS void Ptr<GlBuffer::Impl>::delete_obj();
|
||||
|
||||
//! Smart pointer for OpenGL 2d texture memory with reference counting.
|
||||
class CV_EXPORTS GlTexture
|
||||
{
|
||||
public:
|
||||
//! create empty texture
|
||||
GlTexture();
|
||||
|
||||
//! create texture
|
||||
GlTexture(int rows, int cols, int type);
|
||||
GlTexture(Size size, int type);
|
||||
|
||||
//! copy from host/device memory
|
||||
explicit GlTexture(InputArray mat, bool bgra = true);
|
||||
|
||||
void create(int rows, int cols, int type);
|
||||
void create(Size size, int type);
|
||||
void release();
|
||||
|
||||
//! copy from host/device memory
|
||||
void copyFrom(InputArray mat, bool bgra = true);
|
||||
|
||||
void bind() const;
|
||||
void unbind() const;
|
||||
|
||||
inline int rows() const { return rows_; }
|
||||
inline int cols() const { return cols_; }
|
||||
inline Size size() const { return Size(cols_, rows_); }
|
||||
inline bool empty() const { return rows_ == 0 || cols_ == 0; }
|
||||
|
||||
inline int type() const { return type_; }
|
||||
inline int depth() const { return CV_MAT_DEPTH(type_); }
|
||||
inline int channels() const { return CV_MAT_CN(type_); }
|
||||
inline int elemSize() const { return CV_ELEM_SIZE(type_); }
|
||||
inline int elemSize1() const { return CV_ELEM_SIZE1(type_); }
|
||||
|
||||
class Impl;
|
||||
private:
|
||||
int rows_;
|
||||
int cols_;
|
||||
int type_;
|
||||
|
||||
Ptr<Impl> impl_;
|
||||
GlBuffer buf_;
|
||||
};
|
||||
|
||||
template <> CV_EXPORTS void Ptr<GlTexture::Impl>::delete_obj();
|
||||
|
||||
//! OpenGL Arrays
|
||||
class CV_EXPORTS GlArrays
|
||||
{
|
||||
public:
|
||||
inline GlArrays()
|
||||
: vertex_(GlBuffer::ARRAY_BUFFER), color_(GlBuffer::ARRAY_BUFFER), bgra_(true), normal_(GlBuffer::ARRAY_BUFFER), texCoord_(GlBuffer::ARRAY_BUFFER)
|
||||
{
|
||||
}
|
||||
|
||||
void setVertexArray(InputArray vertex);
|
||||
inline void resetVertexArray() { vertex_.release(); }
|
||||
|
||||
void setColorArray(InputArray color, bool bgra = true);
|
||||
inline void resetColorArray() { color_.release(); }
|
||||
|
||||
void setNormalArray(InputArray normal);
|
||||
inline void resetNormalArray() { normal_.release(); }
|
||||
|
||||
void setTexCoordArray(InputArray texCoord);
|
||||
inline void resetTexCoordArray() { texCoord_.release(); }
|
||||
|
||||
void bind() const;
|
||||
void unbind() const;
|
||||
|
||||
inline int rows() const { return vertex_.rows(); }
|
||||
inline int cols() const { return vertex_.cols(); }
|
||||
inline Size size() const { return vertex_.size(); }
|
||||
inline bool empty() const { return vertex_.empty(); }
|
||||
|
||||
private:
|
||||
GlBuffer vertex_;
|
||||
GlBuffer color_;
|
||||
bool bgra_;
|
||||
GlBuffer normal_;
|
||||
GlBuffer texCoord_;
|
||||
};
|
||||
|
||||
//! OpenGL Font
|
||||
class CV_EXPORTS GlFont
|
||||
{
|
||||
public:
|
||||
enum Weight
|
||||
{
|
||||
WEIGHT_LIGHT = 300,
|
||||
WEIGHT_NORMAL = 400,
|
||||
WEIGHT_SEMIBOLD = 600,
|
||||
WEIGHT_BOLD = 700,
|
||||
WEIGHT_BLACK = 900
|
||||
};
|
||||
|
||||
enum Style
|
||||
{
|
||||
STYLE_NORMAL = 0,
|
||||
STYLE_ITALIC = 1,
|
||||
STYLE_UNDERLINE = 2
|
||||
};
|
||||
|
||||
static Ptr<GlFont> get(const std::string& family, int height = 12, Weight weight = WEIGHT_NORMAL, Style style = STYLE_NORMAL);
|
||||
|
||||
void draw(const char* str, int len) const;
|
||||
|
||||
inline const std::string& family() const { return family_; }
|
||||
inline int height() const { return height_; }
|
||||
inline Weight weight() const { return weight_; }
|
||||
inline Style style() const { return style_; }
|
||||
|
||||
private:
|
||||
GlFont(const std::string& family, int height, Weight weight, Style style);
|
||||
|
||||
std::string family_;
|
||||
int height_;
|
||||
Weight weight_;
|
||||
Style style_;
|
||||
|
||||
unsigned int base_;
|
||||
|
||||
GlFont(const GlFont&);
|
||||
GlFont& operator =(const GlFont&);
|
||||
};
|
||||
|
||||
//! render functions
|
||||
|
||||
//! render texture rectangle in window
|
||||
CV_EXPORTS void render(const GlTexture& tex,
|
||||
Rect_<double> wndRect = Rect_<double>(0.0, 0.0, 1.0, 1.0),
|
||||
Rect_<double> texRect = Rect_<double>(0.0, 0.0, 1.0, 1.0));
|
||||
|
||||
//! render mode
|
||||
namespace RenderMode {
|
||||
enum {
|
||||
POINTS = 0x0000,
|
||||
LINES = 0x0001,
|
||||
LINE_LOOP = 0x0002,
|
||||
LINE_STRIP = 0x0003,
|
||||
TRIANGLES = 0x0004,
|
||||
TRIANGLE_STRIP = 0x0005,
|
||||
TRIANGLE_FAN = 0x0006,
|
||||
QUADS = 0x0007,
|
||||
QUAD_STRIP = 0x0008,
|
||||
POLYGON = 0x0009
|
||||
};
|
||||
}
|
||||
|
||||
//! render OpenGL arrays
|
||||
CV_EXPORTS void render(const GlArrays& arr, int mode = RenderMode::POINTS, Scalar color = Scalar::all(255));
|
||||
|
||||
CV_EXPORTS void render(const std::string& str, const Ptr<GlFont>& font, Scalar color, Point2d pos);
|
||||
|
||||
//! OpenGL camera
|
||||
class CV_EXPORTS GlCamera
|
||||
{
|
||||
public:
|
||||
GlCamera();
|
||||
|
||||
void lookAt(Point3d eye, Point3d center, Point3d up);
|
||||
void setCameraPos(Point3d pos, double yaw, double pitch, double roll);
|
||||
|
||||
void setScale(Point3d scale);
|
||||
|
||||
void setProjectionMatrix(const Mat& projectionMatrix, bool transpose = true);
|
||||
void setPerspectiveProjection(double fov, double aspect, double zNear, double zFar);
|
||||
void setOrthoProjection(double left, double right, double bottom, double top, double zNear, double zFar);
|
||||
|
||||
void setupProjectionMatrix() const;
|
||||
void setupModelViewMatrix() const;
|
||||
|
||||
private:
|
||||
Point3d eye_;
|
||||
Point3d center_;
|
||||
Point3d up_;
|
||||
|
||||
Point3d pos_;
|
||||
double yaw_;
|
||||
double pitch_;
|
||||
double roll_;
|
||||
|
||||
bool useLookAtParams_;
|
||||
|
||||
Point3d scale_;
|
||||
|
||||
Mat projectionMatrix_;
|
||||
|
||||
double fov_;
|
||||
double aspect_;
|
||||
|
||||
double left_;
|
||||
double right_;
|
||||
double bottom_;
|
||||
double top_;
|
||||
|
||||
double zNear_;
|
||||
double zFar_;
|
||||
|
||||
bool perspectiveProjection_;
|
||||
};
|
||||
|
||||
inline void GlBuffer::create(Size _size, int _type, Usage _usage) { create(_size.height, _size.width, _type, _usage); }
|
||||
inline void GlBuffer::create(int _rows, int _cols, int _type) { create(_rows, _cols, _type, usage()); }
|
||||
inline void GlBuffer::create(Size _size, int _type) { create(_size.height, _size.width, _type, usage()); }
|
||||
inline void GlTexture::create(Size _size, int _type) { create(_size.height, _size.width, _type); }
|
||||
|
||||
} // namespace cv
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __OPENCV_OPENGL_INTEROP_DEPRECATED_HPP__
|
2718
modules/core/src/gl_core_3_1.cpp
Normal file
2718
modules/core/src/gl_core_3_1.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1331
modules/core/src/gl_core_3_1.hpp
Normal file
1331
modules/core/src/gl_core_3_1.hpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -43,6 +43,7 @@
|
||||
#include "precomp.hpp"
|
||||
#include "opencv2/core/gpumat.hpp"
|
||||
#include "opencv2/core/opengl_interop.hpp"
|
||||
#include "opencv2/core/opengl_interop_deprecated.hpp"
|
||||
|
||||
/****************************************************************************************\
|
||||
* [scaled] Identity matrix initialization *
|
||||
@@ -925,9 +926,13 @@ _InputArray::_InputArray(const Mat& m) : flags(MAT), obj((void*)&m) {}
|
||||
_InputArray::_InputArray(const vector<Mat>& vec) : flags(STD_VECTOR_MAT), obj((void*)&vec) {}
|
||||
_InputArray::_InputArray(const double& val) : flags(FIXED_TYPE + FIXED_SIZE + MATX + CV_64F), obj((void*)&val), sz(Size(1,1)) {}
|
||||
_InputArray::_InputArray(const MatExpr& expr) : flags(FIXED_TYPE + FIXED_SIZE + EXPR), obj((void*)&expr) {}
|
||||
_InputArray::_InputArray(const GlBuffer& buf) : flags(FIXED_TYPE + FIXED_SIZE + OPENGL_BUFFER), obj((void*)&buf) {}
|
||||
_InputArray::_InputArray(const GlTexture& tex) : flags(FIXED_TYPE + FIXED_SIZE + OPENGL_TEXTURE), obj((void*)&tex) {}
|
||||
// < Deprecated
|
||||
_InputArray::_InputArray(const GlBuffer&) : flags(0), obj(0) {}
|
||||
_InputArray::_InputArray(const GlTexture&) : flags(0), obj(0) {}
|
||||
// >
|
||||
_InputArray::_InputArray(const gpu::GpuMat& d_mat) : flags(GPU_MAT), obj((void*)&d_mat) {}
|
||||
_InputArray::_InputArray(const ogl::Buffer& buf) : flags(OPENGL_BUFFER), obj((void*)&buf) {}
|
||||
_InputArray::_InputArray(const ogl::Texture2D& tex) : flags(OPENGL_TEXTURE), obj((void*)&tex) {}
|
||||
|
||||
Mat _InputArray::getMat(int i) const
|
||||
{
|
||||
@@ -1069,26 +1074,14 @@ void _InputArray::getMatVector(vector<Mat>& mv) const
|
||||
|
||||
GlBuffer _InputArray::getGlBuffer() const
|
||||
{
|
||||
int k = kind();
|
||||
|
||||
CV_Assert(k == OPENGL_BUFFER);
|
||||
//if( k == OPENGL_BUFFER )
|
||||
{
|
||||
const GlBuffer* buf = (const GlBuffer*)obj;
|
||||
return *buf;
|
||||
}
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
return GlBuffer(GlBuffer::ARRAY_BUFFER);
|
||||
}
|
||||
|
||||
GlTexture _InputArray::getGlTexture() const
|
||||
{
|
||||
int k = kind();
|
||||
|
||||
CV_Assert(k == OPENGL_TEXTURE);
|
||||
//if( k == OPENGL_TEXTURE )
|
||||
{
|
||||
const GlTexture* tex = (const GlTexture*)obj;
|
||||
return *tex;
|
||||
}
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
return GlTexture();
|
||||
}
|
||||
|
||||
gpu::GpuMat _InputArray::getGpuMat() const
|
||||
@@ -1096,11 +1089,29 @@ gpu::GpuMat _InputArray::getGpuMat() const
|
||||
int k = kind();
|
||||
|
||||
CV_Assert(k == GPU_MAT);
|
||||
//if( k == GPU_MAT )
|
||||
{
|
||||
const gpu::GpuMat* d_mat = (const gpu::GpuMat*)obj;
|
||||
return *d_mat;
|
||||
}
|
||||
|
||||
const gpu::GpuMat* d_mat = (const gpu::GpuMat*)obj;
|
||||
return *d_mat;
|
||||
}
|
||||
|
||||
ogl::Buffer _InputArray::getOGlBuffer() const
|
||||
{
|
||||
int k = kind();
|
||||
|
||||
CV_Assert(k == OPENGL_BUFFER);
|
||||
|
||||
const ogl::Buffer* gl_buf = (const ogl::Buffer*)obj;
|
||||
return *gl_buf;
|
||||
}
|
||||
|
||||
ogl::Texture2D _InputArray::getOGlTexture2D() const
|
||||
{
|
||||
int k = kind();
|
||||
|
||||
CV_Assert(k == OPENGL_TEXTURE);
|
||||
|
||||
const ogl::Texture2D* gl_tex = (const ogl::Texture2D*)obj;
|
||||
return *gl_tex;
|
||||
}
|
||||
|
||||
int _InputArray::kind() const
|
||||
@@ -1167,14 +1178,14 @@ Size _InputArray::size(int i) const
|
||||
if( k == OPENGL_BUFFER )
|
||||
{
|
||||
CV_Assert( i < 0 );
|
||||
const GlBuffer* buf = (const GlBuffer*)obj;
|
||||
const ogl::Buffer* buf = (const ogl::Buffer*)obj;
|
||||
return buf->size();
|
||||
}
|
||||
|
||||
if( k == OPENGL_TEXTURE )
|
||||
{
|
||||
CV_Assert( i < 0 );
|
||||
const GlTexture* tex = (const GlTexture*)obj;
|
||||
const ogl::Texture2D* tex = (const ogl::Texture2D*)obj;
|
||||
return tex->size();
|
||||
}
|
||||
|
||||
@@ -1235,10 +1246,7 @@ int _InputArray::type(int i) const
|
||||
}
|
||||
|
||||
if( k == OPENGL_BUFFER )
|
||||
return ((const GlBuffer*)obj)->type();
|
||||
|
||||
if( k == OPENGL_TEXTURE )
|
||||
return ((const GlTexture*)obj)->type();
|
||||
return ((const ogl::Buffer*)obj)->type();
|
||||
|
||||
CV_Assert( k == GPU_MAT );
|
||||
//if( k == GPU_MAT )
|
||||
@@ -1290,10 +1298,10 @@ bool _InputArray::empty() const
|
||||
}
|
||||
|
||||
if( k == OPENGL_BUFFER )
|
||||
return ((const GlBuffer*)obj)->empty();
|
||||
return ((const ogl::Buffer*)obj)->empty();
|
||||
|
||||
if( k == OPENGL_TEXTURE )
|
||||
return ((const GlTexture*)obj)->empty();
|
||||
return ((const ogl::Texture2D*)obj)->empty();
|
||||
|
||||
CV_Assert( k == GPU_MAT );
|
||||
//if( k == GPU_MAT )
|
||||
@@ -1308,10 +1316,14 @@ _OutputArray::~_OutputArray() {}
|
||||
_OutputArray::_OutputArray(Mat& m) : _InputArray(m) {}
|
||||
_OutputArray::_OutputArray(vector<Mat>& vec) : _InputArray(vec) {}
|
||||
_OutputArray::_OutputArray(gpu::GpuMat& d_mat) : _InputArray(d_mat) {}
|
||||
_OutputArray::_OutputArray(ogl::Buffer& buf) : _InputArray(buf) {}
|
||||
_OutputArray::_OutputArray(ogl::Texture2D& tex) : _InputArray(tex) {}
|
||||
|
||||
_OutputArray::_OutputArray(const Mat& m) : _InputArray(m) {flags |= FIXED_SIZE|FIXED_TYPE;}
|
||||
_OutputArray::_OutputArray(const vector<Mat>& vec) : _InputArray(vec) {flags |= FIXED_SIZE;}
|
||||
_OutputArray::_OutputArray(const gpu::GpuMat& d_mat) : _InputArray(d_mat) {flags |= FIXED_SIZE|FIXED_TYPE;}
|
||||
_OutputArray::_OutputArray(const ogl::Buffer& buf) : _InputArray(buf) {flags |= FIXED_SIZE|FIXED_TYPE;}
|
||||
_OutputArray::_OutputArray(const ogl::Texture2D& tex) : _InputArray(tex) {flags |= FIXED_SIZE|FIXED_TYPE;}
|
||||
|
||||
|
||||
bool _OutputArray::fixedSize() const
|
||||
@@ -1341,6 +1353,13 @@ void _OutputArray::create(Size _sz, int mtype, int i, bool allowTransposed, int
|
||||
((gpu::GpuMat*)obj)->create(_sz, mtype);
|
||||
return;
|
||||
}
|
||||
if( k == OPENGL_BUFFER && i < 0 && !allowTransposed && fixedDepthMask == 0 )
|
||||
{
|
||||
CV_Assert(!fixedSize() || ((ogl::Buffer*)obj)->size() == _sz);
|
||||
CV_Assert(!fixedType() || ((ogl::Buffer*)obj)->type() == mtype);
|
||||
((ogl::Buffer*)obj)->create(_sz, mtype);
|
||||
return;
|
||||
}
|
||||
int sizes[] = {_sz.height, _sz.width};
|
||||
create(2, sizes, mtype, i, allowTransposed, fixedDepthMask);
|
||||
}
|
||||
@@ -1362,6 +1381,13 @@ void _OutputArray::create(int rows, int cols, int mtype, int i, bool allowTransp
|
||||
((gpu::GpuMat*)obj)->create(rows, cols, mtype);
|
||||
return;
|
||||
}
|
||||
if( k == OPENGL_BUFFER && i < 0 && !allowTransposed && fixedDepthMask == 0 )
|
||||
{
|
||||
CV_Assert(!fixedSize() || ((ogl::Buffer*)obj)->size() == Size(cols, rows));
|
||||
CV_Assert(!fixedType() || ((ogl::Buffer*)obj)->type() == mtype);
|
||||
((ogl::Buffer*)obj)->create(rows, cols, mtype);
|
||||
return;
|
||||
}
|
||||
int sizes[] = {rows, cols};
|
||||
create(2, sizes, mtype, i, allowTransposed, fixedDepthMask);
|
||||
}
|
||||
@@ -1581,6 +1607,18 @@ void _OutputArray::release() const
|
||||
return;
|
||||
}
|
||||
|
||||
if( k == OPENGL_BUFFER )
|
||||
{
|
||||
((ogl::Buffer*)obj)->release();
|
||||
return;
|
||||
}
|
||||
|
||||
if( k == OPENGL_TEXTURE )
|
||||
{
|
||||
((ogl::Texture2D*)obj)->release();
|
||||
return;
|
||||
}
|
||||
|
||||
if( k == NONE )
|
||||
return;
|
||||
|
||||
@@ -1646,6 +1684,20 @@ gpu::GpuMat& _OutputArray::getGpuMatRef() const
|
||||
return *(gpu::GpuMat*)obj;
|
||||
}
|
||||
|
||||
ogl::Buffer& _OutputArray::getOGlBufferRef() const
|
||||
{
|
||||
int k = kind();
|
||||
CV_Assert( k == OPENGL_BUFFER );
|
||||
return *(ogl::Buffer*)obj;
|
||||
}
|
||||
|
||||
ogl::Texture2D& _OutputArray::getOGlTexture2DRef() const
|
||||
{
|
||||
int k = kind();
|
||||
CV_Assert( k == OPENGL_TEXTURE );
|
||||
return *(ogl::Texture2D*)obj;
|
||||
}
|
||||
|
||||
static _OutputArray _none;
|
||||
OutputArray noArray() { return _none; }
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
331
modules/core/src/opengl_interop_deprecated.cpp
Normal file
331
modules/core/src/opengl_interop_deprecated.cpp
Normal file
@@ -0,0 +1,331 @@
|
||||
/*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.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., 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 the copyright holders 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*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "opencv2/core/opengl_interop_deprecated.hpp"
|
||||
#include "opencv2/core/gpumat.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
using namespace cv::gpu;
|
||||
|
||||
CvOpenGlFuncTab::~CvOpenGlFuncTab()
|
||||
{
|
||||
}
|
||||
|
||||
void icvSetOpenGlFuncTab(const CvOpenGlFuncTab*)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// GlBuffer
|
||||
|
||||
class cv::GlBuffer::Impl
|
||||
{
|
||||
};
|
||||
|
||||
cv::GlBuffer::GlBuffer(Usage _usage) : rows_(0), cols_(0), type_(0), usage_(_usage)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
cv::GlBuffer::GlBuffer(int, int, int, Usage _usage) : rows_(0), cols_(0), type_(0), usage_(_usage)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
cv::GlBuffer::GlBuffer(Size, int, Usage _usage) : rows_(0), cols_(0), type_(0), usage_(_usage)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
cv::GlBuffer::GlBuffer(InputArray, Usage _usage) : rows_(0), cols_(0), type_(0), usage_(_usage)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlBuffer::create(int, int, int, Usage)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlBuffer::release()
|
||||
{
|
||||
}
|
||||
|
||||
void cv::GlBuffer::copyFrom(InputArray)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlBuffer::bind() const
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlBuffer::unbind() const
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
Mat cv::GlBuffer::mapHost()
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
return Mat();
|
||||
}
|
||||
|
||||
void cv::GlBuffer::unmapHost()
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
GpuMat cv::GlBuffer::mapDevice()
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
return GpuMat();
|
||||
}
|
||||
|
||||
void cv::GlBuffer::unmapDevice()
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
template <> void cv::Ptr<cv::GlBuffer::Impl>::delete_obj()
|
||||
{
|
||||
if (obj) delete obj;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// GlTexture
|
||||
|
||||
class cv::GlTexture::Impl
|
||||
{
|
||||
};
|
||||
|
||||
cv::GlTexture::GlTexture() : rows_(0), cols_(0), type_(0), buf_(GlBuffer::TEXTURE_BUFFER)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
cv::GlTexture::GlTexture(int, int, int) : rows_(0), cols_(0), type_(0), buf_(GlBuffer::TEXTURE_BUFFER)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
cv::GlTexture::GlTexture(Size, int) : rows_(0), cols_(0), type_(0), buf_(GlBuffer::TEXTURE_BUFFER)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
cv::GlTexture::GlTexture(InputArray, bool) : rows_(0), cols_(0), type_(0), buf_(GlBuffer::TEXTURE_BUFFER)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlTexture::create(int, int, int)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlTexture::release()
|
||||
{
|
||||
}
|
||||
|
||||
void cv::GlTexture::copyFrom(InputArray, bool)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlTexture::bind() const
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlTexture::unbind() const
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
template <> void cv::Ptr<cv::GlTexture::Impl>::delete_obj()
|
||||
{
|
||||
if (obj) delete obj;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// GlArrays
|
||||
|
||||
void cv::GlArrays::setVertexArray(InputArray)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlArrays::setColorArray(InputArray, bool)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlArrays::setNormalArray(InputArray)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlArrays::setTexCoordArray(InputArray)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlArrays::bind() const
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlArrays::unbind() const
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// GlFont
|
||||
|
||||
cv::GlFont::GlFont(const string& _family, int _height, Weight _weight, Style _style)
|
||||
: family_(_family), height_(_height), weight_(_weight), style_(_style), base_(0)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlFont::draw(const char*, int) const
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
Ptr<GlFont> cv::GlFont::get(const std::string&, int, Weight, Style)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
return Ptr<GlFont>();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Rendering
|
||||
|
||||
void cv::render(const GlTexture&, Rect_<double>, Rect_<double>)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::render(const GlArrays&, int, Scalar)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::render(const string&, const Ptr<GlFont>&, Scalar, Point2d)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// GlCamera
|
||||
|
||||
cv::GlCamera::GlCamera() :
|
||||
eye_(0.0, 0.0, -5.0), center_(0.0, 0.0, 0.0), up_(0.0, 1.0, 0.0),
|
||||
pos_(0.0, 0.0, -5.0), yaw_(0.0), pitch_(0.0), roll_(0.0),
|
||||
useLookAtParams_(false),
|
||||
|
||||
scale_(1.0, 1.0, 1.0),
|
||||
|
||||
projectionMatrix_(),
|
||||
fov_(45.0), aspect_(0.0),
|
||||
left_(0.0), right_(1.0), bottom_(1.0), top_(0.0),
|
||||
zNear_(-1.0), zFar_(1.0),
|
||||
perspectiveProjection_(false)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlCamera::lookAt(Point3d, Point3d, Point3d)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlCamera::setCameraPos(Point3d, double, double, double)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlCamera::setScale(Point3d)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlCamera::setProjectionMatrix(const Mat&, bool)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlCamera::setPerspectiveProjection(double, double, double, double)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlCamera::setOrthoProjection(double, double, double, double, double, double)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlCamera::setupProjectionMatrix() const
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlCamera::setupModelViewMatrix() const
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Error handling
|
||||
|
||||
bool icvCheckGlError(const char*, const int, const char*)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
return false;
|
||||
}
|
Reference in New Issue
Block a user