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
6994a02c
Commit
6994a02c
authored
Apr 15, 2013
by
Vladislav Vinogradov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added Stream support to ogl::Buffer
parent
649737b6
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
303 additions
and
99 deletions
+303
-99
opengl.hpp
modules/core/include/opencv2/core/opengl.hpp
+186
-27
matrix.cpp
modules/core/src/matrix.cpp
+0
-2
opengl.cpp
modules/core/src/opengl.cpp
+115
-69
test_opengl.cpp
modules/gpu/test/test_opengl.cpp
+2
-1
No files found.
modules/core/include/opencv2/core/opengl.hpp
View file @
6994a02c
...
@@ -40,8 +40,12 @@
...
@@ -40,8 +40,12 @@
//
//
//M*/
//M*/
#ifndef __OPENCV_OPENGL_INTEROP_HPP__
#ifndef __OPENCV_CORE_OPENGL_HPP__
#define __OPENCV_OPENGL_INTEROP_HPP__
#define __OPENCV_CORE_OPENGL_HPP__
#ifndef __cplusplus
# error opengl.hpp header must be compiled as C++
#endif
#include "opencv2/core.hpp"
#include "opencv2/core.hpp"
...
@@ -84,7 +88,7 @@ public:
...
@@ -84,7 +88,7 @@ public:
//! create buffer
//! create buffer
void
create
(
int
arows
,
int
acols
,
int
atype
,
Target
target
=
ARRAY_BUFFER
,
bool
autoRelease
=
false
);
void
create
(
int
arows
,
int
acols
,
int
atype
,
Target
target
=
ARRAY_BUFFER
,
bool
autoRelease
=
false
);
void
create
(
Size
asize
,
int
atype
,
Target
target
=
ARRAY_BUFFER
,
bool
autoRelease
=
false
)
{
create
(
asize
.
height
,
asize
.
width
,
atype
,
target
,
autoRelease
);
}
void
create
(
Size
asize
,
int
atype
,
Target
target
=
ARRAY_BUFFER
,
bool
autoRelease
=
false
)
;
//! release memory and delete buffer object
//! release memory and delete buffer object
void
release
();
void
release
();
...
@@ -92,11 +96,15 @@ public:
...
@@ -92,11 +96,15 @@ public:
//! set auto release mode (if true, release will be called in object's destructor)
//! set auto release mode (if true, release will be called in object's destructor)
void
setAutoRelease
(
bool
flag
);
void
setAutoRelease
(
bool
flag
);
//! copy from host/device memory
//! copy from host/device memory
(blocking)
void
copyFrom
(
InputArray
arr
,
Target
target
=
ARRAY_BUFFER
,
bool
autoRelease
=
false
);
void
copyFrom
(
InputArray
arr
,
Target
target
=
ARRAY_BUFFER
,
bool
autoRelease
=
false
);
//! copy from device memory (non blocking)
void
copyFrom
(
InputArray
arr
,
gpu
::
Stream
&
stream
,
Target
target
=
ARRAY_BUFFER
,
bool
autoRelease
=
false
);
//! copy to host/device memory
//! copy to host/device memory (blocking)
void
copyTo
(
OutputArray
arr
,
Target
target
=
ARRAY_BUFFER
,
bool
autoRelease
=
false
)
const
;
void
copyTo
(
OutputArray
arr
)
const
;
//! copy to device memory (non blocking)
void
copyTo
(
OutputArray
arr
,
gpu
::
Stream
&
stream
)
const
;
//! create copy of current buffer
//! create copy of current buffer
Buffer
clone
(
Target
target
=
ARRAY_BUFFER
,
bool
autoRelease
=
false
)
const
;
Buffer
clone
(
Target
target
=
ARRAY_BUFFER
,
bool
autoRelease
=
false
)
const
;
...
@@ -111,21 +119,26 @@ public:
...
@@ -111,21 +119,26 @@ public:
Mat
mapHost
(
Access
access
);
Mat
mapHost
(
Access
access
);
void
unmapHost
();
void
unmapHost
();
//! map to device memory
//! map to device memory
(blocking)
gpu
::
GpuMat
mapDevice
();
gpu
::
GpuMat
mapDevice
();
void
unmapDevice
();
void
unmapDevice
();
int
rows
()
const
{
return
rows_
;
}
//! map to device memory (non blocking)
int
cols
()
const
{
return
cols_
;
}
gpu
::
GpuMat
mapDevice
(
gpu
::
Stream
&
stream
);
Size
size
()
const
{
return
Size
(
cols_
,
rows_
);
}
void
unmapDevice
(
gpu
::
Stream
&
stream
);
bool
empty
()
const
{
return
rows_
==
0
||
cols_
==
0
;
}
int
type
()
const
{
return
type_
;
}
int
rows
()
const
;
int
depth
()
const
{
return
CV_MAT_DEPTH
(
type_
);
}
int
cols
()
const
;
int
channels
()
const
{
return
CV_MAT_CN
(
type_
);
}
Size
size
()
const
;
int
elemSize
()
const
{
return
CV_ELEM_SIZE
(
type_
);
}
bool
empty
()
const
;
int
elemSize1
()
const
{
return
CV_ELEM_SIZE1
(
type_
);
}
int
type
()
const
;
int
depth
()
const
;
int
channels
()
const
;
int
elemSize
()
const
;
int
elemSize1
()
const
;
//! get OpenGL opject id
unsigned
int
bufId
()
const
;
unsigned
int
bufId
()
const
;
class
Impl
;
class
Impl
;
...
@@ -165,7 +178,7 @@ public:
...
@@ -165,7 +178,7 @@ public:
//! create texture
//! create texture
void
create
(
int
arows
,
int
acols
,
Format
aformat
,
bool
autoRelease
=
false
);
void
create
(
int
arows
,
int
acols
,
Format
aformat
,
bool
autoRelease
=
false
);
void
create
(
Size
asize
,
Format
aformat
,
bool
autoRelease
=
false
)
{
create
(
asize
.
height
,
asize
.
width
,
aformat
,
autoRelease
);
}
void
create
(
Size
asize
,
Format
aformat
,
bool
autoRelease
=
false
)
;
//! release memory and delete texture object
//! release memory and delete texture object
void
release
();
void
release
();
...
@@ -182,13 +195,14 @@ public:
...
@@ -182,13 +195,14 @@ public:
//! bind texture to current active texture unit for GL_TEXTURE_2D target
//! bind texture to current active texture unit for GL_TEXTURE_2D target
void
bind
()
const
;
void
bind
()
const
;
int
rows
()
const
{
return
rows_
;
}
int
rows
()
const
;
int
cols
()
const
{
return
cols_
;
}
int
cols
()
const
;
Size
size
()
const
{
return
Size
(
cols_
,
rows_
);
}
Size
size
()
const
;
bool
empty
()
const
{
return
rows_
==
0
||
cols_
==
0
;
}
bool
empty
()
const
;
Format
format
()
const
{
return
format_
;
}
Format
format
()
const
;
//! get OpenGL opject id
unsigned
int
texId
()
const
;
unsigned
int
texId
()
const
;
class
Impl
;
class
Impl
;
...
@@ -224,8 +238,8 @@ public:
...
@@ -224,8 +238,8 @@ public:
void
bind
()
const
;
void
bind
()
const
;
int
size
()
const
{
return
size_
;
}
int
size
()
const
;
bool
empty
()
const
{
return
size_
==
0
;
}
bool
empty
()
const
;
private
:
private
:
int
size_
;
int
size_
;
...
@@ -260,14 +274,14 @@ enum {
...
@@ -260,14 +274,14 @@ enum {
CV_EXPORTS
void
render
(
const
Arrays
&
arr
,
int
mode
=
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
));
CV_EXPORTS
void
render
(
const
Arrays
&
arr
,
InputArray
indices
,
int
mode
=
POINTS
,
Scalar
color
=
Scalar
::
all
(
255
));
}}
// namespace cv::gl
}}
// namespace cv::
o
gl
namespace
cv
{
namespace
gpu
{
namespace
cv
{
namespace
gpu
{
//! set a CUDA device to use OpenGL interoperability
//! set a CUDA device to use OpenGL interoperability
CV_EXPORTS
void
setGlDevice
(
int
device
=
0
);
CV_EXPORTS
void
setGlDevice
(
int
device
=
0
);
}}
// cv::gpu
}}
namespace
cv
{
namespace
cv
{
...
@@ -276,4 +290,149 @@ template <> CV_EXPORTS void Ptr<cv::ogl::Texture2D::Impl>::delete_obj();
...
@@ -276,4 +290,149 @@ template <> CV_EXPORTS void Ptr<cv::ogl::Texture2D::Impl>::delete_obj();
}
}
#endif // __OPENCV_OPENGL_INTEROP_HPP__
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
inline
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
);
}
inline
cv
::
ogl
::
Buffer
::
Buffer
(
Size
asize
,
int
atype
,
Target
target
,
bool
autoRelease
)
:
rows_
(
0
),
cols_
(
0
),
type_
(
0
)
{
create
(
asize
,
atype
,
target
,
autoRelease
);
}
inline
void
cv
::
ogl
::
Buffer
::
create
(
Size
asize
,
int
atype
,
Target
target
,
bool
autoRelease
)
{
create
(
asize
.
height
,
asize
.
width
,
atype
,
target
,
autoRelease
);
}
inline
int
cv
::
ogl
::
Buffer
::
rows
()
const
{
return
rows_
;
}
inline
int
cv
::
ogl
::
Buffer
::
cols
()
const
{
return
cols_
;
}
inline
cv
::
Size
cv
::
ogl
::
Buffer
::
size
()
const
{
return
Size
(
cols_
,
rows_
);
}
inline
bool
cv
::
ogl
::
Buffer
::
empty
()
const
{
return
rows_
==
0
||
cols_
==
0
;
}
inline
int
cv
::
ogl
::
Buffer
::
type
()
const
{
return
type_
;
}
inline
int
cv
::
ogl
::
Buffer
::
depth
()
const
{
return
CV_MAT_DEPTH
(
type_
);
}
inline
int
cv
::
ogl
::
Buffer
::
channels
()
const
{
return
CV_MAT_CN
(
type_
);
}
inline
int
cv
::
ogl
::
Buffer
::
elemSize
()
const
{
return
CV_ELEM_SIZE
(
type_
);
}
inline
int
cv
::
ogl
::
Buffer
::
elemSize1
()
const
{
return
CV_ELEM_SIZE1
(
type_
);
}
///////
inline
cv
::
ogl
::
Texture2D
::
Texture2D
(
int
arows
,
int
acols
,
Format
aformat
,
bool
autoRelease
)
:
rows_
(
0
),
cols_
(
0
),
format_
(
NONE
)
{
create
(
arows
,
acols
,
aformat
,
autoRelease
);
}
inline
cv
::
ogl
::
Texture2D
::
Texture2D
(
Size
asize
,
Format
aformat
,
bool
autoRelease
)
:
rows_
(
0
),
cols_
(
0
),
format_
(
NONE
)
{
create
(
asize
,
aformat
,
autoRelease
);
}
inline
void
cv
::
ogl
::
Texture2D
::
create
(
Size
asize
,
Format
aformat
,
bool
autoRelease
)
{
create
(
asize
.
height
,
asize
.
width
,
aformat
,
autoRelease
);
}
inline
int
cv
::
ogl
::
Texture2D
::
rows
()
const
{
return
rows_
;
}
inline
int
cv
::
ogl
::
Texture2D
::
cols
()
const
{
return
cols_
;
}
inline
cv
::
Size
cv
::
ogl
::
Texture2D
::
size
()
const
{
return
Size
(
cols_
,
rows_
);
}
inline
bool
cv
::
ogl
::
Texture2D
::
empty
()
const
{
return
rows_
==
0
||
cols_
==
0
;
}
inline
cv
::
ogl
::
Texture2D
::
Format
cv
::
ogl
::
Texture2D
::
format
()
const
{
return
format_
;
}
///////
inline
cv
::
ogl
::
Arrays
::
Arrays
()
:
size_
(
0
)
{
}
inline
int
cv
::
ogl
::
Arrays
::
size
()
const
{
return
size_
;
}
inline
bool
cv
::
ogl
::
Arrays
::
empty
()
const
{
return
size_
==
0
;
}
#endif
/* __OPENCV_CORE_OPENGL_HPP__ */
modules/core/src/matrix.cpp
View file @
6994a02c
...
@@ -41,8 +41,6 @@
...
@@ -41,8 +41,6 @@
//M*/
//M*/
#include "precomp.hpp"
#include "precomp.hpp"
#include "opencv2/core/gpu.hpp"
#include "opencv2/core/opengl.hpp"
/****************************************************************************************\
/****************************************************************************************\
* [scaled] Identity matrix initialization *
* [scaled] Identity matrix initialization *
...
...
modules/core/src/opengl.cpp
View file @
6994a02c
...
@@ -55,19 +55,19 @@ using namespace cv::gpu;
...
@@ -55,19 +55,19 @@ using namespace cv::gpu;
namespace
namespace
{
{
#ifndef HAVE_OPENGL
#ifndef HAVE_OPENGL
void
throw_no_ogl
()
{
CV_Error
(
CV_
OpenGlNotSupported
,
"The library is compiled without OpenGL support"
);
}
inline
void
throw_no_ogl
()
{
CV_Error
(
cv
::
Error
::
OpenGlNotSupported
,
"The library is compiled without OpenGL support"
);
}
#else
#else
void
throw_no_ogl
()
{
CV_Error
(
CV_
OpenGlApiCallError
,
"OpenGL context doesn't exist"
);
}
inline
void
throw_no_ogl
()
{
CV_Error
(
cv
::
Error
::
OpenGlApiCallError
,
"OpenGL context doesn't exist"
);
}
#endif
#endif
bool
checkError
(
const
char
*
file
,
const
int
line
,
const
char
*
func
=
0
)
bool
checkError
(
const
char
*
file
,
const
int
line
,
const
char
*
func
=
0
)
{
{
#ifndef HAVE_OPENGL
#ifndef HAVE_OPENGL
(
void
)
file
;
(
void
)
file
;
(
void
)
line
;
(
void
)
line
;
(
void
)
func
;
(
void
)
func
;
return
true
;
return
true
;
#else
#else
GLenum
err
=
gl
::
GetError
();
GLenum
err
=
gl
::
GetError
();
if
(
err
!=
gl
::
NO_ERROR_
)
if
(
err
!=
gl
::
NO_ERROR_
)
...
@@ -102,15 +102,14 @@ bool checkError(const char* file, const int line, const char* func = 0)
...
@@ -102,15 +102,14 @@ bool checkError(const char* file, const int line, const char* func = 0)
}
}
return
true
;
return
true
;
#endif
#endif
}
}
#if defined(__GNUC__)
#if defined(__GNUC__)
#define CV_CheckGlError() CV_DbgAssert( (checkError(__FILE__, __LINE__, __func__)) )
#define CV_CheckGlError() CV_DbgAssert( (checkError(__FILE__, __LINE__, __func__)) )
#else
#else
#define CV_CheckGlError() CV_DbgAssert( (checkError(__FILE__, __LINE__)) )
#define CV_CheckGlError() CV_DbgAssert( (checkError(__FILE__, __LINE__)) )
#endif
#endif
}
// namespace
}
// namespace
#ifdef HAVE_OPENGL
#ifdef HAVE_OPENGL
...
@@ -129,7 +128,7 @@ void cv::gpu::setGlDevice(int device)
...
@@ -129,7 +128,7 @@ void cv::gpu::setGlDevice(int device)
(
void
)
device
;
(
void
)
device
;
throw_no_ogl
();
throw_no_ogl
();
#else
#else
#if
!defined(HAVE_CUDA) || defined(CUDA_DISABLER)
#if
ndef HAVE_CUDA
(
void
)
device
;
(
void
)
device
;
throw_no_cuda
();
throw_no_cuda
();
#else
#else
...
@@ -141,7 +140,7 @@ void cv::gpu::setGlDevice(int device)
...
@@ -141,7 +140,7 @@ void cv::gpu::setGlDevice(int device)
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// CudaResource
// CudaResource
#if defined(HAVE_OPENGL) && defined(HAVE_CUDA)
&& !defined(CUDA_DISABLER)
#if defined(HAVE_OPENGL) && defined(HAVE_CUDA)
namespace
namespace
{
{
...
@@ -353,12 +352,13 @@ const Ptr<cv::ogl::Buffer::Impl>& cv::ogl::Buffer::Impl::empty()
...
@@ -353,12 +352,13 @@ const Ptr<cv::ogl::Buffer::Impl>& cv::ogl::Buffer::Impl::empty()
return
p
;
return
p
;
}
}
cv
::
ogl
::
Buffer
::
Impl
::
Impl
()
:
bufId_
(
0
),
autoRelease_
(
tru
e
)
cv
::
ogl
::
Buffer
::
Impl
::
Impl
()
:
bufId_
(
0
),
autoRelease_
(
fals
e
)
{
{
}
}
cv
::
ogl
::
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_Assert
(
gl
::
IsBuffer
(
abufId
)
==
gl
::
TRUE_
);
}
}
cv
::
ogl
::
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
)
...
@@ -437,29 +437,31 @@ void cv::ogl::Buffer::Impl::unmapHost()
...
@@ -437,29 +437,31 @@ void cv::ogl::Buffer::Impl::unmapHost()
}
}
#ifdef HAVE_CUDA
#ifdef HAVE_CUDA
void
cv
::
ogl
::
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_
.
registerBuffer
(
bufId_
);
cudaResource_
.
copyFrom
(
src
,
spitch
,
width
,
height
,
stream
);
cudaResource_
.
copyFrom
(
src
,
spitch
,
width
,
height
,
stream
);
}
}
void
cv
::
ogl
::
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_
.
registerBuffer
(
bufId_
);
cudaResource_
.
copyTo
(
dst
,
dpitch
,
width
,
height
,
stream
);
cudaResource_
.
copyTo
(
dst
,
dpitch
,
width
,
height
,
stream
);
}
}
void
*
cv
::
ogl
::
Buffer
::
Impl
::
mapDevice
(
cudaStream_t
stream
)
void
*
cv
::
ogl
::
Buffer
::
Impl
::
mapDevice
(
cudaStream_t
stream
)
{
{
cudaResource_
.
registerBuffer
(
bufId_
);
cudaResource_
.
registerBuffer
(
bufId_
);
return
cudaResource_
.
map
(
stream
);
return
cudaResource_
.
map
(
stream
);
}
}
void
cv
::
ogl
::
Buffer
::
Impl
::
unmapDevice
(
cudaStream_t
stream
)
void
cv
::
ogl
::
Buffer
::
Impl
::
unmapDevice
(
cudaStream_t
stream
)
{
{
cudaResource_
.
unmap
(
stream
);
cudaResource_
.
unmap
(
stream
);
}
}
#endif
#endif // HAVE_CUDA
#endif // HAVE_OPENGL
#endif // HAVE_OPENGL
...
@@ -505,16 +507,6 @@ cv::ogl::Buffer::Buffer(Size asize, int atype, unsigned int abufId, bool autoRel
...
@@ -505,16 +507,6 @@ cv::ogl::Buffer::Buffer(Size asize, int atype, unsigned int abufId, bool autoRel
#endif
#endif
}
}
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
::
ogl
::
Buffer
::
Buffer
(
Size
asize
,
int
atype
,
Target
target
,
bool
autoRelease
)
:
rows_
(
0
),
cols_
(
0
),
type_
(
0
)
{
create
(
asize
,
atype
,
target
,
autoRelease
);
}
cv
::
ogl
::
Buffer
::
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
#ifndef HAVE_OPENGL
...
@@ -528,16 +520,9 @@ cv::ogl::Buffer::Buffer(InputArray arr, Target target, bool autoRelease) : rows_
...
@@ -528,16 +520,9 @@ cv::ogl::Buffer::Buffer(InputArray arr, Target target, bool autoRelease) : rows_
switch
(
kind
)
switch
(
kind
)
{
{
case
_InputArray
:
:
OPENGL_BUFFER
:
case
_InputArray
:
:
OPENGL_BUFFER
:
{
copyFrom
(
arr
,
target
,
autoRelease
);
break
;
}
case
_InputArray
:
:
GPU_MAT
:
case
_InputArray
:
:
GPU_MAT
:
{
copyFrom
(
arr
,
target
,
autoRelease
);
copyFrom
(
arr
,
target
,
autoRelease
);
break
;
break
;
}
default
:
default
:
{
{
...
@@ -622,7 +607,7 @@ void cv::ogl::Buffer::copyFrom(InputArray arr, Target target, bool autoRelease)
...
@@ -622,7 +607,7 @@ void cv::ogl::Buffer::copyFrom(InputArray arr, Target target, bool autoRelease)
case
_InputArray
:
:
GPU_MAT
:
case
_InputArray
:
:
GPU_MAT
:
{
{
#if
!defined HAVE_CUDA || defined(CUDA_DISABLER)
#if
ndef HAVE_CUDA
throw_no_cuda
();
throw_no_cuda
();
#else
#else
GpuMat
dmat
=
arr
.
getGpuMat
();
GpuMat
dmat
=
arr
.
getGpuMat
();
...
@@ -642,13 +627,36 @@ void cv::ogl::Buffer::copyFrom(InputArray arr, Target target, bool autoRelease)
...
@@ -642,13 +627,36 @@ void cv::ogl::Buffer::copyFrom(InputArray arr, Target target, bool autoRelease)
#endif
#endif
}
}
void
cv
::
ogl
::
Buffer
::
copy
To
(
OutputArray
arr
,
Target
target
,
bool
autoRelease
)
const
void
cv
::
ogl
::
Buffer
::
copy
From
(
InputArray
arr
,
gpu
::
Stream
&
stream
,
Target
target
,
bool
autoRelease
)
{
{
#ifndef HAVE_OPENGL
#ifndef HAVE_OPENGL
(
void
)
arr
;
(
void
)
arr
;
(
void
)
stream
;
(
void
)
target
;
(
void
)
target
;
(
void
)
autoRelease
;
(
void
)
autoRelease
;
throw_no_ogl
();
throw_no_ogl
();
#else
#ifndef HAVE_CUDA
(
void
)
arr
;
(
void
)
stream
;
(
void
)
target
;
(
void
)
autoRelease
;
throw_no_cuda
();
#else
GpuMat
dmat
=
arr
.
getGpuMat
();
create
(
dmat
.
size
(),
dmat
.
type
(),
target
,
autoRelease
);
impl_
->
copyFrom
(
dmat
.
data
,
dmat
.
step
,
dmat
.
cols
*
dmat
.
elemSize
(),
dmat
.
rows
,
gpu
::
StreamAccessor
::
getStream
(
stream
));
#endif
#endif
}
void
cv
::
ogl
::
Buffer
::
copyTo
(
OutputArray
arr
)
const
{
#ifndef HAVE_OPENGL
(
void
)
arr
;
throw_no_ogl
();
#else
#else
const
int
kind
=
arr
.
kind
();
const
int
kind
=
arr
.
kind
();
...
@@ -656,13 +664,13 @@ void cv::ogl::Buffer::copyTo(OutputArray arr, Target target, bool autoRelease) c
...
@@ -656,13 +664,13 @@ void cv::ogl::Buffer::copyTo(OutputArray arr, Target target, bool autoRelease) c
{
{
case
_InputArray
:
:
OPENGL_BUFFER
:
case
_InputArray
:
:
OPENGL_BUFFER
:
{
{
arr
.
getOGlBufferRef
().
copyFrom
(
*
this
,
target
,
autoRelease
);
arr
.
getOGlBufferRef
().
copyFrom
(
*
this
);
break
;
break
;
}
}
case
_InputArray
:
:
GPU_MAT
:
case
_InputArray
:
:
GPU_MAT
:
{
{
#if
!defined HAVE_CUDA || defined(CUDA_DISABLER)
#if
ndef HAVE_CUDA
throw_no_cuda
();
throw_no_cuda
();
#else
#else
GpuMat
&
dmat
=
arr
.
getGpuMatRef
();
GpuMat
&
dmat
=
arr
.
getGpuMatRef
();
...
@@ -684,6 +692,25 @@ void cv::ogl::Buffer::copyTo(OutputArray arr, Target target, bool autoRelease) c
...
@@ -684,6 +692,25 @@ void cv::ogl::Buffer::copyTo(OutputArray arr, Target target, bool autoRelease) c
#endif
#endif
}
}
void
cv
::
ogl
::
Buffer
::
copyTo
(
OutputArray
arr
,
gpu
::
Stream
&
stream
)
const
{
#ifndef HAVE_OPENGL
(
void
)
arr
;
(
void
)
stream
;
throw_no_ogl
();
#else
#ifndef HAVE_CUDA
(
void
)
arr
;
(
void
)
stream
;
throw_no_cuda
();
#else
arr
.
create
(
rows_
,
cols_
,
type_
);
GpuMat
dmat
=
arr
.
getGpuMat
();
impl_
->
copyTo
(
dmat
.
data
,
dmat
.
step
,
dmat
.
cols
*
dmat
.
elemSize
(),
dmat
.
rows
,
gpu
::
StreamAccessor
::
getStream
(
stream
));
#endif
#endif
}
cv
::
ogl
::
Buffer
cv
::
ogl
::
Buffer
::
clone
(
Target
target
,
bool
autoRelease
)
const
cv
::
ogl
::
Buffer
cv
::
ogl
::
Buffer
::
clone
(
Target
target
,
bool
autoRelease
)
const
{
{
#ifndef HAVE_OPENGL
#ifndef HAVE_OPENGL
...
@@ -745,7 +772,7 @@ GpuMat cv::ogl::Buffer::mapDevice()
...
@@ -745,7 +772,7 @@ GpuMat cv::ogl::Buffer::mapDevice()
throw_no_ogl
();
throw_no_ogl
();
return
GpuMat
();
return
GpuMat
();
#else
#else
#if
!defined HAVE_CUDA || defined(CUDA_DISABLER)
#if
ndef HAVE_CUDA
throw_no_cuda
();
throw_no_cuda
();
return
GpuMat
();
return
GpuMat
();
#else
#else
...
@@ -759,7 +786,7 @@ void cv::ogl::Buffer::unmapDevice()
...
@@ -759,7 +786,7 @@ void cv::ogl::Buffer::unmapDevice()
#ifndef HAVE_OPENGL
#ifndef HAVE_OPENGL
throw_no_ogl
();
throw_no_ogl
();
#else
#else
#if
!defined HAVE_CUDA || defined(CUDA_DISABLER)
#if
ndef HAVE_CUDA
throw_no_cuda
();
throw_no_cuda
();
#else
#else
impl_
->
unmapDevice
();
impl_
->
unmapDevice
();
...
@@ -767,6 +794,38 @@ void cv::ogl::Buffer::unmapDevice()
...
@@ -767,6 +794,38 @@ void cv::ogl::Buffer::unmapDevice()
#endif
#endif
}
}
gpu
::
GpuMat
cv
::
ogl
::
Buffer
::
mapDevice
(
gpu
::
Stream
&
stream
)
{
#ifndef HAVE_OPENGL
(
void
)
stream
;
throw_no_ogl
();
return
GpuMat
();
#else
#ifndef HAVE_CUDA
(
void
)
stream
;
throw_no_cuda
();
return
GpuMat
();
#else
return
GpuMat
(
rows_
,
cols_
,
type_
,
impl_
->
mapDevice
(
gpu
::
StreamAccessor
::
getStream
(
stream
)));
#endif
#endif
}
void
cv
::
ogl
::
Buffer
::
unmapDevice
(
gpu
::
Stream
&
stream
)
{
#ifndef HAVE_OPENGL
(
void
)
stream
;
throw_no_ogl
();
#else
#ifndef HAVE_CUDA
(
void
)
stream
;
throw_no_cuda
();
#else
impl_
->
unmapDevice
(
gpu
::
StreamAccessor
::
getStream
(
stream
));
#endif
#endif
}
unsigned
int
cv
::
ogl
::
Buffer
::
bufId
()
const
unsigned
int
cv
::
ogl
::
Buffer
::
bufId
()
const
{
{
#ifndef HAVE_OPENGL
#ifndef HAVE_OPENGL
...
@@ -824,12 +883,13 @@ const Ptr<cv::ogl::Texture2D::Impl> cv::ogl::Texture2D::Impl::empty()
...
@@ -824,12 +883,13 @@ const Ptr<cv::ogl::Texture2D::Impl> cv::ogl::Texture2D::Impl::empty()
return
p
;
return
p
;
}
}
cv
::
ogl
::
Texture2D
::
Impl
::
Impl
()
:
texId_
(
0
),
autoRelease_
(
tru
e
)
cv
::
ogl
::
Texture2D
::
Impl
::
Impl
()
:
texId_
(
0
),
autoRelease_
(
fals
e
)
{
{
}
}
cv
::
ogl
::
Texture2D
::
Impl
::
Impl
(
GLuint
atexId
,
bool
autoRelease
)
:
texId_
(
atexId
),
autoRelease_
(
autoRelease
)
cv
::
ogl
::
Texture2D
::
Impl
::
Impl
(
GLuint
atexId
,
bool
autoRelease
)
:
texId_
(
atexId
),
autoRelease_
(
autoRelease
)
{
{
CV_Assert
(
gl
::
IsTexture
(
atexId
)
==
gl
::
TRUE_
);
}
}
cv
::
ogl
::
Texture2D
::
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
)
...
@@ -935,16 +995,6 @@ cv::ogl::Texture2D::Texture2D(Size asize, Format aformat, unsigned int atexId, b
...
@@ -935,16 +995,6 @@ cv::ogl::Texture2D::Texture2D(Size asize, Format aformat, unsigned int atexId, b
#endif
#endif
}
}
cv
::
ogl
::
Texture2D
::
Texture2D
(
int
arows
,
int
acols
,
Format
aformat
,
bool
autoRelease
)
:
rows_
(
0
),
cols_
(
0
),
format_
(
NONE
)
{
create
(
arows
,
acols
,
aformat
,
autoRelease
);
}
cv
::
ogl
::
Texture2D
::
Texture2D
(
Size
asize
,
Format
aformat
,
bool
autoRelease
)
:
rows_
(
0
),
cols_
(
0
),
format_
(
NONE
)
{
create
(
asize
,
aformat
,
autoRelease
);
}
cv
::
ogl
::
Texture2D
::
Texture2D
(
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
#ifndef HAVE_OPENGL
...
@@ -985,7 +1035,7 @@ cv::ogl::Texture2D::Texture2D(InputArray arr, bool autoRelease) : rows_(0), cols
...
@@ -985,7 +1035,7 @@ cv::ogl::Texture2D::Texture2D(InputArray arr, bool autoRelease) : rows_(0), cols
case
_InputArray
:
:
GPU_MAT
:
case
_InputArray
:
:
GPU_MAT
:
{
{
#if
!defined HAVE_CUDA || defined(CUDA_DISABLER)
#if
ndef HAVE_CUDA
throw_no_cuda
();
throw_no_cuda
();
#else
#else
GpuMat
dmat
=
arr
.
getGpuMat
();
GpuMat
dmat
=
arr
.
getGpuMat
();
...
@@ -1098,7 +1148,7 @@ void cv::ogl::Texture2D::copyFrom(InputArray arr, bool autoRelease)
...
@@ -1098,7 +1148,7 @@ void cv::ogl::Texture2D::copyFrom(InputArray arr, bool autoRelease)
case
_InputArray
:
:
GPU_MAT
:
case
_InputArray
:
:
GPU_MAT
:
{
{
#if
!defined HAVE_CUDA || defined(CUDA_DISABLER)
#if
ndef HAVE_CUDA
throw_no_cuda
();
throw_no_cuda
();
#else
#else
GpuMat
dmat
=
arr
.
getGpuMat
();
GpuMat
dmat
=
arr
.
getGpuMat
();
...
@@ -1149,7 +1199,7 @@ void cv::ogl::Texture2D::copyTo(OutputArray arr, int ddepth, bool autoRelease) c
...
@@ -1149,7 +1199,7 @@ void cv::ogl::Texture2D::copyTo(OutputArray arr, int ddepth, bool autoRelease) c
case
_InputArray
:
:
GPU_MAT
:
case
_InputArray
:
:
GPU_MAT
:
{
{
#if
!defined HAVE_CUDA || defined(CUDA_DISABLER)
#if
ndef HAVE_CUDA
throw_no_cuda
();
throw_no_cuda
();
#else
#else
ogl
::
Buffer
buf
(
rows_
,
cols_
,
CV_MAKE_TYPE
(
ddepth
,
cn
),
ogl
::
Buffer
::
PIXEL_PACK_BUFFER
);
ogl
::
Buffer
buf
(
rows_
,
cols_
,
CV_MAKE_TYPE
(
ddepth
,
cn
),
ogl
::
Buffer
::
PIXEL_PACK_BUFFER
);
...
@@ -1201,10 +1251,6 @@ template <> void cv::Ptr<cv::ogl::Texture2D::Impl>::delete_obj()
...
@@ -1201,10 +1251,6 @@ template <> void cv::Ptr<cv::ogl::Texture2D::Impl>::delete_obj()
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// ogl::Arrays
// ogl::Arrays
cv
::
ogl
::
Arrays
::
Arrays
()
:
size_
(
0
)
{
}
void
cv
::
ogl
::
Arrays
::
setVertexArray
(
InputArray
vertex
)
void
cv
::
ogl
::
Arrays
::
setVertexArray
(
InputArray
vertex
)
{
{
const
int
cn
=
vertex
.
channels
();
const
int
cn
=
vertex
.
channels
();
...
...
modules/gpu/test/test_opengl.cpp
View file @
6994a02c
...
@@ -198,7 +198,8 @@ GPU_TEST_P(Buffer, CopyToBuffer)
...
@@ -198,7 +198,8 @@ GPU_TEST_P(Buffer, CopyToBuffer)
cv
::
ogl
::
Buffer
buf
(
gold
,
cv
::
ogl
::
Buffer
::
ARRAY_BUFFER
,
true
);
cv
::
ogl
::
Buffer
buf
(
gold
,
cv
::
ogl
::
Buffer
::
ARRAY_BUFFER
,
true
);
cv
::
ogl
::
Buffer
dst
;
cv
::
ogl
::
Buffer
dst
;
buf
.
copyTo
(
dst
,
cv
::
ogl
::
Buffer
::
ARRAY_BUFFER
,
true
);
buf
.
copyTo
(
dst
);
dst
.
setAutoRelease
(
true
);
EXPECT_NE
(
buf
.
bufId
(),
dst
.
bufId
());
EXPECT_NE
(
buf
.
bufId
(),
dst
.
bufId
());
...
...
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