
committed by
Andrey Kamaev

parent
6569a58518
commit
ecb2ebfba4
@@ -84,10 +84,11 @@ class Mat;
|
||||
class SparseMat;
|
||||
typedef Mat MatND;
|
||||
|
||||
class GlBuffer;
|
||||
class GlTexture2D;
|
||||
class GlArrays;
|
||||
class GlCamera;
|
||||
namespace ogl {
|
||||
class Buffer;
|
||||
class Texture2D;
|
||||
class Arrays;
|
||||
}
|
||||
|
||||
namespace gpu {
|
||||
class GpuMat;
|
||||
@@ -1303,7 +1304,7 @@ public:
|
||||
STD_VECTOR_MAT = 5 << KIND_SHIFT,
|
||||
EXPR = 6 << KIND_SHIFT,
|
||||
OPENGL_BUFFER = 7 << KIND_SHIFT,
|
||||
OPENGL_TEXTURE2D = 8 << KIND_SHIFT,
|
||||
OPENGL_TEXTURE = 8 << KIND_SHIFT,
|
||||
GPU_MAT = 9 << KIND_SHIFT
|
||||
};
|
||||
_InputArray();
|
||||
@@ -1319,15 +1320,15 @@ public:
|
||||
template<typename _Tp, int m, int n> _InputArray(const Matx<_Tp, m, n>& matx);
|
||||
_InputArray(const Scalar& s);
|
||||
_InputArray(const double& val);
|
||||
_InputArray(const GlBuffer& buf);
|
||||
_InputArray(const GlTexture2D& 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(std::vector<Mat>& mv) const;
|
||||
virtual GlBuffer getGlBuffer() const;
|
||||
virtual GlTexture2D getGlTexture2D() 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;
|
||||
@@ -1377,8 +1378,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(GlBuffer& buf);
|
||||
_OutputArray(GlTexture2D& tex);
|
||||
_OutputArray(ogl::Buffer& buf);
|
||||
_OutputArray(ogl::Texture2D& tex);
|
||||
|
||||
_OutputArray(const Mat& m);
|
||||
template<typename _Tp> _OutputArray(const std::vector<_Tp>& vec);
|
||||
@@ -1389,16 +1390,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 GlBuffer& buf);
|
||||
_OutputArray(const GlTexture2D& tex);
|
||||
_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 GlBuffer& getGlBufferRef() const;
|
||||
virtual GlTexture2D& getGlTexture2DRef() 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;
|
||||
|
@@ -143,7 +143,6 @@ namespace cv { namespace gpu
|
||||
int multi_processor_count_;
|
||||
int majorVersion_;
|
||||
int minorVersion_;
|
||||
size_t sharedMemPerBlock_;
|
||||
};
|
||||
|
||||
CV_EXPORTS void printCudaDeviceInfo(int device);
|
||||
|
@@ -750,4 +750,14 @@ typedef struct CvBigFuncTable
|
||||
(tab).fn_2d[CV_32F] = (void*)FUNCNAME##_32f##FLAG; \
|
||||
(tab).fn_2d[CV_64F] = (void*)FUNCNAME##_64f##FLAG
|
||||
|
||||
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( (cv::ogl::checkError(__FILE__, __LINE__, __func__)) )
|
||||
#else
|
||||
#define CV_CheckGlError() CV_DbgAssert( (cv::ogl::checkError(__FILE__, __LINE__)) )
|
||||
#endif
|
||||
|
||||
#endif // __OPENCV_CORE_INTERNAL_HPP__
|
||||
|
@@ -47,20 +47,12 @@
|
||||
|
||||
#include "opencv2/core/core.hpp"
|
||||
|
||||
namespace cv {
|
||||
|
||||
CV_EXPORTS bool checkGlError(const char* file, const int line, const char* func = "");
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define CV_CheckGlError() CV_DbgAssert( (cv::checkGlError(__FILE__, __LINE__, __func__)) )
|
||||
#else
|
||||
#define CV_CheckGlError() CV_DbgAssert( (cv::checkGlError(__FILE__, __LINE__)) )
|
||||
#endif
|
||||
namespace cv { namespace ogl {
|
||||
|
||||
/////////////////// OpenGL Objects ///////////////////
|
||||
|
||||
//! Smart pointer for OpenGL buffer memory with reference counting.
|
||||
class CV_EXPORTS GlBuffer
|
||||
class CV_EXPORTS Buffer
|
||||
{
|
||||
public:
|
||||
enum Target
|
||||
@@ -79,18 +71,18 @@ public:
|
||||
};
|
||||
|
||||
//! create empty buffer
|
||||
GlBuffer();
|
||||
Buffer();
|
||||
|
||||
//! create buffer from existed buffer id
|
||||
GlBuffer(int arows, int acols, int atype, unsigned int abufId, bool autoRelease = false);
|
||||
GlBuffer(Size asize, int atype, unsigned int abufId, bool autoRelease = false);
|
||||
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 arows, int acols, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false);
|
||||
GlBuffer(Size asize, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false);
|
||||
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
|
||||
explicit GlBuffer(InputArray arr, Target target = ARRAY_BUFFER, bool autoRelease = false);
|
||||
explicit Buffer(InputArray arr, Target target = ARRAY_BUFFER, bool autoRelease = false);
|
||||
|
||||
//! create buffer
|
||||
void create(int arows, int acols, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false);
|
||||
@@ -109,7 +101,7 @@ public:
|
||||
void copyTo(OutputArray arr, Target target = ARRAY_BUFFER, bool autoRelease = false) const;
|
||||
|
||||
//! create copy of current buffer
|
||||
GlBuffer clone(Target target = ARRAY_BUFFER, bool autoRelease = false) const;
|
||||
Buffer clone(Target target = ARRAY_BUFFER, bool autoRelease = false) const;
|
||||
|
||||
//! bind buffer for specified target
|
||||
void bind(Target target) const;
|
||||
@@ -147,10 +139,8 @@ private:
|
||||
int type_;
|
||||
};
|
||||
|
||||
template <> CV_EXPORTS void Ptr<GlBuffer::Impl>::delete_obj();
|
||||
|
||||
//! Smart pointer for OpenGL 2D texture memory with reference counting.
|
||||
class CV_EXPORTS GlTexture2D
|
||||
class CV_EXPORTS Texture2D
|
||||
{
|
||||
public:
|
||||
enum Format
|
||||
@@ -162,18 +152,18 @@ public:
|
||||
};
|
||||
|
||||
//! create empty texture
|
||||
GlTexture2D();
|
||||
Texture2D();
|
||||
|
||||
//! create texture from existed texture id
|
||||
GlTexture2D(int arows, int acols, Format aformat, unsigned int atexId, bool autoRelease = false);
|
||||
GlTexture2D(Size asize, Format aformat, unsigned int atexId, bool autoRelease = false);
|
||||
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
|
||||
GlTexture2D(int arows, int acols, Format aformat, bool autoRelease = false);
|
||||
GlTexture2D(Size asize, Format aformat, bool autoRelease = false);
|
||||
Texture2D(int arows, int acols, Format aformat, bool autoRelease = false);
|
||||
Texture2D(Size asize, Format aformat, bool autoRelease = false);
|
||||
|
||||
//! copy from host/device memory
|
||||
explicit GlTexture2D(InputArray arr, bool autoRelease = false);
|
||||
explicit Texture2D(InputArray arr, bool autoRelease = false);
|
||||
|
||||
//! create texture
|
||||
void create(int arows, int acols, Format aformat, bool autoRelease = false);
|
||||
@@ -212,13 +202,11 @@ private:
|
||||
Format format_;
|
||||
};
|
||||
|
||||
template <> CV_EXPORTS void Ptr<GlTexture2D::Impl>::delete_obj();
|
||||
|
||||
//! OpenGL Arrays
|
||||
class CV_EXPORTS GlArrays
|
||||
class CV_EXPORTS Arrays
|
||||
{
|
||||
public:
|
||||
GlArrays();
|
||||
Arrays();
|
||||
|
||||
void setVertexArray(InputArray vertex);
|
||||
void resetVertexArray();
|
||||
@@ -243,46 +231,53 @@ public:
|
||||
|
||||
private:
|
||||
int size_;
|
||||
GlBuffer vertex_;
|
||||
GlBuffer color_;
|
||||
GlBuffer normal_;
|
||||
GlBuffer texCoord_;
|
||||
Buffer vertex_;
|
||||
Buffer color_;
|
||||
Buffer normal_;
|
||||
Buffer texCoord_;
|
||||
};
|
||||
|
||||
/////////////////// Render Functions ///////////////////
|
||||
|
||||
//! render texture rectangle in window
|
||||
CV_EXPORTS void render(const GlTexture2D& 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
|
||||
};
|
||||
}
|
||||
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 GlArrays& arr, InputArray indices, int mode = RenderMode::POINTS, Scalar color = Scalar::all(255));
|
||||
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
|
||||
|
||||
#endif // __OPENCV_OPENGL_INTEROP_HPP__
|
||||
|
Reference in New Issue
Block a user