added GlArrays class and pointCloudShow function
This commit is contained in:
@@ -241,11 +241,15 @@ namespace cv { namespace gpu
|
||||
GlBuffer(Size size, int type, Usage usage);
|
||||
|
||||
//! copy from host/device memory
|
||||
GlBuffer(const Mat& mat, Usage usage);
|
||||
GlBuffer(InputArray mat, Usage usage);
|
||||
GlBuffer(const GpuMat& d_mat, Usage usage);
|
||||
|
||||
GlBuffer(const GlBuffer& other);
|
||||
|
||||
~GlBuffer();
|
||||
|
||||
GlBuffer& operator =(const GlBuffer& other);
|
||||
|
||||
void create(int rows, int cols, int type, Usage usage);
|
||||
inline void create(Size size, int type, Usage usage) { create(size.height, size.width, type, usage); }
|
||||
inline void create(int rows, int cols, int type) { create(rows, cols, type, usage()); }
|
||||
@@ -254,7 +258,7 @@ namespace cv { namespace gpu
|
||||
void release();
|
||||
|
||||
//! copy from host/device memory
|
||||
void copyFrom(const Mat& mat);
|
||||
void copyFrom(InputArray mat);
|
||||
void copyFrom(const GpuMat& d_mat);
|
||||
|
||||
void bind() const;
|
||||
@@ -267,11 +271,12 @@ namespace cv { namespace gpu
|
||||
//! map to device memory
|
||||
GpuMat mapDevice();
|
||||
void unmapDevice();
|
||||
|
||||
int rows;
|
||||
int cols;
|
||||
|
||||
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 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_); }
|
||||
@@ -282,8 +287,6 @@ namespace cv { namespace gpu
|
||||
inline Usage usage() const { return usage_; }
|
||||
|
||||
private:
|
||||
int rows_;
|
||||
int cols_;
|
||||
int type_;
|
||||
Usage usage_;
|
||||
|
||||
@@ -303,26 +306,31 @@ namespace cv { namespace gpu
|
||||
GlTexture(Size size, int type);
|
||||
|
||||
//! copy from host/device memory
|
||||
explicit GlTexture(const Mat& mat, bool bgra = true);
|
||||
explicit GlTexture(InputArray mat, bool bgra = true);
|
||||
explicit GlTexture(const GlBuffer& buf, bool bgra = true);
|
||||
|
||||
GlTexture(const GlTexture& other);
|
||||
|
||||
~GlTexture();
|
||||
|
||||
GlTexture& operator =(const GlTexture& other);
|
||||
|
||||
void create(int rows, int cols, int type);
|
||||
inline void create(Size size, int type) { create(size.height, size.width, type); }
|
||||
void release();
|
||||
|
||||
//! copy from host/device memory
|
||||
void copyFrom(const Mat& mat, bool bgra = true);
|
||||
void copyFrom(InputArray mat, bool bgra = true);
|
||||
void copyFrom(const GlBuffer& buf, 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; }
|
||||
int rows;
|
||||
int 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_); }
|
||||
@@ -331,22 +339,136 @@ namespace cv { namespace gpu
|
||||
inline int elemSize1() const { return CV_ELEM_SIZE1(type_); }
|
||||
|
||||
private:
|
||||
int rows_;
|
||||
int cols_;
|
||||
int type_;
|
||||
|
||||
class Impl;
|
||||
Ptr<Impl> impl_;
|
||||
};
|
||||
|
||||
//! 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(const GlBuffer& vertex);
|
||||
void setVertexArray(const GpuMat& vertex);
|
||||
void setVertexArray(InputArray vertex);
|
||||
inline void resetVertexArray() { vertex_.release(); }
|
||||
|
||||
void setColorArray(const GlBuffer& color, bool bgra = true);
|
||||
void setColorArray(const GpuMat& color, bool bgra = true);
|
||||
void setColorArray(InputArray color, bool bgra = true);
|
||||
inline void resetColorArray() { color_.release(); }
|
||||
|
||||
void setNormalArray(const GlBuffer& normal);
|
||||
void setNormalArray(const GpuMat& normal);
|
||||
void setNormalArray(InputArray normal);
|
||||
inline void resetNormalArray() { normal_.release(); }
|
||||
|
||||
void setTexCoordArray(const GlBuffer& texCoord);
|
||||
void setTexCoordArray(const GpuMat& texCoord);
|
||||
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_;
|
||||
};
|
||||
|
||||
//! render functions
|
||||
CV_EXPORTS void render(const GlTexture& tex);
|
||||
|
||||
//! 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);
|
||||
|
||||
//! 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_;
|
||||
};
|
||||
|
||||
//! OpenGL extension table
|
||||
class CV_EXPORTS GlFuncTab
|
||||
{
|
||||
public:
|
||||
virtual ~GlFuncTab() {}
|
||||
virtual ~GlFuncTab();
|
||||
|
||||
virtual void genBuffers(int n, unsigned int* buffers) const = 0;
|
||||
virtual void deleteBuffers(int n, const unsigned int* buffers) const = 0;
|
||||
|
Reference in New Issue
Block a user