Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
a938534a
Commit
a938534a
authored
Feb 21, 2013
by
Vladislav Vinogradov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
restored binary compatibility
parent
e06c3ec7
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
1085 additions
and
352 deletions
+1085
-352
core.hpp
modules/core/include/opencv2/core/core.hpp
+22
-6
internal.hpp
modules/core/include/opencv2/core/internal.hpp
+31
-0
opengl_interop.hpp
modules/core/include/opencv2/core/opengl_interop.hpp
+54
-51
opengl_interop_deprecated.hpp
...s/core/include/opencv2/core/opengl_interop_deprecated.hpp
+330
-0
matrix.cpp
modules/core/src/matrix.cpp
+54
-43
opengl_interop.cpp
modules/core/src/opengl_interop.cpp
+124
-124
opengl_interop_deprecated.cpp
modules/core/src/opengl_interop_deprecated.cpp
+331
-0
test_opengl.cpp
modules/gpu/test/test_opengl.cpp
+88
-88
highgui.hpp
modules/highgui/include/opencv2/highgui/highgui.hpp
+6
-1
window.cpp
modules/highgui/src/window.cpp
+20
-10
opengl.cpp
samples/gpu/opengl.cpp
+25
-29
No files found.
modules/core/include/opencv2/core/core.hpp
View file @
a938534a
...
...
@@ -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,8 +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
(
Gl
Buffer
&
buf
);
_OutputArray
(
GlTexture
&
tex
);
_OutputArray
(
ogl
::
Buffer
&
buf
);
_OutputArray
(
ogl
::
Texture2D
&
tex
);
_OutputArray
(
const
Mat
&
m
);
template
<
typename
_Tp
>
_OutputArray
(
const
vector
<
_Tp
>&
vec
);
...
...
@@ -1399,16 +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
Gl
Buffer
&
buf
);
_OutputArray
(
const
GlTexture
&
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
&
get
GlBufferRef
()
const
;
/*virtual*/
GlTexture
&
getGlTexture
Ref
()
const
;
/*virtual*/
ogl
::
Buffer
&
getO
GlBufferRef
()
const
;
/*virtual*/
ogl
::
Texture2D
&
getOGlTexture2D
Ref
()
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
;
...
...
modules/core/include/opencv2/core/internal.hpp
View file @
a938534a
...
...
@@ -750,4 +750,35 @@ typedef struct CvBigFuncTable
(tab).fn_2d[CV_32F] = (void*)FUNCNAME##_32f##FLAG; \
(tab).fn_2d[CV_64F] = (void*)FUNCNAME##_64f##FLAG
#ifdef __cplusplus
// Deprecated
class
CV_EXPORTS
CvOpenGlFuncTab
{
public
:
virtual
~
CvOpenGlFuncTab
();
virtual
void
genBuffers
(
int
n
,
unsigned
int
*
buffers
)
const
=
0
;
virtual
void
deleteBuffers
(
int
n
,
const
unsigned
int
*
buffers
)
const
=
0
;
virtual
void
bufferData
(
unsigned
int
target
,
ptrdiff_t
size
,
const
void
*
data
,
unsigned
int
usage
)
const
=
0
;
virtual
void
bufferSubData
(
unsigned
int
target
,
ptrdiff_t
offset
,
ptrdiff_t
size
,
const
void
*
data
)
const
=
0
;
virtual
void
bindBuffer
(
unsigned
int
target
,
unsigned
int
buffer
)
const
=
0
;
virtual
void
*
mapBuffer
(
unsigned
int
target
,
unsigned
int
access
)
const
=
0
;
virtual
void
unmapBuffer
(
unsigned
int
target
)
const
=
0
;
virtual
void
generateBitmapFont
(
const
std
::
string
&
family
,
int
height
,
int
weight
,
bool
italic
,
bool
underline
,
int
start
,
int
count
,
int
base
)
const
=
0
;
virtual
bool
isGlContextInitialized
()
const
=
0
;
};
CV_EXPORTS
void
icvSetOpenGlFuncTab
(
const
CvOpenGlFuncTab
*
tab
);
CV_EXPORTS
bool
icvCheckGlError
(
const
char
*
file
,
const
int
line
,
const
char
*
func
=
""
);
#endif //__cplusplus
#endif // __OPENCV_CORE_INTERNAL_HPP__
modules/core/include/opencv2/core/opengl_interop.hpp
View file @
a938534a
...
...
@@ -47,20 +47,20 @@
#include "opencv2/core/core.hpp"
namespace
cv
{
namespace
cv
{
namespace
ogl
{
CV_EXPORTS
bool
check
Gl
Error
(
const
char
*
file
,
const
int
line
,
const
char
*
func
=
""
);
CV_EXPORTS
bool
checkError
(
const
char
*
file
,
const
int
line
,
const
char
*
func
=
""
);
#if defined(__GNUC__)
#define CV_CheckGlError() CV_DbgAssert( (cv::
checkGl
Error(__FILE__, __LINE__, __func__)) )
#define CV_CheckGlError() CV_DbgAssert( (cv::
gl::check
Error(__FILE__, __LINE__, __func__)) )
#else
#define CV_CheckGlError() CV_DbgAssert( (cv::
checkGl
Error(__FILE__, __LINE__)) )
#define CV_CheckGlError() CV_DbgAssert( (cv::
gl::check
Error(__FILE__, __LINE__)) )
#endif
/////////////////// OpenGL Objects ///////////////////
//! Smart pointer for OpenGL buffer memory with reference counting.
class
CV_EXPORTS
Gl
Buffer
class
CV_EXPORTS
Buffer
{
public
:
enum
Target
...
...
@@ -79,18 +79,18 @@ public:
};
//! create empty buffer
Gl
Buffer
();
Buffer
();
//! create buffer from existed buffer id
Gl
Buffer
(
int
arows
,
int
acols
,
int
atype
,
unsigned
int
abufId
,
bool
autoRelease
=
false
);
Gl
Buffer
(
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
Gl
Buffer
(
int
arows
,
int
acols
,
int
atype
,
Target
target
=
ARRAY_BUFFER
,
bool
autoRelease
=
false
);
Gl
Buffer
(
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
Gl
Buffer
(
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 +109,7 @@ public:
void
copyTo
(
OutputArray
arr
,
Target
target
=
ARRAY_BUFFER
,
bool
autoRelease
=
false
)
const
;
//! create copy of current buffer
Gl
Buffer
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 +147,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
GlTexture
class
CV_EXPORTS
Texture2D
{
public
:
enum
Format
...
...
@@ -162,18 +160,18 @@ public:
};
//! create empty texture
GlTexture
();
Texture2D
();
//! create texture from existed texture id
GlTexture
(
int
arows
,
int
acols
,
Format
aformat
,
unsigned
int
atexId
,
bool
autoRelease
=
false
);
GlTexture
(
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
GlTexture
(
int
arows
,
int
acols
,
Format
aformat
,
bool
autoRelease
=
false
);
GlTexture
(
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
GlTexture
(
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 +210,11 @@ private:
Format
format_
;
};
template
<>
CV_EXPORTS
void
Ptr
<
GlTexture
::
Impl
>::
delete_obj
();
//! OpenGL Arrays
class
CV_EXPORTS
Gl
Arrays
class
CV_EXPORTS
Arrays
{
public
:
Gl
Arrays
();
Arrays
();
void
setVertexArray
(
InputArray
vertex
);
void
resetVertexArray
();
...
...
@@ -243,45 +239,52 @@ public:
private
:
int
size_
;
Gl
Buffer
vertex_
;
Gl
Buffer
color_
;
Gl
Buffer
normal_
;
Gl
Buffer
texCoord_
;
Buffer
vertex_
;
Buffer
color_
;
Buffer
normal_
;
Buffer
texCoord_
;
};
/////////////////// 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
};
}
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
gpu
{
//! set a CUDA device to use OpenGL interoperability
CV_EXPORTS
void
setGlDevice
(
int
device
=
0
);
}
}}
// namespace cv::gl
}
// namespace cv
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
();
}
#endif // __cplusplus
...
...
modules/core/include/opencv2/core/opengl_interop_deprecated.hpp
0 → 100644
View file @
a938534a
/*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__
modules/core/src/matrix.cpp
View file @
a938534a
...
...
@@ -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
(
OPENGL_BUFFER
),
obj
((
void
*
)
&
buf
)
{}
_InputArray
::
_InputArray
(
const
GlTexture
&
tex
)
:
flags
(
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
{
...
...
@@ -1068,39 +1073,45 @@ void _InputArray::getMatVector(vector<Mat>& mv) const
}
GlBuffer
_InputArray
::
getGlBuffer
()
const
{
CV_Error
(
CV_StsNotImplemented
,
"This function in deprecated, do not use it"
);
return
GlBuffer
(
GlBuffer
::
ARRAY_BUFFER
);
}
GlTexture
_InputArray
::
getGlTexture
()
const
{
CV_Error
(
CV_StsNotImplemented
,
"This function in deprecated, do not use it"
);
return
GlTexture
();
}
gpu
::
GpuMat
_InputArray
::
getGpuMat
()
const
{
int
k
=
kind
();
CV_Assert
(
k
==
OPENGL_BUFFER
);
//if( k == OPENGL_BUFFER )
{
const
GlBuffer
*
buf
=
(
const
GlBuffer
*
)
obj
;
return
*
buf
;
}
CV_Assert
(
k
==
GPU_MAT
);
const
gpu
::
GpuMat
*
d_mat
=
(
const
gpu
::
GpuMat
*
)
obj
;
return
*
d_mat
;
}
GlTexture
_InputArray
::
getGlTexture
()
const
ogl
::
Buffer
_InputArray
::
getOGlBuffer
()
const
{
int
k
=
kind
();
CV_Assert
(
k
==
OPENGL_TEXTURE
);
//if( k == OPENGL_TEXTURE )
{
const
GlTexture
*
tex
=
(
const
GlTexture
*
)
obj
;
return
*
tex
;
}
CV_Assert
(
k
==
OPENGL_BUFFER
);
const
ogl
::
Buffer
*
gl_buf
=
(
const
ogl
::
Buffer
*
)
obj
;
return
*
gl_buf
;
}
gpu
::
GpuMat
_InputArray
::
getGpuMat
()
const
ogl
::
Texture2D
_InputArray
::
getOGlTexture2D
()
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
;
}
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
Gl
Buffer
*
)
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,7 +1246,7 @@ int _InputArray::type(int i) const
}
if
(
k
==
OPENGL_BUFFER
)
return
((
const
Gl
Buffer
*
)
obj
)
->
type
();
return
((
const
ogl
::
Buffer
*
)
obj
)
->
type
();
CV_Assert
(
k
==
GPU_MAT
);
//if( k == GPU_MAT )
...
...
@@ -1287,10 +1298,10 @@ bool _InputArray::empty() const
}
if
(
k
==
OPENGL_BUFFER
)
return
((
const
Gl
Buffer
*
)
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 )
...
...
@@ -1305,14 +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
(
Gl
Buffer
&
buf
)
:
_InputArray
(
buf
)
{}
_OutputArray
::
_OutputArray
(
GlTexture
&
tex
)
:
_InputArray
(
tex
)
{}
_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
Gl
Buffer
&
buf
)
:
_InputArray
(
buf
)
{
flags
|=
FIXED_SIZE
|
FIXED_TYPE
;}
_OutputArray
::
_OutputArray
(
const
GlTexture
&
tex
)
:
_InputArray
(
tex
)
{
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
...
...
@@ -1344,9 +1355,9 @@ void _OutputArray::create(Size _sz, int mtype, int i, bool allowTransposed, int
}
if
(
k
==
OPENGL_BUFFER
&&
i
<
0
&&
!
allowTransposed
&&
fixedDepthMask
==
0
)
{
CV_Assert
(
!
fixedSize
()
||
((
Gl
Buffer
*
)
obj
)
->
size
()
==
_sz
);
CV_Assert
(
!
fixedType
()
||
((
Gl
Buffer
*
)
obj
)
->
type
()
==
mtype
);
((
Gl
Buffer
*
)
obj
)
->
create
(
_sz
,
mtype
);
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
};
...
...
@@ -1372,9 +1383,9 @@ void _OutputArray::create(int rows, int cols, int mtype, int i, bool allowTransp
}
if
(
k
==
OPENGL_BUFFER
&&
i
<
0
&&
!
allowTransposed
&&
fixedDepthMask
==
0
)
{
CV_Assert
(
!
fixedSize
()
||
((
Gl
Buffer
*
)
obj
)
->
size
()
==
Size
(
cols
,
rows
));
CV_Assert
(
!
fixedType
()
||
((
Gl
Buffer
*
)
obj
)
->
type
()
==
mtype
);
((
Gl
Buffer
*
)
obj
)
->
create
(
rows
,
cols
,
mtype
);
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
};
...
...
@@ -1598,13 +1609,13 @@ void _OutputArray::release() const
if
(
k
==
OPENGL_BUFFER
)
{
((
Gl
Buffer
*
)
obj
)
->
release
();
((
ogl
::
Buffer
*
)
obj
)
->
release
();
return
;
}
if
(
k
==
OPENGL_TEXTURE
)
{
((
GlTexture
*
)
obj
)
->
release
();
((
ogl
::
Texture2D
*
)
obj
)
->
release
();
return
;
}
...
...
@@ -1673,18 +1684,18 @@ gpu::GpuMat& _OutputArray::getGpuMatRef() const
return
*
(
gpu
::
GpuMat
*
)
obj
;
}
GlBuffer
&
_OutputArray
::
get
GlBufferRef
()
const
ogl
::
Buffer
&
_OutputArray
::
getO
GlBufferRef
()
const
{
int
k
=
kind
();
CV_Assert
(
k
==
OPENGL_BUFFER
);
return
*
(
Gl
Buffer
*
)
obj
;
return
*
(
ogl
::
Buffer
*
)
obj
;
}
GlTexture
&
_OutputArray
::
getGlTexture
Ref
()
const
ogl
::
Texture2D
&
_OutputArray
::
getOGlTexture2D
Ref
()
const
{
int
k
=
kind
();
CV_Assert
(
k
==
OPENGL_TEXTURE
);
return
*
(
GlTexture
*
)
obj
;
return
*
(
ogl
::
Texture2D
*
)
obj
;
}
static
_OutputArray
_none
;
...
...
modules/core/src/opengl_interop.cpp
View file @
a938534a
...
...
@@ -84,7 +84,7 @@ namespace
#endif
}
bool
cv
::
checkGl
Error
(
const
char
*
file
,
const
int
line
,
const
char
*
func
)
bool
cv
::
ogl
::
check
Error
(
const
char
*
file
,
const
int
line
,
const
char
*
func
)
{
#ifndef HAVE_OPENGL
(
void
)
file
;
...
...
@@ -311,17 +311,17 @@ namespace
#endif
////////////////////////////////////////////////////////////////////////
//
Gl
Buffer
//
ogl::
Buffer
#ifndef HAVE_OPENGL
class
cv
::
Gl
Buffer
::
Impl
class
cv
::
ogl
::
Buffer
::
Impl
{
};
#else
class
cv
::
Gl
Buffer
::
Impl
class
cv
::
ogl
::
Buffer
::
Impl
{
public
:
static
const
Ptr
<
Impl
>&
empty
();
...
...
@@ -363,21 +363,21 @@ private:
#endif
};
const
Ptr
<
cv
::
GlBuffer
::
Impl
>&
cv
::
Gl
Buffer
::
Impl
::
empty
()
const
Ptr
<
cv
::
ogl
::
Buffer
::
Impl
>&
cv
::
ogl
::
Buffer
::
Impl
::
empty
()
{
static
Ptr
<
Impl
>
p
(
new
Impl
);
return
p
;
}
cv
::
Gl
Buffer
::
Impl
::
Impl
()
:
bufId_
(
0
),
autoRelease_
(
true
)
cv
::
ogl
::
Buffer
::
Impl
::
Impl
()
:
bufId_
(
0
),
autoRelease_
(
true
)
{
}
cv
::
Gl
Buffer
::
Impl
::
Impl
(
GLuint
abufId
,
bool
autoRelease
)
:
bufId_
(
abufId
),
autoRelease_
(
autoRelease
)
cv
::
ogl
::
Buffer
::
Impl
::
Impl
(
GLuint
abufId
,
bool
autoRelease
)
:
bufId_
(
abufId
),
autoRelease_
(
autoRelease
)
{
}
cv
::
Gl
Buffer
::
Impl
::
Impl
(
GLsizeiptr
size
,
const
GLvoid
*
data
,
GLenum
target
,
bool
autoRelease
)
:
bufId_
(
0
),
autoRelease_
(
autoRelease
)
cv
::
ogl
::
Buffer
::
Impl
::
Impl
(
GLsizeiptr
size
,
const
GLvoid
*
data
,
GLenum
target
,
bool
autoRelease
)
:
bufId_
(
0
),
autoRelease_
(
autoRelease
)
{
gl
::
GenBuffers
(
1
,
&
bufId_
);
CV_CheckGlError
();
...
...
@@ -394,19 +394,19 @@ cv::GlBuffer::Impl::Impl(GLsizeiptr size, const GLvoid* data, GLenum target, boo
CV_CheckGlError
();
}
cv
::
Gl
Buffer
::
Impl
::~
Impl
()
cv
::
ogl
::
Buffer
::
Impl
::~
Impl
()
{
if
(
autoRelease_
&&
bufId_
)
gl
::
DeleteBuffers
(
1
,
&
bufId_
);
}
void
cv
::
Gl
Buffer
::
Impl
::
bind
(
GLenum
target
)
const
void
cv
::
ogl
::
Buffer
::
Impl
::
bind
(
GLenum
target
)
const
{
gl
::
BindBuffer
(
target
,
bufId_
);
CV_CheckGlError
();
}
void
cv
::
Gl
Buffer
::
Impl
::
copyFrom
(
GLuint
srcBuf
,
GLsizeiptr
size
)
void
cv
::
ogl
::
Buffer
::
Impl
::
copyFrom
(
GLuint
srcBuf
,
GLsizeiptr
size
)
{
gl
::
BindBuffer
(
gl
::
COPY_WRITE_BUFFER
,
bufId_
);
CV_CheckGlError
();
...
...
@@ -418,7 +418,7 @@ void cv::GlBuffer::Impl::copyFrom(GLuint srcBuf, GLsizeiptr size)
CV_CheckGlError
();
}
void
cv
::
Gl
Buffer
::
Impl
::
copyFrom
(
GLsizeiptr
size
,
const
GLvoid
*
data
)
void
cv
::
ogl
::
Buffer
::
Impl
::
copyFrom
(
GLsizeiptr
size
,
const
GLvoid
*
data
)
{
gl
::
BindBuffer
(
gl
::
COPY_WRITE_BUFFER
,
bufId_
);
CV_CheckGlError
();
...
...
@@ -427,7 +427,7 @@ void cv::GlBuffer::Impl::copyFrom(GLsizeiptr size, const GLvoid* data)
CV_CheckGlError
();
}
void
cv
::
Gl
Buffer
::
Impl
::
copyTo
(
GLsizeiptr
size
,
GLvoid
*
data
)
const
void
cv
::
ogl
::
Buffer
::
Impl
::
copyTo
(
GLsizeiptr
size
,
GLvoid
*
data
)
const
{
gl
::
BindBuffer
(
gl
::
COPY_READ_BUFFER
,
bufId_
);
CV_CheckGlError
();
...
...
@@ -436,7 +436,7 @@ void cv::GlBuffer::Impl::copyTo(GLsizeiptr size, GLvoid* data) const
CV_CheckGlError
();
}
void
*
cv
::
Gl
Buffer
::
Impl
::
mapHost
(
GLenum
access
)
void
*
cv
::
ogl
::
Buffer
::
Impl
::
mapHost
(
GLenum
access
)
{
gl
::
BindBuffer
(
gl
::
COPY_READ_BUFFER
,
bufId_
);
CV_CheckGlError
();
...
...
@@ -447,31 +447,31 @@ void* cv::GlBuffer::Impl::mapHost(GLenum access)
return
data
;
}
void
cv
::
Gl
Buffer
::
Impl
::
unmapHost
()
void
cv
::
ogl
::
Buffer
::
Impl
::
unmapHost
()
{
gl
::
UnmapBuffer
(
gl
::
COPY_READ_BUFFER
);
}
#ifdef HAVE_CUDA
void
cv
::
Gl
Buffer
::
Impl
::
copyFrom
(
const
void
*
src
,
size_t
spitch
,
size_t
width
,
size_t
height
,
cudaStream_t
stream
)
void
cv
::
ogl
::
Buffer
::
Impl
::
copyFrom
(
const
void
*
src
,
size_t
spitch
,
size_t
width
,
size_t
height
,
cudaStream_t
stream
)
{
cudaResource_
.
registerBuffer
(
bufId_
);
cudaResource_
.
copyFrom
(
src
,
spitch
,
width
,
height
,
stream
);
}
void
cv
::
Gl
Buffer
::
Impl
::
copyTo
(
void
*
dst
,
size_t
dpitch
,
size_t
width
,
size_t
height
,
cudaStream_t
stream
)
const
void
cv
::
ogl
::
Buffer
::
Impl
::
copyTo
(
void
*
dst
,
size_t
dpitch
,
size_t
width
,
size_t
height
,
cudaStream_t
stream
)
const
{
cudaResource_
.
registerBuffer
(
bufId_
);
cudaResource_
.
copyTo
(
dst
,
dpitch
,
width
,
height
,
stream
);
}
void
*
cv
::
Gl
Buffer
::
Impl
::
mapDevice
(
cudaStream_t
stream
)
void
*
cv
::
ogl
::
Buffer
::
Impl
::
mapDevice
(
cudaStream_t
stream
)
{
cudaResource_
.
registerBuffer
(
bufId_
);
return
cudaResource_
.
map
(
stream
);
}
void
cv
::
Gl
Buffer
::
Impl
::
unmapDevice
(
cudaStream_t
stream
)
void
cv
::
ogl
::
Buffer
::
Impl
::
unmapDevice
(
cudaStream_t
stream
)
{
cudaResource_
.
unmap
(
stream
);
}
...
...
@@ -479,7 +479,7 @@ void cv::GlBuffer::Impl::unmapHost()
#endif // HAVE_OPENGL
cv
::
GlBuffer
::
Gl
Buffer
()
:
rows_
(
0
),
cols_
(
0
),
type_
(
0
)
cv
::
ogl
::
Buffer
::
Buffer
()
:
rows_
(
0
),
cols_
(
0
),
type_
(
0
)
{
#ifndef HAVE_OPENGL
throw_nogl
();
...
...
@@ -488,7 +488,7 @@ cv::GlBuffer::GlBuffer() : rows_(0), cols_(0), type_(0)
#endif
}
cv
::
GlBuffer
::
Gl
Buffer
(
int
arows
,
int
acols
,
int
atype
,
unsigned
int
abufId
,
bool
autoRelease
)
:
rows_
(
0
),
cols_
(
0
),
type_
(
0
)
cv
::
ogl
::
Buffer
::
Buffer
(
int
arows
,
int
acols
,
int
atype
,
unsigned
int
abufId
,
bool
autoRelease
)
:
rows_
(
0
),
cols_
(
0
),
type_
(
0
)
{
#ifndef HAVE_OPENGL
(
void
)
arows
;
...
...
@@ -505,7 +505,7 @@ cv::GlBuffer::GlBuffer(int arows, int acols, int atype, unsigned int abufId, boo
#endif
}
cv
::
GlBuffer
::
Gl
Buffer
(
Size
asize
,
int
atype
,
unsigned
int
abufId
,
bool
autoRelease
)
:
rows_
(
0
),
cols_
(
0
),
type_
(
0
)
cv
::
ogl
::
Buffer
::
Buffer
(
Size
asize
,
int
atype
,
unsigned
int
abufId
,
bool
autoRelease
)
:
rows_
(
0
),
cols_
(
0
),
type_
(
0
)
{
#ifndef HAVE_OPENGL
(
void
)
asize
;
...
...
@@ -521,17 +521,17 @@ cv::GlBuffer::GlBuffer(Size asize, int atype, unsigned int abufId, bool autoRele
#endif
}
cv
::
GlBuffer
::
Gl
Buffer
(
int
arows
,
int
acols
,
int
atype
,
Target
target
,
bool
autoRelease
)
:
rows_
(
0
),
cols_
(
0
),
type_
(
0
)
cv
::
ogl
::
Buffer
::
Buffer
(
int
arows
,
int
acols
,
int
atype
,
Target
target
,
bool
autoRelease
)
:
rows_
(
0
),
cols_
(
0
),
type_
(
0
)
{
create
(
arows
,
acols
,
atype
,
target
,
autoRelease
);
}
cv
::
GlBuffer
::
Gl
Buffer
(
Size
asize
,
int
atype
,
Target
target
,
bool
autoRelease
)
:
rows_
(
0
),
cols_
(
0
),
type_
(
0
)
cv
::
ogl
::
Buffer
::
Buffer
(
Size
asize
,
int
atype
,
Target
target
,
bool
autoRelease
)
:
rows_
(
0
),
cols_
(
0
),
type_
(
0
)
{
create
(
asize
,
atype
,
target
,
autoRelease
);
}
cv
::
GlBuffer
::
Gl
Buffer
(
InputArray
arr
,
Target
target
,
bool
autoRelease
)
:
rows_
(
0
),
cols_
(
0
),
type_
(
0
)
cv
::
ogl
::
Buffer
::
Buffer
(
InputArray
arr
,
Target
target
,
bool
autoRelease
)
:
rows_
(
0
),
cols_
(
0
),
type_
(
0
)
{
#ifndef HAVE_OPENGL
(
void
)
arr
;
...
...
@@ -576,7 +576,7 @@ cv::GlBuffer::GlBuffer(InputArray arr, Target target, bool autoRelease) : rows_(
#endif
}
void
cv
::
Gl
Buffer
::
create
(
int
arows
,
int
acols
,
int
atype
,
Target
target
,
bool
autoRelease
)
void
cv
::
ogl
::
Buffer
::
create
(
int
arows
,
int
acols
,
int
atype
,
Target
target
,
bool
autoRelease
)
{
#ifndef HAVE_OPENGL
(
void
)
arows
;
...
...
@@ -597,7 +597,7 @@ void cv::GlBuffer::create(int arows, int acols, int atype, Target target, bool a
#endif
}
void
cv
::
Gl
Buffer
::
release
()
void
cv
::
ogl
::
Buffer
::
release
()
{
#ifdef HAVE_OPENGL
if
(
*
impl_
.
refcount
==
1
)
...
...
@@ -609,7 +609,7 @@ void cv::GlBuffer::release()
#endif
}
void
cv
::
Gl
Buffer
::
setAutoRelease
(
bool
flag
)
void
cv
::
ogl
::
Buffer
::
setAutoRelease
(
bool
flag
)
{
#ifndef HAVE_OPENGL
(
void
)
flag
;
...
...
@@ -619,7 +619,7 @@ void cv::GlBuffer::setAutoRelease(bool flag)
#endif
}
void
cv
::
Gl
Buffer
::
copyFrom
(
InputArray
arr
,
Target
target
,
bool
autoRelease
)
void
cv
::
ogl
::
Buffer
::
copyFrom
(
InputArray
arr
,
Target
target
,
bool
autoRelease
)
{
#ifndef HAVE_OPENGL
(
void
)
arr
;
...
...
@@ -631,7 +631,7 @@ void cv::GlBuffer::copyFrom(InputArray arr, Target target, bool autoRelease)
if
(
kind
==
_InputArray
::
OPENGL_TEXTURE
)
{
GlTexture
tex
=
arr
.
getGlTexture
();
ogl
::
Texture2D
tex
=
arr
.
getOGlTexture2D
();
tex
.
copyTo
(
*
this
);
setAutoRelease
(
autoRelease
);
return
;
...
...
@@ -645,7 +645,7 @@ void cv::GlBuffer::copyFrom(InputArray arr, Target target, bool autoRelease)
{
case
_InputArray
:
:
OPENGL_BUFFER
:
{
GlBuffer
buf
=
arr
.
get
GlBuffer
();
ogl
::
Buffer
buf
=
arr
.
getO
GlBuffer
();
impl_
->
copyFrom
(
buf
.
bufId
(),
asize
.
area
()
*
CV_ELEM_SIZE
(
atype
));
break
;
}
...
...
@@ -672,7 +672,7 @@ void cv::GlBuffer::copyFrom(InputArray arr, Target target, bool autoRelease)
#endif
}
void
cv
::
Gl
Buffer
::
copyTo
(
OutputArray
arr
,
Target
target
,
bool
autoRelease
)
const
void
cv
::
ogl
::
Buffer
::
copyTo
(
OutputArray
arr
,
Target
target
,
bool
autoRelease
)
const
{
#ifndef HAVE_OPENGL
(
void
)
arr
;
...
...
@@ -686,13 +686,13 @@ void cv::GlBuffer::copyTo(OutputArray arr, Target target, bool autoRelease) cons
{
case
_InputArray
:
:
OPENGL_BUFFER
:
{
arr
.
getGlBufferRef
().
copyFrom
(
*
this
,
target
,
autoRelease
);
arr
.
get
O
GlBufferRef
().
copyFrom
(
*
this
,
target
,
autoRelease
);
break
;
}
case
_InputArray
:
:
OPENGL_TEXTURE
:
{
arr
.
get
GlTexture
Ref
().
copyFrom
(
*
this
,
autoRelease
);
arr
.
get
OGlTexture2D
Ref
().
copyFrom
(
*
this
,
autoRelease
);
break
;
}
...
...
@@ -720,21 +720,21 @@ void cv::GlBuffer::copyTo(OutputArray arr, Target target, bool autoRelease) cons
#endif
}
GlBuffer
cv
::
Gl
Buffer
::
clone
(
Target
target
,
bool
autoRelease
)
const
cv
::
ogl
::
Buffer
cv
::
ogl
::
Buffer
::
clone
(
Target
target
,
bool
autoRelease
)
const
{
#ifndef HAVE_OPENGL
(
void
)
target
;
(
void
)
autoRelease
;
throw_nogl
();
return
Gl
Buffer
();
return
cv
::
ogl
::
Buffer
();
#else
Gl
Buffer
buf
;
ogl
::
Buffer
buf
;
buf
.
copyFrom
(
*
this
,
target
,
autoRelease
);
return
buf
;
#endif
}
void
cv
::
Gl
Buffer
::
bind
(
Target
target
)
const
void
cv
::
ogl
::
Buffer
::
bind
(
Target
target
)
const
{
#ifndef HAVE_OPENGL
(
void
)
target
;
...
...
@@ -744,7 +744,7 @@ void cv::GlBuffer::bind(Target target) const
#endif
}
void
cv
::
Gl
Buffer
::
unbind
(
Target
target
)
void
cv
::
ogl
::
Buffer
::
unbind
(
Target
target
)
{
#ifndef HAVE_OPENGL
(
void
)
target
;
...
...
@@ -755,7 +755,7 @@ void cv::GlBuffer::unbind(Target target)
#endif
}
Mat
cv
::
Gl
Buffer
::
mapHost
(
Access
access
)
Mat
cv
::
ogl
::
Buffer
::
mapHost
(
Access
access
)
{
#ifndef HAVE_OPENGL
(
void
)
access
;
...
...
@@ -766,7 +766,7 @@ Mat cv::GlBuffer::mapHost(Access access)
#endif
}
void
cv
::
Gl
Buffer
::
unmapHost
()
void
cv
::
ogl
::
Buffer
::
unmapHost
()
{
#ifndef HAVE_OPENGL
throw_nogl
();
...
...
@@ -775,7 +775,7 @@ void cv::GlBuffer::unmapHost()
#endif
}
GpuMat
cv
::
Gl
Buffer
::
mapDevice
()
GpuMat
cv
::
ogl
::
Buffer
::
mapDevice
()
{
#ifndef HAVE_OPENGL
throw_nogl
();
...
...
@@ -790,7 +790,7 @@ GpuMat cv::GlBuffer::mapDevice()
#endif
}
void
cv
::
Gl
Buffer
::
unmapDevice
()
void
cv
::
ogl
::
Buffer
::
unmapDevice
()
{
#ifndef HAVE_OPENGL
throw_nogl
();
...
...
@@ -803,7 +803,7 @@ void cv::GlBuffer::unmapDevice()
#endif
}
unsigned
int
cv
::
Gl
Buffer
::
bufId
()
const
unsigned
int
cv
::
ogl
::
Buffer
::
bufId
()
const
{
#ifndef HAVE_OPENGL
throw_nogl
();
...
...
@@ -813,23 +813,23 @@ unsigned int cv::GlBuffer::bufId() const
#endif
}
template
<>
void
cv
::
Ptr
<
cv
::
Gl
Buffer
::
Impl
>::
delete_obj
()
template
<>
void
cv
::
Ptr
<
cv
::
ogl
::
Buffer
::
Impl
>::
delete_obj
()
{
if
(
obj
)
delete
obj
;
}
//////////////////////////////////////////////////////////////////////////////////////////
//
Gl
Texture
//
ogl::
Texture
#ifndef HAVE_OPENGL
class
cv
::
GlTexture
::
Impl
class
cv
::
ogl
::
Texture2D
::
Impl
{
};
#else
class
cv
::
GlTexture
::
Impl
class
cv
::
ogl
::
Texture2D
::
Impl
{
public
:
static
const
Ptr
<
Impl
>
empty
();
...
...
@@ -854,21 +854,21 @@ private:
bool
autoRelease_
;
};
const
Ptr
<
cv
::
GlTexture
::
Impl
>
cv
::
GlTexture
::
Impl
::
empty
()
const
Ptr
<
cv
::
ogl
::
Texture2D
::
Impl
>
cv
::
ogl
::
Texture2D
::
Impl
::
empty
()
{
static
Ptr
<
Impl
>
p
(
new
Impl
);
return
p
;
}
cv
::
GlTexture
::
Impl
::
Impl
()
:
texId_
(
0
),
autoRelease_
(
true
)
cv
::
ogl
::
Texture2D
::
Impl
::
Impl
()
:
texId_
(
0
),
autoRelease_
(
true
)
{
}
cv
::
GlTexture
::
Impl
::
Impl
(
GLuint
atexId
,
bool
autoRelease
)
:
texId_
(
atexId
),
autoRelease_
(
autoRelease
)
cv
::
ogl
::
Texture2D
::
Impl
::
Impl
(
GLuint
atexId
,
bool
autoRelease
)
:
texId_
(
atexId
),
autoRelease_
(
autoRelease
)
{
}
cv
::
GlTexture
::
Impl
::
Impl
(
GLint
internalFormat
,
GLsizei
width
,
GLsizei
height
,
GLenum
format
,
GLenum
type
,
const
GLvoid
*
pixels
,
bool
autoRelease
)
:
texId_
(
0
),
autoRelease_
(
autoRelease
)
cv
::
ogl
::
Texture2D
::
Impl
::
Impl
(
GLint
internalFormat
,
GLsizei
width
,
GLsizei
height
,
GLenum
format
,
GLenum
type
,
const
GLvoid
*
pixels
,
bool
autoRelease
)
:
texId_
(
0
),
autoRelease_
(
autoRelease
)
{
gl
::
GenTextures
(
1
,
&
texId_
);
CV_CheckGlError
();
...
...
@@ -888,13 +888,13 @@ cv::GlTexture::Impl::Impl(GLint internalFormat, GLsizei width, GLsizei height, G
CV_CheckGlError
();
}
cv
::
GlTexture
::
Impl
::~
Impl
()
cv
::
ogl
::
Texture2D
::
Impl
::~
Impl
()
{
if
(
autoRelease_
&&
texId_
)
gl
::
DeleteTextures
(
1
,
&
texId_
);
}
void
cv
::
GlTexture
::
Impl
::
copyFrom
(
GLsizei
width
,
GLsizei
height
,
GLenum
format
,
GLenum
type
,
const
GLvoid
*
pixels
)
void
cv
::
ogl
::
Texture2D
::
Impl
::
copyFrom
(
GLsizei
width
,
GLsizei
height
,
GLenum
format
,
GLenum
type
,
const
GLvoid
*
pixels
)
{
gl
::
BindTexture
(
gl
::
TEXTURE_2D
,
texId_
);
CV_CheckGlError
();
...
...
@@ -909,7 +909,7 @@ void cv::GlTexture::Impl::copyFrom(GLsizei width, GLsizei height, GLenum format,
CV_CheckGlError
();
}
void
cv
::
GlTexture
::
Impl
::
copyTo
(
GLenum
format
,
GLenum
type
,
GLvoid
*
pixels
)
const
void
cv
::
ogl
::
Texture2D
::
Impl
::
copyTo
(
GLenum
format
,
GLenum
type
,
GLvoid
*
pixels
)
const
{
gl
::
BindTexture
(
gl
::
TEXTURE_2D
,
texId_
);
CV_CheckGlError
();
...
...
@@ -921,7 +921,7 @@ void cv::GlTexture::Impl::copyTo(GLenum format, GLenum type, GLvoid* pixels) con
CV_CheckGlError
();
}
void
cv
::
GlTexture
::
Impl
::
bind
()
const
void
cv
::
ogl
::
Texture2D
::
Impl
::
bind
()
const
{
gl
::
BindTexture
(
gl
::
TEXTURE_2D
,
texId_
);
CV_CheckGlError
();
...
...
@@ -929,7 +929,7 @@ void cv::GlTexture::Impl::bind() const
#endif // HAVE_OPENGL
cv
::
GlTexture
::
GlTexture
()
:
rows_
(
0
),
cols_
(
0
),
format_
(
NONE
)
cv
::
ogl
::
Texture2D
::
Texture2D
()
:
rows_
(
0
),
cols_
(
0
),
format_
(
NONE
)
{
#ifndef HAVE_OPENGL
throw_nogl
();
...
...
@@ -938,7 +938,7 @@ cv::GlTexture::GlTexture() : rows_(0), cols_(0), format_(NONE)
#endif
}
cv
::
GlTexture
::
GlTexture
(
int
arows
,
int
acols
,
Format
aformat
,
unsigned
int
atexId
,
bool
autoRelease
)
:
rows_
(
0
),
cols_
(
0
),
format_
(
NONE
)
cv
::
ogl
::
Texture2D
::
Texture2D
(
int
arows
,
int
acols
,
Format
aformat
,
unsigned
int
atexId
,
bool
autoRelease
)
:
rows_
(
0
),
cols_
(
0
),
format_
(
NONE
)
{
#ifndef HAVE_OPENGL
(
void
)
arows
;
...
...
@@ -955,7 +955,7 @@ cv::GlTexture::GlTexture(int arows, int acols, Format aformat, unsigned int atex
#endif
}
cv
::
GlTexture
::
GlTexture
(
Size
asize
,
Format
aformat
,
unsigned
int
atexId
,
bool
autoRelease
)
:
rows_
(
0
),
cols_
(
0
),
format_
(
NONE
)
cv
::
ogl
::
Texture2D
::
Texture2D
(
Size
asize
,
Format
aformat
,
unsigned
int
atexId
,
bool
autoRelease
)
:
rows_
(
0
),
cols_
(
0
),
format_
(
NONE
)
{
#ifndef HAVE_OPENGL
(
void
)
asize
;
...
...
@@ -971,17 +971,17 @@ cv::GlTexture::GlTexture(Size asize, Format aformat, unsigned int atexId, bool a
#endif
}
cv
::
GlTexture
::
GlTexture
(
int
arows
,
int
acols
,
Format
aformat
,
bool
autoRelease
)
:
rows_
(
0
),
cols_
(
0
),
format_
(
NONE
)
cv
::
ogl
::
Texture2D
::
Texture2D
(
int
arows
,
int
acols
,
Format
aformat
,
bool
autoRelease
)
:
rows_
(
0
),
cols_
(
0
),
format_
(
NONE
)
{
create
(
arows
,
acols
,
aformat
,
autoRelease
);
}
cv
::
GlTexture
::
GlTexture
(
Size
asize
,
Format
aformat
,
bool
autoRelease
)
:
rows_
(
0
),
cols_
(
0
),
format_
(
NONE
)
cv
::
ogl
::
Texture2D
::
Texture2D
(
Size
asize
,
Format
aformat
,
bool
autoRelease
)
:
rows_
(
0
),
cols_
(
0
),
format_
(
NONE
)
{
create
(
asize
,
aformat
,
autoRelease
);
}
cv
::
GlTexture
::
GlTexture
(
InputArray
arr
,
bool
autoRelease
)
:
rows_
(
0
),
cols_
(
0
),
format_
(
NONE
)
cv
::
ogl
::
Texture2D
::
Texture2D
(
InputArray
arr
,
bool
autoRelease
)
:
rows_
(
0
),
cols_
(
0
),
format_
(
NONE
)
{
#ifndef HAVE_OPENGL
(
void
)
arr
;
...
...
@@ -1012,10 +1012,10 @@ cv::GlTexture::GlTexture(InputArray arr, bool autoRelease) : rows_(0), cols_(0),
{
case
_InputArray
:
:
OPENGL_BUFFER
:
{
GlBuffer
buf
=
arr
.
get
GlBuffer
();
buf
.
bind
(
Gl
Buffer
::
PIXEL_UNPACK_BUFFER
);
ogl
::
Buffer
buf
=
arr
.
getO
GlBuffer
();
buf
.
bind
(
ogl
::
Buffer
::
PIXEL_UNPACK_BUFFER
);
impl_
=
new
Impl
(
internalFormats
[
cn
],
asize
.
width
,
asize
.
height
,
srcFormats
[
cn
],
gl_types
[
depth
],
0
,
autoRelease
);
GlBuffer
::
unbind
(
Gl
Buffer
::
PIXEL_UNPACK_BUFFER
);
ogl
::
Buffer
::
unbind
(
ogl
::
Buffer
::
PIXEL_UNPACK_BUFFER
);
break
;
}
...
...
@@ -1025,10 +1025,10 @@ cv::GlTexture::GlTexture(InputArray arr, bool autoRelease) : rows_(0), cols_(0),
throw_nocuda
();
#else
GpuMat
dmat
=
arr
.
getGpuMat
();
GlBuffer
buf
(
dmat
,
Gl
Buffer
::
PIXEL_UNPACK_BUFFER
);
buf
.
bind
(
Gl
Buffer
::
PIXEL_UNPACK_BUFFER
);
ogl
::
Buffer
buf
(
dmat
,
ogl
::
Buffer
::
PIXEL_UNPACK_BUFFER
);
buf
.
bind
(
ogl
::
Buffer
::
PIXEL_UNPACK_BUFFER
);
impl_
=
new
Impl
(
internalFormats
[
cn
],
asize
.
width
,
asize
.
height
,
srcFormats
[
cn
],
gl_types
[
depth
],
0
,
autoRelease
);
GlBuffer
::
unbind
(
Gl
Buffer
::
PIXEL_UNPACK_BUFFER
);
ogl
::
Buffer
::
unbind
(
ogl
::
Buffer
::
PIXEL_UNPACK_BUFFER
);
#endif
break
;
...
...
@@ -1038,7 +1038,7 @@ cv::GlTexture::GlTexture(InputArray arr, bool autoRelease) : rows_(0), cols_(0),
{
Mat
mat
=
arr
.
getMat
();
CV_Assert
(
mat
.
isContinuous
()
);
GlBuffer
::
unbind
(
Gl
Buffer
::
PIXEL_UNPACK_BUFFER
);
ogl
::
Buffer
::
unbind
(
ogl
::
Buffer
::
PIXEL_UNPACK_BUFFER
);
impl_
=
new
Impl
(
internalFormats
[
cn
],
asize
.
width
,
asize
.
height
,
srcFormats
[
cn
],
gl_types
[
depth
],
mat
.
data
,
autoRelease
);
break
;
}
...
...
@@ -1050,7 +1050,7 @@ cv::GlTexture::GlTexture(InputArray arr, bool autoRelease) : rows_(0), cols_(0),
#endif
}
void
cv
::
GlTexture
::
create
(
int
arows
,
int
acols
,
Format
aformat
,
bool
autoRelease
)
void
cv
::
ogl
::
Texture2D
::
create
(
int
arows
,
int
acols
,
Format
aformat
,
bool
autoRelease
)
{
#ifndef HAVE_OPENGL
(
void
)
arows
;
...
...
@@ -1061,7 +1061,7 @@ void cv::GlTexture::create(int arows, int acols, Format aformat, bool autoReleas
#else
if
(
rows_
!=
arows
||
cols_
!=
acols
||
format_
!=
aformat
)
{
GlBuffer
::
unbind
(
Gl
Buffer
::
PIXEL_UNPACK_BUFFER
);
ogl
::
Buffer
::
unbind
(
ogl
::
Buffer
::
PIXEL_UNPACK_BUFFER
);
impl_
=
new
Impl
(
aformat
,
acols
,
arows
,
aformat
,
gl
::
FLOAT
,
0
,
autoRelease
);
rows_
=
arows
;
cols_
=
acols
;
...
...
@@ -1070,7 +1070,7 @@ void cv::GlTexture::create(int arows, int acols, Format aformat, bool autoReleas
#endif
}
void
cv
::
GlTexture
::
release
()
void
cv
::
ogl
::
Texture2D
::
release
()
{
#ifdef HAVE_OPENGL
if
(
*
impl_
.
refcount
==
1
)
...
...
@@ -1082,7 +1082,7 @@ void cv::GlTexture::release()
#endif
}
void
cv
::
GlTexture
::
setAutoRelease
(
bool
flag
)
void
cv
::
ogl
::
Texture2D
::
setAutoRelease
(
bool
flag
)
{
#ifndef HAVE_OPENGL
(
void
)
flag
;
...
...
@@ -1092,7 +1092,7 @@ void cv::GlTexture::setAutoRelease(bool flag)
#endif
}
void
cv
::
GlTexture
::
copyFrom
(
InputArray
arr
,
bool
autoRelease
)
void
cv
::
ogl
::
Texture2D
::
copyFrom
(
InputArray
arr
,
bool
autoRelease
)
{
#ifndef HAVE_OPENGL
(
void
)
arr
;
...
...
@@ -1125,10 +1125,10 @@ void cv::GlTexture::copyFrom(InputArray arr, bool autoRelease)
{
case
_InputArray
:
:
OPENGL_BUFFER
:
{
GlBuffer
buf
=
arr
.
get
GlBuffer
();
buf
.
bind
(
Gl
Buffer
::
PIXEL_UNPACK_BUFFER
);
ogl
::
Buffer
buf
=
arr
.
getO
GlBuffer
();
buf
.
bind
(
ogl
::
Buffer
::
PIXEL_UNPACK_BUFFER
);
impl_
->
copyFrom
(
asize
.
width
,
asize
.
height
,
srcFormats
[
cn
],
gl_types
[
depth
],
0
);
GlBuffer
::
unbind
(
Gl
Buffer
::
PIXEL_UNPACK_BUFFER
);
ogl
::
Buffer
::
unbind
(
ogl
::
Buffer
::
PIXEL_UNPACK_BUFFER
);
break
;
}
...
...
@@ -1138,10 +1138,10 @@ void cv::GlTexture::copyFrom(InputArray arr, bool autoRelease)
throw_nocuda
();
#else
GpuMat
dmat
=
arr
.
getGpuMat
();
GlBuffer
buf
(
dmat
,
Gl
Buffer
::
PIXEL_UNPACK_BUFFER
);
buf
.
bind
(
Gl
Buffer
::
PIXEL_UNPACK_BUFFER
);
ogl
::
Buffer
buf
(
dmat
,
ogl
::
Buffer
::
PIXEL_UNPACK_BUFFER
);
buf
.
bind
(
ogl
::
Buffer
::
PIXEL_UNPACK_BUFFER
);
impl_
->
copyFrom
(
asize
.
width
,
asize
.
height
,
srcFormats
[
cn
],
gl_types
[
depth
],
0
);
GlBuffer
::
unbind
(
Gl
Buffer
::
PIXEL_UNPACK_BUFFER
);
ogl
::
Buffer
::
unbind
(
ogl
::
Buffer
::
PIXEL_UNPACK_BUFFER
);
#endif
break
;
...
...
@@ -1151,14 +1151,14 @@ void cv::GlTexture::copyFrom(InputArray arr, bool autoRelease)
{
Mat
mat
=
arr
.
getMat
();
CV_Assert
(
mat
.
isContinuous
()
);
GlBuffer
::
unbind
(
Gl
Buffer
::
PIXEL_UNPACK_BUFFER
);
ogl
::
Buffer
::
unbind
(
ogl
::
Buffer
::
PIXEL_UNPACK_BUFFER
);
impl_
->
copyFrom
(
asize
.
width
,
asize
.
height
,
srcFormats
[
cn
],
gl_types
[
depth
],
mat
.
data
);
}
}
#endif
}
void
cv
::
GlTexture
::
copyTo
(
OutputArray
arr
,
int
ddepth
,
bool
autoRelease
)
const
void
cv
::
ogl
::
Texture2D
::
copyTo
(
OutputArray
arr
,
int
ddepth
,
bool
autoRelease
)
const
{
#ifndef HAVE_OPENGL
(
void
)
arr
;
...
...
@@ -1175,11 +1175,11 @@ void cv::GlTexture::copyTo(OutputArray arr, int ddepth, bool autoRelease) const
{
case
_InputArray
:
:
OPENGL_BUFFER
:
{
GlBuffer
&
buf
=
arr
.
get
GlBufferRef
();
buf
.
create
(
rows_
,
cols_
,
CV_MAKE_TYPE
(
ddepth
,
cn
),
Gl
Buffer
::
PIXEL_PACK_BUFFER
,
autoRelease
);
buf
.
bind
(
Gl
Buffer
::
PIXEL_PACK_BUFFER
);
ogl
::
Buffer
&
buf
=
arr
.
getO
GlBufferRef
();
buf
.
create
(
rows_
,
cols_
,
CV_MAKE_TYPE
(
ddepth
,
cn
),
ogl
::
Buffer
::
PIXEL_PACK_BUFFER
,
autoRelease
);
buf
.
bind
(
ogl
::
Buffer
::
PIXEL_PACK_BUFFER
);
impl_
->
copyTo
(
dstFormat
,
gl_types
[
ddepth
],
0
);
GlBuffer
::
unbind
(
Gl
Buffer
::
PIXEL_PACK_BUFFER
);
ogl
::
Buffer
::
unbind
(
ogl
::
Buffer
::
PIXEL_PACK_BUFFER
);
break
;
}
...
...
@@ -1188,10 +1188,10 @@ void cv::GlTexture::copyTo(OutputArray arr, int ddepth, bool autoRelease) const
#if !defined HAVE_CUDA || defined(CUDA_DISABLER)
throw_nocuda
();
#else
GlBuffer
buf
(
rows_
,
cols_
,
CV_MAKE_TYPE
(
ddepth
,
cn
),
Gl
Buffer
::
PIXEL_PACK_BUFFER
);
buf
.
bind
(
Gl
Buffer
::
PIXEL_PACK_BUFFER
);
ogl
::
Buffer
buf
(
rows_
,
cols_
,
CV_MAKE_TYPE
(
ddepth
,
cn
),
ogl
::
Buffer
::
PIXEL_PACK_BUFFER
);
buf
.
bind
(
ogl
::
Buffer
::
PIXEL_PACK_BUFFER
);
impl_
->
copyTo
(
dstFormat
,
gl_types
[
ddepth
],
0
);
GlBuffer
::
unbind
(
Gl
Buffer
::
PIXEL_PACK_BUFFER
);
ogl
::
Buffer
::
unbind
(
ogl
::
Buffer
::
PIXEL_PACK_BUFFER
);
buf
.
copyTo
(
arr
);
#endif
...
...
@@ -1203,14 +1203,14 @@ void cv::GlTexture::copyTo(OutputArray arr, int ddepth, bool autoRelease) const
arr
.
create
(
rows_
,
cols_
,
CV_MAKE_TYPE
(
ddepth
,
cn
));
Mat
mat
=
arr
.
getMat
();
CV_Assert
(
mat
.
isContinuous
()
);
GlBuffer
::
unbind
(
Gl
Buffer
::
PIXEL_PACK_BUFFER
);
ogl
::
Buffer
::
unbind
(
ogl
::
Buffer
::
PIXEL_PACK_BUFFER
);
impl_
->
copyTo
(
dstFormat
,
gl_types
[
ddepth
],
mat
.
data
);
}
}
#endif
}
void
cv
::
GlTexture
::
bind
()
const
void
cv
::
ogl
::
Texture2D
::
bind
()
const
{
#ifndef HAVE_OPENGL
throw_nogl
();
...
...
@@ -1219,7 +1219,7 @@ void cv::GlTexture::bind() const
#endif
}
unsigned
int
cv
::
GlTexture
::
texId
()
const
unsigned
int
cv
::
ogl
::
Texture2D
::
texId
()
const
{
#ifndef HAVE_OPENGL
throw_nogl
();
...
...
@@ -1229,19 +1229,19 @@ unsigned int cv::GlTexture::texId() const
#endif
}
template
<>
void
cv
::
Ptr
<
cv
::
GlTexture
::
Impl
>::
delete_obj
()
template
<>
void
cv
::
Ptr
<
cv
::
ogl
::
Texture2D
::
Impl
>::
delete_obj
()
{
if
(
obj
)
delete
obj
;
}
////////////////////////////////////////////////////////////////////////
//
Gl
Arrays
//
ogl::
Arrays
cv
::
GlArrays
::
Gl
Arrays
()
:
size_
(
0
)
cv
::
ogl
::
Arrays
::
Arrays
()
:
size_
(
0
)
{
}
void
cv
::
Gl
Arrays
::
setVertexArray
(
InputArray
vertex
)
void
cv
::
ogl
::
Arrays
::
setVertexArray
(
InputArray
vertex
)
{
const
int
cn
=
vertex
.
channels
();
const
int
depth
=
vertex
.
depth
();
...
...
@@ -1250,37 +1250,37 @@ void cv::GlArrays::setVertexArray(InputArray vertex)
CV_Assert
(
depth
==
CV_16S
||
depth
==
CV_32S
||
depth
==
CV_32F
||
depth
==
CV_64F
);
if
(
vertex
.
kind
()
==
_InputArray
::
OPENGL_BUFFER
)
vertex_
=
vertex
.
getGlBuffer
();
vertex_
=
vertex
.
get
O
GlBuffer
();
else
vertex_
.
copyFrom
(
vertex
);
size_
=
vertex_
.
size
().
area
();
}
void
cv
::
Gl
Arrays
::
resetVertexArray
()
void
cv
::
ogl
::
Arrays
::
resetVertexArray
()
{
vertex_
.
release
();
size_
=
0
;
}
void
cv
::
Gl
Arrays
::
setColorArray
(
InputArray
color
)
void
cv
::
ogl
::
Arrays
::
setColorArray
(
InputArray
color
)
{
const
int
cn
=
color
.
channels
();
CV_Assert
(
cn
==
3
||
cn
==
4
);
if
(
color
.
kind
()
==
_InputArray
::
OPENGL_BUFFER
)
color_
=
color
.
getGlBuffer
();
color_
=
color
.
get
O
GlBuffer
();
else
color_
.
copyFrom
(
color
);
}
void
cv
::
Gl
Arrays
::
resetColorArray
()
void
cv
::
ogl
::
Arrays
::
resetColorArray
()
{
color_
.
release
();
}
void
cv
::
Gl
Arrays
::
setNormalArray
(
InputArray
normal
)
void
cv
::
ogl
::
Arrays
::
setNormalArray
(
InputArray
normal
)
{
const
int
cn
=
normal
.
channels
();
const
int
depth
=
normal
.
depth
();
...
...
@@ -1289,17 +1289,17 @@ void cv::GlArrays::setNormalArray(InputArray normal)
CV_Assert
(
depth
==
CV_8S
||
depth
==
CV_16S
||
depth
==
CV_32S
||
depth
==
CV_32F
||
depth
==
CV_64F
);
if
(
normal
.
kind
()
==
_InputArray
::
OPENGL_BUFFER
)
normal_
=
normal
.
getGlBuffer
();
normal_
=
normal
.
get
O
GlBuffer
();
else
normal_
.
copyFrom
(
normal
);
}
void
cv
::
Gl
Arrays
::
resetNormalArray
()
void
cv
::
ogl
::
Arrays
::
resetNormalArray
()
{
normal_
.
release
();
}
void
cv
::
Gl
Arrays
::
setTexCoordArray
(
InputArray
texCoord
)
void
cv
::
ogl
::
Arrays
::
setTexCoordArray
(
InputArray
texCoord
)
{
const
int
cn
=
texCoord
.
channels
();
const
int
depth
=
texCoord
.
depth
();
...
...
@@ -1308,17 +1308,17 @@ void cv::GlArrays::setTexCoordArray(InputArray texCoord)
CV_Assert
(
depth
==
CV_16S
||
depth
==
CV_32S
||
depth
==
CV_32F
||
depth
==
CV_64F
);
if
(
texCoord
.
kind
()
==
_InputArray
::
OPENGL_BUFFER
)
texCoord_
=
texCoord
.
getGlBuffer
();
texCoord_
=
texCoord
.
get
O
GlBuffer
();
else
texCoord_
.
copyFrom
(
texCoord
);
}
void
cv
::
Gl
Arrays
::
resetTexCoordArray
()
void
cv
::
ogl
::
Arrays
::
resetTexCoordArray
()
{
texCoord_
.
release
();
}
void
cv
::
Gl
Arrays
::
release
()
void
cv
::
ogl
::
Arrays
::
release
()
{
resetVertexArray
();
resetColorArray
();
...
...
@@ -1326,7 +1326,7 @@ void cv::GlArrays::release()
resetTexCoordArray
();
}
void
cv
::
Gl
Arrays
::
setAutoRelease
(
bool
flag
)
void
cv
::
ogl
::
Arrays
::
setAutoRelease
(
bool
flag
)
{
vertex_
.
setAutoRelease
(
flag
);
color_
.
setAutoRelease
(
flag
);
...
...
@@ -1334,7 +1334,7 @@ void cv::GlArrays::setAutoRelease(bool flag)
texCoord_
.
setAutoRelease
(
flag
);
}
void
cv
::
Gl
Arrays
::
bind
()
const
void
cv
::
ogl
::
Arrays
::
bind
()
const
{
#ifndef HAVE_OPENGL
throw_nogl
();
...
...
@@ -1353,7 +1353,7 @@ void cv::GlArrays::bind() const
gl
::
EnableClientState
(
gl
::
TEXTURE_COORD_ARRAY
);
CV_CheckGlError
();
texCoord_
.
bind
(
Gl
Buffer
::
ARRAY_BUFFER
);
texCoord_
.
bind
(
ogl
::
Buffer
::
ARRAY_BUFFER
);
gl
::
TexCoordPointer
(
texCoord_
.
channels
(),
gl_types
[
texCoord_
.
depth
()],
0
,
0
);
CV_CheckGlError
();
...
...
@@ -1369,7 +1369,7 @@ void cv::GlArrays::bind() const
gl
::
EnableClientState
(
gl
::
NORMAL_ARRAY
);
CV_CheckGlError
();
normal_
.
bind
(
Gl
Buffer
::
ARRAY_BUFFER
);
normal_
.
bind
(
ogl
::
Buffer
::
ARRAY_BUFFER
);
gl
::
NormalPointer
(
gl_types
[
normal_
.
depth
()],
0
,
0
);
CV_CheckGlError
();
...
...
@@ -1385,7 +1385,7 @@ void cv::GlArrays::bind() const
gl
::
EnableClientState
(
gl
::
COLOR_ARRAY
);
CV_CheckGlError
();
color_
.
bind
(
Gl
Buffer
::
ARRAY_BUFFER
);
color_
.
bind
(
ogl
::
Buffer
::
ARRAY_BUFFER
);
const
int
cn
=
color_
.
channels
();
...
...
@@ -1403,20 +1403,20 @@ void cv::GlArrays::bind() const
gl
::
EnableClientState
(
gl
::
VERTEX_ARRAY
);
CV_CheckGlError
();
vertex_
.
bind
(
Gl
Buffer
::
ARRAY_BUFFER
);
vertex_
.
bind
(
ogl
::
Buffer
::
ARRAY_BUFFER
);
gl
::
VertexPointer
(
vertex_
.
channels
(),
gl_types
[
vertex_
.
depth
()],
0
,
0
);
CV_CheckGlError
();
}
GlBuffer
::
unbind
(
Gl
Buffer
::
ARRAY_BUFFER
);
ogl
::
Buffer
::
unbind
(
ogl
::
Buffer
::
ARRAY_BUFFER
);
#endif
}
////////////////////////////////////////////////////////////////////////
// Rendering
void
cv
::
render
(
const
GlTexture
&
tex
,
Rect_
<
double
>
wndRect
,
Rect_
<
double
>
texRect
)
void
cv
::
ogl
::
render
(
const
ogl
::
Texture2D
&
tex
,
Rect_
<
double
>
wndRect
,
Rect_
<
double
>
texRect
)
{
#ifndef HAVE_OPENGL
(
void
)
tex
;
...
...
@@ -1464,7 +1464,7 @@ void cv::render(const GlTexture& tex, Rect_<double> wndRect, Rect_<double> texRe
texRect
.
x
+
texRect
.
width
,
texRect
.
y
};
GlBuffer
::
unbind
(
Gl
Buffer
::
ARRAY_BUFFER
);
ogl
::
Buffer
::
unbind
(
ogl
::
Buffer
::
ARRAY_BUFFER
);
gl
::
EnableClientState
(
gl
::
TEXTURE_COORD_ARRAY
);
CV_CheckGlError
();
...
...
@@ -1482,13 +1482,13 @@ void cv::render(const GlTexture& tex, Rect_<double> wndRect, Rect_<double> texRe
gl
::
VertexPointer
(
3
,
gl
::
FLOAT
,
0
,
vertex
);
CV_CheckGlError
();
gl
::
DrawArrays
(
cv
::
RenderMode
::
QUADS
,
0
,
4
);
gl
::
DrawArrays
(
gl
::
QUADS
,
0
,
4
);
CV_CheckGlError
();
}
#endif
}
void
cv
::
render
(
const
Gl
Arrays
&
arr
,
int
mode
,
Scalar
color
)
void
cv
::
ogl
::
render
(
const
ogl
::
Arrays
&
arr
,
int
mode
,
Scalar
color
)
{
#ifndef HAVE_OPENGL
(
void
)
arr
;
...
...
@@ -1507,7 +1507,7 @@ void cv::render(const GlArrays& arr, int mode, Scalar color)
#endif
}
void
cv
::
render
(
const
Gl
Arrays
&
arr
,
InputArray
indices
,
int
mode
,
Scalar
color
)
void
cv
::
ogl
::
render
(
const
ogl
::
Arrays
&
arr
,
InputArray
indices
,
int
mode
,
Scalar
color
)
{
#ifndef HAVE_OPENGL
(
void
)
arr
;
...
...
@@ -1528,7 +1528,7 @@ void cv::render(const GlArrays& arr, InputArray indices, int mode, Scalar color)
{
case
_InputArray
:
:
OPENGL_BUFFER
:
{
GlBuffer
buf
=
indices
.
get
GlBuffer
();
ogl
::
Buffer
buf
=
indices
.
getO
GlBuffer
();
const
int
depth
=
buf
.
depth
();
...
...
@@ -1543,11 +1543,11 @@ void cv::render(const GlArrays& arr, InputArray indices, int mode, Scalar color)
else
type
=
gl
::
UNSIGNED_INT
;
buf
.
bind
(
Gl
Buffer
::
ELEMENT_ARRAY_BUFFER
);
buf
.
bind
(
ogl
::
Buffer
::
ELEMENT_ARRAY_BUFFER
);
gl
::
DrawElements
(
mode
,
buf
.
size
().
area
(),
type
,
0
);
GlBuffer
::
unbind
(
Gl
Buffer
::
ELEMENT_ARRAY_BUFFER
);
ogl
::
Buffer
::
unbind
(
ogl
::
Buffer
::
ELEMENT_ARRAY_BUFFER
);
break
;
}
...
...
@@ -1570,7 +1570,7 @@ void cv::render(const GlArrays& arr, InputArray indices, int mode, Scalar color)
else
type
=
gl
::
UNSIGNED_INT
;
GlBuffer
::
unbind
(
Gl
Buffer
::
ELEMENT_ARRAY_BUFFER
);
ogl
::
Buffer
::
unbind
(
ogl
::
Buffer
::
ELEMENT_ARRAY_BUFFER
);
gl
::
DrawElements
(
mode
,
mat
.
size
().
area
(),
type
,
mat
.
data
);
}
...
...
modules/core/src/opengl_interop_deprecated.cpp
0 → 100644
View file @
a938534a
/*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
;
}
modules/gpu/test/test_opengl.cpp
View file @
a938534a
...
...
@@ -44,9 +44,9 @@
#if defined(HAVE_CUDA) && defined(HAVE_OPENGL)
/////////////////////////////////////////////
//
Gl
Buffer
// Buffer
PARAM_TEST_CASE
(
Gl
Buffer
,
cv
::
Size
,
MatType
)
PARAM_TEST_CASE
(
Buffer
,
cv
::
Size
,
MatType
)
{
static
void
SetUpTestCase
()
{
...
...
@@ -68,29 +68,29 @@ PARAM_TEST_CASE(GlBuffer, cv::Size, MatType)
}
};
GPU_TEST_P
(
Gl
Buffer
,
Constructor1
)
GPU_TEST_P
(
Buffer
,
Constructor1
)
{
cv
::
GlBuffer
buf
(
size
.
height
,
size
.
width
,
type
,
cv
::
Gl
Buffer
::
ARRAY_BUFFER
,
true
);
cv
::
ogl
::
Buffer
buf
(
size
.
height
,
size
.
width
,
type
,
cv
::
ogl
::
Buffer
::
ARRAY_BUFFER
,
true
);
EXPECT_EQ
(
size
.
height
,
buf
.
rows
());
EXPECT_EQ
(
size
.
width
,
buf
.
cols
());
EXPECT_EQ
(
type
,
buf
.
type
());
}
GPU_TEST_P
(
Gl
Buffer
,
Constructor2
)
GPU_TEST_P
(
Buffer
,
Constructor2
)
{
cv
::
GlBuffer
buf
(
size
,
type
,
cv
::
Gl
Buffer
::
ARRAY_BUFFER
,
true
);
cv
::
ogl
::
Buffer
buf
(
size
,
type
,
cv
::
ogl
::
Buffer
::
ARRAY_BUFFER
,
true
);
EXPECT_EQ
(
size
.
height
,
buf
.
rows
());
EXPECT_EQ
(
size
.
width
,
buf
.
cols
());
EXPECT_EQ
(
type
,
buf
.
type
());
}
GPU_TEST_P
(
Gl
Buffer
,
ConstructorFromMat
)
GPU_TEST_P
(
Buffer
,
ConstructorFromMat
)
{
cv
::
Mat
gold
=
randomMat
(
size
,
type
);
cv
::
GlBuffer
buf
(
gold
,
cv
::
Gl
Buffer
::
ARRAY_BUFFER
,
true
);
cv
::
ogl
::
Buffer
buf
(
gold
,
cv
::
ogl
::
Buffer
::
ARRAY_BUFFER
,
true
);
cv
::
Mat
bufData
;
buf
.
copyTo
(
bufData
);
...
...
@@ -98,12 +98,12 @@ GPU_TEST_P(GlBuffer, ConstructorFromMat)
EXPECT_MAT_NEAR
(
gold
,
bufData
,
0
);
}
GPU_TEST_P
(
Gl
Buffer
,
ConstructorFromGpuMat
)
GPU_TEST_P
(
Buffer
,
ConstructorFromGpuMat
)
{
cv
::
Mat
gold
=
randomMat
(
size
,
type
);
cv
::
gpu
::
GpuMat
d_gold
(
gold
);
cv
::
GlBuffer
buf
(
d_gold
,
cv
::
Gl
Buffer
::
ARRAY_BUFFER
);
cv
::
ogl
::
Buffer
buf
(
d_gold
,
cv
::
ogl
::
Buffer
::
ARRAY_BUFFER
);
cv
::
Mat
bufData
;
buf
.
copyTo
(
bufData
);
...
...
@@ -111,11 +111,11 @@ GPU_TEST_P(GlBuffer, ConstructorFromGpuMat)
EXPECT_MAT_NEAR
(
gold
,
bufData
,
0
);
}
GPU_TEST_P
(
GlBuffer
,
ConstructorFromGl
Buffer
)
GPU_TEST_P
(
Buffer
,
ConstructorFrom
Buffer
)
{
cv
::
GlBuffer
buf_gold
(
size
,
type
,
cv
::
Gl
Buffer
::
ARRAY_BUFFER
,
true
);
cv
::
ogl
::
Buffer
buf_gold
(
size
,
type
,
cv
::
ogl
::
Buffer
::
ARRAY_BUFFER
,
true
);
cv
::
Gl
Buffer
buf
(
buf_gold
);
cv
::
ogl
::
Buffer
buf
(
buf_gold
);
EXPECT_EQ
(
buf_gold
.
bufId
(),
buf
.
bufId
());
EXPECT_EQ
(
buf_gold
.
rows
(),
buf
.
rows
());
...
...
@@ -123,7 +123,7 @@ GPU_TEST_P(GlBuffer, ConstructorFromGlBuffer)
EXPECT_EQ
(
buf_gold
.
type
(),
buf
.
type
());
}
GPU_TEST_P
(
GlBuffer
,
ConstructorFromGlTexture
)
GPU_TEST_P
(
Buffer
,
ConstructorFromTexture2D
)
{
const
int
depth
=
CV_MAT_DEPTH
(
type
);
const
int
cn
=
CV_MAT_CN
(
type
);
...
...
@@ -132,9 +132,9 @@ GPU_TEST_P(GlBuffer, ConstructorFromGlTexture)
return
;
cv
::
Mat
gold
=
randomMat
(
size
,
type
,
0
,
1.0
);
cv
::
GlTexture
tex_gold
(
gold
,
true
);
cv
::
ogl
::
Texture2D
tex_gold
(
gold
,
true
);
cv
::
GlBuffer
buf
(
tex_gold
,
cv
::
Gl
Buffer
::
PIXEL_PACK_BUFFER
,
true
);
cv
::
ogl
::
Buffer
buf
(
tex_gold
,
cv
::
ogl
::
Buffer
::
PIXEL_PACK_BUFFER
,
true
);
cv
::
Mat
bufData
;
buf
.
copyTo
(
bufData
);
...
...
@@ -142,22 +142,22 @@ GPU_TEST_P(GlBuffer, ConstructorFromGlTexture)
EXPECT_MAT_NEAR
(
gold
,
bufData
,
1e-2
);
}
GPU_TEST_P
(
Gl
Buffer
,
Create
)
GPU_TEST_P
(
Buffer
,
Create
)
{
cv
::
Gl
Buffer
buf
;
buf
.
create
(
size
.
height
,
size
.
width
,
type
,
cv
::
Gl
Buffer
::
ARRAY_BUFFER
,
true
);
cv
::
ogl
::
Buffer
buf
;
buf
.
create
(
size
.
height
,
size
.
width
,
type
,
cv
::
ogl
::
Buffer
::
ARRAY_BUFFER
,
true
);
EXPECT_EQ
(
size
.
height
,
buf
.
rows
());
EXPECT_EQ
(
size
.
width
,
buf
.
cols
());
EXPECT_EQ
(
type
,
buf
.
type
());
}
GPU_TEST_P
(
Gl
Buffer
,
CopyFromMat
)
GPU_TEST_P
(
Buffer
,
CopyFromMat
)
{
cv
::
Mat
gold
=
randomMat
(
size
,
type
);
cv
::
Gl
Buffer
buf
;
buf
.
copyFrom
(
gold
,
cv
::
Gl
Buffer
::
ARRAY_BUFFER
,
true
);
cv
::
ogl
::
Buffer
buf
;
buf
.
copyFrom
(
gold
,
cv
::
ogl
::
Buffer
::
ARRAY_BUFFER
,
true
);
cv
::
Mat
bufData
;
buf
.
copyTo
(
bufData
);
...
...
@@ -165,13 +165,13 @@ GPU_TEST_P(GlBuffer, CopyFromMat)
EXPECT_MAT_NEAR
(
gold
,
bufData
,
0
);
}
GPU_TEST_P
(
Gl
Buffer
,
CopyFromGpuMat
)
GPU_TEST_P
(
Buffer
,
CopyFromGpuMat
)
{
cv
::
Mat
gold
=
randomMat
(
size
,
type
);
cv
::
gpu
::
GpuMat
d_gold
(
gold
);
cv
::
Gl
Buffer
buf
;
buf
.
copyFrom
(
d_gold
,
cv
::
Gl
Buffer
::
ARRAY_BUFFER
,
true
);
cv
::
ogl
::
Buffer
buf
;
buf
.
copyFrom
(
d_gold
,
cv
::
ogl
::
Buffer
::
ARRAY_BUFFER
,
true
);
cv
::
Mat
bufData
;
buf
.
copyTo
(
bufData
);
...
...
@@ -179,13 +179,13 @@ GPU_TEST_P(GlBuffer, CopyFromGpuMat)
EXPECT_MAT_NEAR
(
gold
,
bufData
,
0
);
}
GPU_TEST_P
(
GlBuffer
,
CopyFromGl
Buffer
)
GPU_TEST_P
(
Buffer
,
CopyFrom
Buffer
)
{
cv
::
Mat
gold
=
randomMat
(
size
,
type
);
cv
::
GlBuffer
buf_gold
(
gold
,
cv
::
Gl
Buffer
::
ARRAY_BUFFER
,
true
);
cv
::
ogl
::
Buffer
buf_gold
(
gold
,
cv
::
ogl
::
Buffer
::
ARRAY_BUFFER
,
true
);
cv
::
Gl
Buffer
buf
;
buf
.
copyFrom
(
buf_gold
,
cv
::
Gl
Buffer
::
ARRAY_BUFFER
,
true
);
cv
::
ogl
::
Buffer
buf
;
buf
.
copyFrom
(
buf_gold
,
cv
::
ogl
::
Buffer
::
ARRAY_BUFFER
,
true
);
EXPECT_NE
(
buf_gold
.
bufId
(),
buf
.
bufId
());
...
...
@@ -195,7 +195,7 @@ GPU_TEST_P(GlBuffer, CopyFromGlBuffer)
EXPECT_MAT_NEAR
(
gold
,
bufData
,
0
);
}
GPU_TEST_P
(
GlBuffer
,
CopyFromGlTexture
)
GPU_TEST_P
(
Buffer
,
CopyFromTexture2D
)
{
const
int
depth
=
CV_MAT_DEPTH
(
type
);
const
int
cn
=
CV_MAT_CN
(
type
);
...
...
@@ -204,10 +204,10 @@ GPU_TEST_P(GlBuffer, CopyFromGlTexture)
return
;
cv
::
Mat
gold
=
randomMat
(
size
,
type
,
0
,
1.0
);
cv
::
GlTexture
tex_gold
(
gold
,
true
);
cv
::
ogl
::
Texture2D
tex_gold
(
gold
,
true
);
cv
::
Gl
Buffer
buf
;
buf
.
copyFrom
(
tex_gold
,
cv
::
Gl
Buffer
::
ARRAY_BUFFER
,
true
);
cv
::
ogl
::
Buffer
buf
;
buf
.
copyFrom
(
tex_gold
,
cv
::
ogl
::
Buffer
::
ARRAY_BUFFER
,
true
);
cv
::
Mat
bufData
;
buf
.
copyTo
(
bufData
);
...
...
@@ -215,11 +215,11 @@ GPU_TEST_P(GlBuffer, CopyFromGlTexture)
EXPECT_MAT_NEAR
(
gold
,
bufData
,
1e-2
);
}
GPU_TEST_P
(
Gl
Buffer
,
CopyToGpuMat
)
GPU_TEST_P
(
Buffer
,
CopyToGpuMat
)
{
cv
::
Mat
gold
=
randomMat
(
size
,
type
);
cv
::
GlBuffer
buf
(
gold
,
cv
::
Gl
Buffer
::
ARRAY_BUFFER
,
true
);
cv
::
ogl
::
Buffer
buf
(
gold
,
cv
::
ogl
::
Buffer
::
ARRAY_BUFFER
,
true
);
cv
::
gpu
::
GpuMat
dst
;
buf
.
copyTo
(
dst
);
...
...
@@ -227,14 +227,14 @@ GPU_TEST_P(GlBuffer, CopyToGpuMat)
EXPECT_MAT_NEAR
(
gold
,
dst
,
0
);
}
GPU_TEST_P
(
GlBuffer
,
CopyToGl
Buffer
)
GPU_TEST_P
(
Buffer
,
CopyTo
Buffer
)
{
cv
::
Mat
gold
=
randomMat
(
size
,
type
);
cv
::
GlBuffer
buf
(
gold
,
cv
::
Gl
Buffer
::
ARRAY_BUFFER
,
true
);
cv
::
ogl
::
Buffer
buf
(
gold
,
cv
::
ogl
::
Buffer
::
ARRAY_BUFFER
,
true
);
cv
::
Gl
Buffer
dst
;
buf
.
copyTo
(
dst
,
cv
::
Gl
Buffer
::
ARRAY_BUFFER
,
true
);
cv
::
ogl
::
Buffer
dst
;
buf
.
copyTo
(
dst
,
cv
::
ogl
::
Buffer
::
ARRAY_BUFFER
,
true
);
EXPECT_NE
(
buf
.
bufId
(),
dst
.
bufId
());
...
...
@@ -244,7 +244,7 @@ GPU_TEST_P(GlBuffer, CopyToGlBuffer)
EXPECT_MAT_NEAR
(
gold
,
bufData
,
0
);
}
GPU_TEST_P
(
GlBuffer
,
CopyToGlTexture
)
GPU_TEST_P
(
Buffer
,
CopyToTexture2D
)
{
const
int
depth
=
CV_MAT_DEPTH
(
type
);
const
int
cn
=
CV_MAT_CN
(
type
);
...
...
@@ -254,10 +254,10 @@ GPU_TEST_P(GlBuffer, CopyToGlTexture)
cv
::
Mat
gold
=
randomMat
(
size
,
type
,
0
,
1.0
);
cv
::
GlBuffer
buf
(
gold
,
cv
::
Gl
Buffer
::
PIXEL_PACK_BUFFER
,
true
);
cv
::
ogl
::
Buffer
buf
(
gold
,
cv
::
ogl
::
Buffer
::
PIXEL_PACK_BUFFER
,
true
);
cv
::
GlTexture
tex
;
buf
.
copyTo
(
tex
,
cv
::
Gl
Buffer
::
PIXEL_PACK_BUFFER
,
true
);
cv
::
ogl
::
Texture2D
tex
;
buf
.
copyTo
(
tex
,
cv
::
ogl
::
Buffer
::
PIXEL_PACK_BUFFER
,
true
);
cv
::
Mat
texData
;
tex
.
copyTo
(
texData
);
...
...
@@ -265,13 +265,13 @@ GPU_TEST_P(GlBuffer, CopyToGlTexture)
EXPECT_MAT_NEAR
(
gold
,
texData
,
1e-2
);
}
GPU_TEST_P
(
Gl
Buffer
,
Clone
)
GPU_TEST_P
(
Buffer
,
Clone
)
{
cv
::
Mat
gold
=
randomMat
(
size
,
type
);
cv
::
GlBuffer
buf
(
gold
,
cv
::
Gl
Buffer
::
ARRAY_BUFFER
,
true
);
cv
::
ogl
::
Buffer
buf
(
gold
,
cv
::
ogl
::
Buffer
::
ARRAY_BUFFER
,
true
);
cv
::
GlBuffer
dst
=
buf
.
clone
(
cv
::
Gl
Buffer
::
ARRAY_BUFFER
,
true
);
cv
::
ogl
::
Buffer
dst
=
buf
.
clone
(
cv
::
ogl
::
Buffer
::
ARRAY_BUFFER
,
true
);
EXPECT_NE
(
buf
.
bufId
(),
dst
.
bufId
());
...
...
@@ -281,26 +281,26 @@ GPU_TEST_P(GlBuffer, Clone)
EXPECT_MAT_NEAR
(
gold
,
bufData
,
0
);
}
GPU_TEST_P
(
Gl
Buffer
,
MapHostRead
)
GPU_TEST_P
(
Buffer
,
MapHostRead
)
{
cv
::
Mat
gold
=
randomMat
(
size
,
type
);
cv
::
GlBuffer
buf
(
gold
,
cv
::
Gl
Buffer
::
ARRAY_BUFFER
,
true
);
cv
::
ogl
::
Buffer
buf
(
gold
,
cv
::
ogl
::
Buffer
::
ARRAY_BUFFER
,
true
);
cv
::
Mat
dst
=
buf
.
mapHost
(
cv
::
Gl
Buffer
::
READ_ONLY
);
cv
::
Mat
dst
=
buf
.
mapHost
(
cv
::
ogl
::
Buffer
::
READ_ONLY
);
EXPECT_MAT_NEAR
(
gold
,
dst
,
0
);
buf
.
unmapHost
();
}
GPU_TEST_P
(
Gl
Buffer
,
MapHostWrite
)
GPU_TEST_P
(
Buffer
,
MapHostWrite
)
{
cv
::
Mat
gold
=
randomMat
(
size
,
type
);
cv
::
GlBuffer
buf
(
size
,
type
,
cv
::
Gl
Buffer
::
ARRAY_BUFFER
,
true
);
cv
::
ogl
::
Buffer
buf
(
size
,
type
,
cv
::
ogl
::
Buffer
::
ARRAY_BUFFER
,
true
);
cv
::
Mat
dst
=
buf
.
mapHost
(
cv
::
Gl
Buffer
::
WRITE_ONLY
);
cv
::
Mat
dst
=
buf
.
mapHost
(
cv
::
ogl
::
Buffer
::
WRITE_ONLY
);
gold
.
copyTo
(
dst
);
buf
.
unmapHost
();
dst
.
release
();
...
...
@@ -311,11 +311,11 @@ GPU_TEST_P(GlBuffer, MapHostWrite)
EXPECT_MAT_NEAR
(
gold
,
bufData
,
0
);
}
GPU_TEST_P
(
Gl
Buffer
,
MapDevice
)
GPU_TEST_P
(
Buffer
,
MapDevice
)
{
cv
::
Mat
gold
=
randomMat
(
size
,
type
);
cv
::
GlBuffer
buf
(
gold
,
cv
::
Gl
Buffer
::
ARRAY_BUFFER
,
true
);
cv
::
ogl
::
Buffer
buf
(
gold
,
cv
::
ogl
::
Buffer
::
ARRAY_BUFFER
,
true
);
cv
::
gpu
::
GpuMat
dst
=
buf
.
mapDevice
();
...
...
@@ -324,12 +324,12 @@ GPU_TEST_P(GlBuffer, MapDevice)
buf
.
unmapDevice
();
}
INSTANTIATE_TEST_CASE_P
(
OpenGL
,
Gl
Buffer
,
testing
::
Combine
(
DIFFERENT_SIZES
,
ALL_TYPES
));
INSTANTIATE_TEST_CASE_P
(
OpenGL
,
Buffer
,
testing
::
Combine
(
DIFFERENT_SIZES
,
ALL_TYPES
));
/////////////////////////////////////////////
//
GlTexture
//
Texture2D
PARAM_TEST_CASE
(
GlTexture
,
cv
::
Size
,
MatType
)
PARAM_TEST_CASE
(
Texture2D
,
cv
::
Size
,
MatType
)
{
static
void
SetUpTestCase
()
{
...
...
@@ -345,7 +345,7 @@ PARAM_TEST_CASE(GlTexture, cv::Size, MatType)
int
type
;
int
depth
;
int
cn
;
cv
::
GlTexture
::
Format
format
;
cv
::
ogl
::
Texture2D
::
Format
format
;
virtual
void
SetUp
()
{
...
...
@@ -354,33 +354,33 @@ PARAM_TEST_CASE(GlTexture, cv::Size, MatType)
depth
=
CV_MAT_DEPTH
(
type
);
cn
=
CV_MAT_CN
(
type
);
format
=
cn
==
1
?
cv
::
GlTexture
::
DEPTH_COMPONENT
:
cn
==
3
?
cv
::
GlTexture
::
RGB
:
cn
==
4
?
cv
::
GlTexture
::
RGBA
:
cv
::
GlTexture
::
NONE
;
format
=
cn
==
1
?
cv
::
ogl
::
Texture2D
::
DEPTH_COMPONENT
:
cn
==
3
?
cv
::
ogl
::
Texture2D
::
RGB
:
cn
==
4
?
cv
::
ogl
::
Texture2D
::
RGBA
:
cv
::
ogl
::
Texture2D
::
NONE
;
}
};
GPU_TEST_P
(
GlTexture
,
Constructor1
)
GPU_TEST_P
(
Texture2D
,
Constructor1
)
{
cv
::
GlTexture
tex
(
size
.
height
,
size
.
width
,
format
,
true
);
cv
::
ogl
::
Texture2D
tex
(
size
.
height
,
size
.
width
,
format
,
true
);
EXPECT_EQ
(
size
.
height
,
tex
.
rows
());
EXPECT_EQ
(
size
.
width
,
tex
.
cols
());
EXPECT_EQ
(
format
,
tex
.
format
());
}
GPU_TEST_P
(
GlTexture
,
Constructor2
)
GPU_TEST_P
(
Texture2D
,
Constructor2
)
{
cv
::
GlTexture
tex
(
size
,
format
,
true
);
cv
::
ogl
::
Texture2D
tex
(
size
,
format
,
true
);
EXPECT_EQ
(
size
.
height
,
tex
.
rows
());
EXPECT_EQ
(
size
.
width
,
tex
.
cols
());
EXPECT_EQ
(
format
,
tex
.
format
());
}
GPU_TEST_P
(
GlTexture
,
ConstructorFromMat
)
GPU_TEST_P
(
Texture2D
,
ConstructorFromMat
)
{
cv
::
Mat
gold
=
randomMat
(
size
,
type
,
0
,
depth
==
CV_8U
?
255
:
1
);
cv
::
GlTexture
tex
(
gold
,
true
);
cv
::
ogl
::
Texture2D
tex
(
gold
,
true
);
cv
::
Mat
texData
;
tex
.
copyTo
(
texData
,
depth
);
...
...
@@ -388,12 +388,12 @@ GPU_TEST_P(GlTexture, ConstructorFromMat)
EXPECT_MAT_NEAR
(
gold
,
texData
,
1e-2
);
}
GPU_TEST_P
(
GlTexture
,
ConstructorFromGpuMat
)
GPU_TEST_P
(
Texture2D
,
ConstructorFromGpuMat
)
{
cv
::
Mat
gold
=
randomMat
(
size
,
type
,
0
,
depth
==
CV_8U
?
255
:
1
);
cv
::
gpu
::
GpuMat
d_gold
(
gold
);
cv
::
GlTexture
tex
(
d_gold
,
true
);
cv
::
ogl
::
Texture2D
tex
(
d_gold
,
true
);
cv
::
Mat
texData
;
tex
.
copyTo
(
texData
,
depth
);
...
...
@@ -401,12 +401,12 @@ GPU_TEST_P(GlTexture, ConstructorFromGpuMat)
EXPECT_MAT_NEAR
(
gold
,
texData
,
1e-2
);
}
GPU_TEST_P
(
GlTexture
,
ConstructorFromGl
Buffer
)
GPU_TEST_P
(
Texture2D
,
ConstructorFrom
Buffer
)
{
cv
::
Mat
gold
=
randomMat
(
size
,
type
,
0
,
depth
==
CV_8U
?
255
:
1
);
cv
::
GlBuffer
buf_gold
(
gold
,
cv
::
Gl
Buffer
::
PIXEL_UNPACK_BUFFER
,
true
);
cv
::
ogl
::
Buffer
buf_gold
(
gold
,
cv
::
ogl
::
Buffer
::
PIXEL_UNPACK_BUFFER
,
true
);
cv
::
GlTexture
tex
(
buf_gold
,
true
);
cv
::
ogl
::
Texture2D
tex
(
buf_gold
,
true
);
cv
::
Mat
texData
;
tex
.
copyTo
(
texData
,
depth
);
...
...
@@ -414,10 +414,10 @@ GPU_TEST_P(GlTexture, ConstructorFromGlBuffer)
EXPECT_MAT_NEAR
(
gold
,
texData
,
1e-2
);
}
GPU_TEST_P
(
GlTexture
,
ConstructorFromGlTexture
)
GPU_TEST_P
(
Texture2D
,
ConstructorFromTexture2D
)
{
cv
::
GlTexture
tex_gold
(
size
,
format
,
true
);
cv
::
GlTexture
tex
(
tex_gold
);
cv
::
ogl
::
Texture2D
tex_gold
(
size
,
format
,
true
);
cv
::
ogl
::
Texture2D
tex
(
tex_gold
);
EXPECT_EQ
(
tex_gold
.
texId
(),
tex
.
texId
());
EXPECT_EQ
(
tex_gold
.
rows
(),
tex
.
rows
());
...
...
@@ -425,9 +425,9 @@ GPU_TEST_P(GlTexture, ConstructorFromGlTexture)
EXPECT_EQ
(
tex_gold
.
format
(),
tex
.
format
());
}
GPU_TEST_P
(
GlTexture
,
Create
)
GPU_TEST_P
(
Texture2D
,
Create
)
{
cv
::
GlTexture
tex
;
cv
::
ogl
::
Texture2D
tex
;
tex
.
create
(
size
.
height
,
size
.
width
,
format
,
true
);
EXPECT_EQ
(
size
.
height
,
tex
.
rows
());
...
...
@@ -435,11 +435,11 @@ GPU_TEST_P(GlTexture, Create)
EXPECT_EQ
(
format
,
tex
.
format
());
}
GPU_TEST_P
(
GlTexture
,
CopyFromMat
)
GPU_TEST_P
(
Texture2D
,
CopyFromMat
)
{
cv
::
Mat
gold
=
randomMat
(
size
,
type
,
0
,
depth
==
CV_8U
?
255
:
1
);
cv
::
GlTexture
tex
;
cv
::
ogl
::
Texture2D
tex
;
tex
.
copyFrom
(
gold
,
true
);
cv
::
Mat
texData
;
...
...
@@ -448,12 +448,12 @@ GPU_TEST_P(GlTexture, CopyFromMat)
EXPECT_MAT_NEAR
(
gold
,
texData
,
1e-2
);
}
GPU_TEST_P
(
GlTexture
,
CopyFromGpuMat
)
GPU_TEST_P
(
Texture2D
,
CopyFromGpuMat
)
{
cv
::
Mat
gold
=
randomMat
(
size
,
type
,
0
,
depth
==
CV_8U
?
255
:
1
);
cv
::
gpu
::
GpuMat
d_gold
(
gold
);
cv
::
GlTexture
tex
;
cv
::
ogl
::
Texture2D
tex
;
tex
.
copyFrom
(
d_gold
,
true
);
cv
::
Mat
texData
;
...
...
@@ -462,12 +462,12 @@ GPU_TEST_P(GlTexture, CopyFromGpuMat)
EXPECT_MAT_NEAR
(
gold
,
texData
,
1e-2
);
}
GPU_TEST_P
(
GlTexture
,
CopyFromGl
Buffer
)
GPU_TEST_P
(
Texture2D
,
CopyFrom
Buffer
)
{
cv
::
Mat
gold
=
randomMat
(
size
,
type
,
0
,
depth
==
CV_8U
?
255
:
1
);
cv
::
GlBuffer
buf_gold
(
gold
,
cv
::
Gl
Buffer
::
PIXEL_UNPACK_BUFFER
,
true
);
cv
::
ogl
::
Buffer
buf_gold
(
gold
,
cv
::
ogl
::
Buffer
::
PIXEL_UNPACK_BUFFER
,
true
);
cv
::
GlTexture
tex
;
cv
::
ogl
::
Texture2D
tex
;
tex
.
copyFrom
(
buf_gold
,
true
);
cv
::
Mat
texData
;
...
...
@@ -476,11 +476,11 @@ GPU_TEST_P(GlTexture, CopyFromGlBuffer)
EXPECT_MAT_NEAR
(
gold
,
texData
,
1e-2
);
}
GPU_TEST_P
(
GlTexture
,
CopyToGpuMat
)
GPU_TEST_P
(
Texture2D
,
CopyToGpuMat
)
{
cv
::
Mat
gold
=
randomMat
(
size
,
type
,
0
,
depth
==
CV_8U
?
255
:
1
);
cv
::
GlTexture
tex
(
gold
,
true
);
cv
::
ogl
::
Texture2D
tex
(
gold
,
true
);
cv
::
gpu
::
GpuMat
dst
;
tex
.
copyTo
(
dst
,
depth
);
...
...
@@ -488,13 +488,13 @@ GPU_TEST_P(GlTexture, CopyToGpuMat)
EXPECT_MAT_NEAR
(
gold
,
dst
,
1e-2
);
}
GPU_TEST_P
(
GlTexture
,
CopyToGl
Buffer
)
GPU_TEST_P
(
Texture2D
,
CopyTo
Buffer
)
{
cv
::
Mat
gold
=
randomMat
(
size
,
type
,
0
,
depth
==
CV_8U
?
255
:
1
);
cv
::
GlTexture
tex
(
gold
,
true
);
cv
::
ogl
::
Texture2D
tex
(
gold
,
true
);
cv
::
Gl
Buffer
dst
;
cv
::
ogl
::
Buffer
dst
;
tex
.
copyTo
(
dst
,
depth
,
true
);
cv
::
Mat
bufData
;
...
...
@@ -503,6 +503,6 @@ GPU_TEST_P(GlTexture, CopyToGlBuffer)
EXPECT_MAT_NEAR
(
gold
,
bufData
,
1e-2
);
}
INSTANTIATE_TEST_CASE_P
(
OpenGL
,
GlTexture
,
testing
::
Combine
(
DIFFERENT_SIZES
,
testing
::
Values
(
CV_8UC1
,
CV_8UC3
,
CV_8UC4
,
CV_32FC1
,
CV_32FC3
,
CV_32FC4
)));
INSTANTIATE_TEST_CASE_P
(
OpenGL
,
Texture2D
,
testing
::
Combine
(
DIFFERENT_SIZES
,
testing
::
Values
(
CV_8UC1
,
CV_8UC3
,
CV_8UC4
,
CV_32FC1
,
CV_32FC3
,
CV_32FC4
)));
#endif
modules/highgui/include/opencv2/highgui/highgui.hpp
View file @
a938534a
...
...
@@ -125,13 +125,18 @@ CV_EXPORTS_W void setTrackbarPos(const string& trackbarname, const string& winna
// OpenGL support
typedef
void
(
CV_CDECL
*
OpenGlDrawCallback
)(
void
*
userdata
);
typedef
void
(
*
OpenGlDrawCallback
)(
void
*
userdata
);
CV_EXPORTS
void
setOpenGlDrawCallback
(
const
string
&
winname
,
OpenGlDrawCallback
onOpenGlDraw
,
void
*
userdata
=
0
);
CV_EXPORTS
void
setOpenGlContext
(
const
string
&
winname
);
CV_EXPORTS
void
updateWindow
(
const
string
&
winname
);
// < Deperecated
CV_EXPORTS
void
pointCloudShow
(
const
string
&
winname
,
const
GlCamera
&
camera
,
const
GlArrays
&
arr
);
CV_EXPORTS
void
pointCloudShow
(
const
string
&
winname
,
const
GlCamera
&
camera
,
InputArray
points
,
InputArray
colors
=
noArray
());
// >
//Only for Qt
CV_EXPORTS
CvFont
fontQt
(
const
string
&
nameFont
,
int
pointSize
=-
1
,
...
...
modules/highgui/src/window.cpp
View file @
a938534a
...
...
@@ -241,15 +241,15 @@ void cv::updateWindow(const string& windowName)
#ifdef HAVE_OPENGL
namespace
{
std
::
map
<
std
::
string
,
cv
::
GlTexture
>
wndTexs
;
std
::
map
<
std
::
string
,
cv
::
GlTexture
>
ownWndTexs
;
std
::
map
<
std
::
string
,
cv
::
Gl
Buffer
>
ownWndBufs
;
std
::
map
<
std
::
string
,
cv
::
ogl
::
Texture2D
>
wndTexs
;
std
::
map
<
std
::
string
,
cv
::
ogl
::
Texture2D
>
ownWndTexs
;
std
::
map
<
std
::
string
,
cv
::
ogl
::
Buffer
>
ownWndBufs
;
void
CV_CDECL
glDrawTextureCallback
(
void
*
userdata
)
void
glDrawTextureCallback
(
void
*
userdata
)
{
cv
::
GlTexture
*
texObj
=
static_cast
<
cv
::
GlTexture
*>
(
userdata
);
cv
::
ogl
::
Texture2D
*
texObj
=
static_cast
<
cv
::
ogl
::
Texture2D
*>
(
userdata
);
cv
::
render
(
*
texObj
);
cv
::
ogl
::
render
(
*
texObj
);
}
}
#endif // HAVE_OPENGL
...
...
@@ -283,9 +283,9 @@ void cv::imshow( const string& winname, InputArray _img )
if
(
_img
.
kind
()
==
_InputArray
::
OPENGL_TEXTURE
)
{
cv
::
GlTexture
&
tex
=
wndTexs
[
winname
];
cv
::
ogl
::
Texture2D
&
tex
=
wndTexs
[
winname
];
tex
=
_img
.
get
GlTexture
();
tex
=
_img
.
get
OGlTexture2D
();
tex
.
setAutoRelease
(
false
);
...
...
@@ -293,11 +293,11 @@ void cv::imshow( const string& winname, InputArray _img )
}
else
{
cv
::
GlTexture
&
tex
=
ownWndTexs
[
winname
];
cv
::
ogl
::
Texture2D
&
tex
=
ownWndTexs
[
winname
];
if
(
_img
.
kind
()
==
_InputArray
::
GPU_MAT
)
{
cv
::
Gl
Buffer
&
buf
=
ownWndBufs
[
winname
];
cv
::
ogl
::
Buffer
&
buf
=
ownWndBufs
[
winname
];
buf
.
copyFrom
(
_img
);
buf
.
setAutoRelease
(
false
);
...
...
@@ -319,6 +319,16 @@ void cv::imshow( const string& winname, InputArray _img )
#endif
}
void
cv
::
pointCloudShow
(
const
string
&
,
const
GlCamera
&
,
const
GlArrays
&
)
{
CV_Error
(
CV_StsNotImplemented
,
"This function in deprecated, do not use it"
);
}
void
cv
::
pointCloudShow
(
const
string
&
,
const
GlCamera
&
,
InputArray
,
InputArray
)
{
CV_Error
(
CV_StsNotImplemented
,
"This function in deprecated, do not use it"
);
}
// Without OpenGL
#ifndef HAVE_OPENGL
...
...
samples/gpu/opengl.cpp
View file @
a938534a
...
...
@@ -37,39 +37,20 @@ const int win_height = 640;
struct
DrawData
{
Gl
Arrays
arr
;
GlTexture
tex
;
Gl
Buffer
indices
;
ogl
::
Arrays
arr
;
ogl
::
Texture2D
tex
;
ogl
::
Buffer
indices
;
};
void
CV_CDECL
draw
(
void
*
userdata
);
void
draw
(
void
*
userdata
);
void
CV_CDECL
draw
(
void
*
userdata
)
void
draw
(
void
*
userdata
)
{
static
double
angle
=
0.0
;
DrawData
*
data
=
static_cast
<
DrawData
*>
(
userdata
);
glMatrixMode
(
GL_PROJECTION
);
glLoadIdentity
();
gluPerspective
(
45.0
,
(
double
)
win_width
/
win_height
,
0.1
,
100.0
);
glMatrixMode
(
GL_MODELVIEW
);
glLoadIdentity
();
gluLookAt
(
0
,
0
,
3
,
0
,
0
,
0
,
0
,
1
,
0
);
glRotated
(
angle
,
0
,
1
,
0
);
glEnable
(
GL_TEXTURE_2D
);
data
->
tex
.
bind
();
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MIN_FILTER
,
GL_LINEAR
);
glTexEnvi
(
GL_TEXTURE_2D
,
GL_TEXTURE_ENV_MODE
,
GL_REPLACE
);
glDisable
(
GL_CULL_FACE
);
render
(
data
->
arr
,
data
->
indices
,
RenderMode
::
TRIANGLES
);
glRotated
(
0.6
,
0
,
1
,
0
);
angle
+=
0.3
;
ogl
::
render
(
data
->
arr
,
data
->
indices
,
ogl
::
TRIANGLES
)
;
}
int
main
(
int
argc
,
char
*
argv
[])
...
...
@@ -106,12 +87,28 @@ int main(int argc, char* argv[])
data
.
indices
.
copyFrom
(
indices
);
data
.
tex
.
copyFrom
(
img
);
glMatrixMode
(
GL_PROJECTION
);
glLoadIdentity
();
gluPerspective
(
45.0
,
(
double
)
win_width
/
win_height
,
0.1
,
100.0
);
glMatrixMode
(
GL_MODELVIEW
);
glLoadIdentity
();
gluLookAt
(
0
,
0
,
3
,
0
,
0
,
0
,
0
,
1
,
0
);
glEnable
(
GL_TEXTURE_2D
);
data
.
tex
.
bind
();
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MIN_FILTER
,
GL_LINEAR
);
glTexEnvi
(
GL_TEXTURE_2D
,
GL_TEXTURE_ENV_MODE
,
GL_REPLACE
);
glDisable
(
GL_CULL_FACE
);
setOpenGlDrawCallback
(
"OpenGL"
,
draw
,
&
data
);
for
(;;)
{
updateWindow
(
"OpenGL"
);
int
key
=
waitKey
(
1
0
);
int
key
=
waitKey
(
4
0
);
if
((
key
&
0xff
)
==
27
)
break
;
}
...
...
@@ -122,4 +119,4 @@ int main(int argc, char* argv[])
return
0
;
}
#endif
\ No newline at end of file
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment