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
c2783af7
Commit
c2783af7
authored
Nov 21, 2011
by
Vladislav Vinogradov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added OpenGL support to highgui under WIN32
parent
03002fff
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
442 additions
and
84 deletions
+442
-84
CMakeLists.txt
CMakeLists.txt
+17
-2
CMakeCache.android.initial.cmake
android/CMakeCache.android.initial.cmake
+2
-2
cvconfig.h.cmake
cvconfig.h.cmake
+3
-0
devmem2d.hpp
modules/core/include/opencv2/core/devmem2d.hpp
+4
-0
gpumat.hpp
modules/core/include/opencv2/core/gpumat.hpp
+157
-2
types_c.h
modules/core/include/opencv2/core/types_c.h
+3
-1
matrix_operations.cu
modules/core/src/cuda/matrix_operations.cu
+3
-3
gpumat.cpp
modules/core/src/gpumat.cpp
+0
-0
system.cpp
modules/core/src/system.cpp
+3
-1
bilateral_filter.cu
modules/gpu/src/cuda/bilateral_filter.cu
+1
-1
hog.cu
modules/gpu/src/cuda/hog.cu
+1
-1
split_merge.cu
modules/gpu/src/cuda/split_merge.cu
+2
-2
stereobm.cu
modules/gpu/src/cuda/stereobm.cu
+1
-1
stereocsbp.cu
modules/gpu/src/cuda/stereocsbp.cu
+4
-4
common.hpp
modules/gpu/src/opencv2/gpu/device/common.hpp
+1
-1
utility.hpp
modules/gpu/src/opencv2/gpu/device/utility.hpp
+1
-1
highgui.hpp
modules/highgui/include/opencv2/highgui/highgui.hpp
+79
-45
highgui_c.h
modules/highgui/include/opencv2/highgui/highgui_c.h
+20
-13
precomp.hpp
modules/highgui/src/precomp.hpp
+13
-4
window.cpp
modules/highgui/src/window.cpp
+0
-0
window_w32.cpp
modules/highgui/src/window_w32.cpp
+0
-0
highgui_gpu.cpp
samples/gpu/highgui_gpu.cpp
+127
-0
No files found.
CMakeLists.txt
View file @
c2783af7
...
...
@@ -462,6 +462,9 @@ endif()
set
(
WITH_OPENNI OFF CACHE BOOL
"Include OpenNI support"
)
set
(
WITH_XIMEA OFF CACHE BOOL
"Include XIMEA cameras support"
)
set
(
WITH_OPENGL OFF CACHE BOOL
"Include OpenGL support"
)
set
(
HAVE_OPENGL 0
)
# ===================================================
# Macros that checks if module have been installed.
...
...
@@ -872,7 +875,6 @@ endif()
############################### QT ################################
set
(
WITH_QT OFF CACHE BOOL
"Build with Qt Backend support"
)
set
(
WITH_QT_OPENGL OFF CACHE BOOL
"Add OpenGL extension to Qt"
)
set
(
HAVE_QT 0
)
set
(
HAVE_QT_OPENGL 0
)
...
...
@@ -885,8 +887,9 @@ if (WITH_QT)
find_package
(
OpenGL QUIET
)
#if (NOT WIN32)
if
(
WITH_
QT_
OPENGL
)
if
(
WITH_OPENGL
)
if
(
QT_QTOPENGL_FOUND AND OPENGL_FOUND
)
#set(HAVE_OPENGL 1)
set
(
HAVE_QT_OPENGL 1
)
add_definitions
(
-DHAVE_QT_OPENGL
)
#link_directories("${OPENGL_LIBRARIES}")
...
...
@@ -1121,6 +1124,16 @@ if(WIN32)
set
(
HIGHGUI_LIBRARIES
${
HIGHGUI_LIBRARIES
}
vfw32 winmm
)
endif
()
endif
()
if
(
WITH_OPENGL
)
find_package
(
OpenGL QUIET
)
if
(
OPENGL_FOUND
)
set
(
HAVE_OPENGL 1
)
set
(
OPENCV_LINKER_LIBS
${
OPENCV_LINKER_LIBS
}
${
OPENGL_LIBRARIES
}
)
include_directories
(
${
OPENGL_INCLUDE_DIR
}
)
endif
()
endif
()
endif
()
############## Android source tree for native camera ###############
...
...
@@ -1717,6 +1730,8 @@ else()
endif
()
endif
()
status
(
" OpenGL support:"
HAVE_OPENGL THEN YES ELSE NO
)
# media
status
(
""
)
status
(
" Media I/O: "
)
...
...
android/CMakeCache.android.initial.cmake
View file @
c2783af7
...
...
@@ -55,8 +55,8 @@ set(WITH_PVAPI OFF CACHE BOOL "" )
#Build with Qt Backend support
set
(
WITH_QT OFF CACHE BOOL
""
)
#Add OpenGL
extension to Q
t
set
(
WITH_
QT_
OPENGL OFF CACHE BOOL
""
)
#Add OpenGL
suppor
t
set
(
WITH_OPENGL OFF CACHE BOOL
""
)
#Include Intel TBB support
set
(
WITH_TBB OFF CACHE BOOL
""
)
...
...
cvconfig.h.cmake
View file @
c2783af7
...
...
@@ -195,3 +195,6 @@
/* XIMEA camera support */
#cmakedefine HAVE_XIMEA
/* OpenGL support*/
#cmakedefine HAVE_OPENGL
modules/core/include/opencv2/core/devmem2d.hpp
View file @
c2783af7
...
...
@@ -43,6 +43,8 @@
#ifndef __OPENCV_CORE_DevMem2D_HPP__
#define __OPENCV_CORE_DevMem2D_HPP__
#ifdef __cplusplus
#ifdef __CUDACC__
#define __CV_GPU_HOST_DEVICE__ __host__ __device__ __forceinline__
#else
...
...
@@ -154,4 +156,6 @@ namespace cv
}
}
#endif // __cplusplus
#endif
/* __OPENCV_GPU_DevMem2D_HPP__ */
modules/core/include/opencv2/core/gpumat.hpp
View file @
c2783af7
...
...
@@ -43,11 +43,16 @@
#ifndef __OPENCV_GPUMAT_HPP__
#define __OPENCV_GPUMAT_HPP__
#ifdef __cplusplus
#include "opencv2/core/core.hpp"
#include "opencv2/core/devmem2d.hpp"
namespace
cv
{
namespace
gpu
{
////////////////////////////////////////////////////////////////////////
// GpuMat
//! Smart pointer for GPU memory with reference counting. Its interface is mostly similar with cv::Mat.
class
CV_EXPORTS
GpuMat
{
...
...
@@ -212,10 +217,158 @@ namespace cv { namespace gpu
CV_EXPORTS
void
ensureSizeIsEnough
(
int
rows
,
int
cols
,
int
type
,
GpuMat
&
m
);
CV_EXPORTS
void
ensureSizeIsEnough
(
Size
size
,
int
type
,
GpuMat
&
m
);
//////////////////////////////// Error handling ////////////////////////
////////////////////////////////////////////////////////////////////////
// OpenGL
//! set a CUDA device to use OpenGL interoperability
CV_EXPORTS
void
setGlDevice
(
int
device
=
0
);
//! 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
(
const
Mat
&
mat
,
Usage
usage
);
GlBuffer
(
const
GpuMat
&
d_mat
,
Usage
usage
);
~
GlBuffer
();
void
create
(
int
rows
,
int
cols
,
int
type
,
Usage
usage
);
inline
void
create
(
Size
size
,
int
type
,
Usage
usage
)
{
create
(
size
.
height
,
size
.
width
,
type
,
usage
);
}
inline
void
create
(
int
rows
,
int
cols
,
int
type
)
{
create
(
rows
,
cols
,
type
,
usage
());
}
inline
void
create
(
Size
size
,
int
type
)
{
create
(
size
.
height
,
size
.
width
,
type
,
usage
());
}
void
release
();
//! copy from host/device memory
void
copyFrom
(
const
Mat
&
mat
);
void
copyFrom
(
const
GpuMat
&
d_mat
);
void
bind
()
const
;
void
unbind
()
const
;
//! map to host memory
Mat
mapHost
();
void
unmapHost
();
//! map to device memory
GpuMat
mapDevice
();
void
unmapDevice
();
int
rows
()
const
;
int
cols
()
const
;
Size
size
()
const
;
bool
empty
()
const
;
int
type
()
const
;
int
depth
()
const
;
int
channels
()
const
;
int
elemSize
()
const
;
int
elemSize1
()
const
;
Usage
usage
()
const
;
private
:
class
Impl
;
Ptr
<
Impl
>
impl_
;
};
//! 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
);
CV_EXPORTS
void
error
(
const
char
*
error_string
,
const
char
*
file
,
const
int
line
,
const
char
*
func
);
//! copy from host/device memory
explicit
GlTexture
(
const
Mat
&
mat
,
bool
bgra
=
true
);
explicit
GlTexture
(
const
GlBuffer
&
buf
,
bool
bgra
=
true
);
~
GlTexture
();
void
create
(
int
rows
,
int
cols
,
int
type
);
inline
void
create
(
Size
size
,
int
type
)
{
create
(
size
.
height
,
size
.
width
,
type
);
}
void
release
();
//! copy from host/device memory
void
copyFrom
(
const
Mat
&
mat
,
bool
bgra
=
true
);
void
copyFrom
(
const
GlBuffer
&
buf
,
bool
bgra
=
true
);
void
bind
()
const
;
void
unbind
()
const
;
int
rows
()
const
;
int
cols
()
const
;
Size
size
()
const
;
bool
empty
()
const
;
int
type
()
const
;
int
depth
()
const
;
int
channels
()
const
;
int
elemSize
()
const
;
int
elemSize1
()
const
;
private
:
class
Impl
;
Ptr
<
Impl
>
impl_
;
};
//! render functions
CV_EXPORTS
void
render
(
const
GlTexture
&
tex
);
//! OpenGL extension table
class
CV_EXPORTS
GlFuncTab
{
public
:
virtual
~
GlFuncTab
()
{}
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
bool
isGlContextInitialized
()
const
=
0
;
};
CV_EXPORTS
void
setGlFuncTab
(
const
GlFuncTab
*
tab
);
////////////////////////////////////////////////////////////////////////
// Error handling
CV_EXPORTS
void
error
(
const
char
*
error_string
,
const
char
*
file
,
const
int
line
,
const
char
*
func
=
""
);
CV_EXPORTS
bool
checkGlError
(
const
char
*
file
,
const
int
line
,
const
char
*
func
=
""
);
#if defined(__GNUC__)
#define CV_CheckGlError() CV_DbgAssert( (cv::gpu::checkGlError(__FILE__, __LINE__, __func__)) )
#else
#define CV_CheckGlError() CV_DbgAssert( (cv::gpu::checkGlError(__FILE__, __LINE__)) )
#endif
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
inline
GpuMat
::
GpuMat
()
...
...
@@ -456,4 +609,6 @@ namespace cv { namespace gpu
}
}}
#endif // __cplusplus
#endif // __OPENCV_GPUMAT_HPP__
modules/core/include/opencv2/core/types_c.h
View file @
c2783af7
...
...
@@ -250,7 +250,9 @@ enum {
CV_StsBadMemBlock
=
-
214
,
/* an allocated block has been corrupted */
CV_StsAssert
=
-
215
,
/* assertion failed */
CV_GpuNotSupported
=
-
216
,
CV_GpuApiCallError
=
-
217
CV_GpuApiCallError
=
-
217
,
CV_OpenGlNotSupported
=
-
218
,
CV_OpenGlApiCallError
=
-
219
};
/****************************************************************************************\
...
...
modules/core/src/cuda/matrix_operations.cu
View file @
c2783af7
...
...
@@ -106,7 +106,7 @@ namespace cv { namespace gpu { namespace device
CopyToFunc func = tab[depth];
if (func == 0)
cv::gpu::error("Unsupported copyTo operation", __FILE__, __LINE__);
cv::gpu::error("Unsupported copyTo operation", __FILE__, __LINE__
, "copy_to_with_mask"
);
func(mat_src, mat_dst, mask, channels, stream);
}
...
...
@@ -246,7 +246,7 @@ namespace cv { namespace gpu { namespace device
return saturate_cast<D>(alpha * src + beta);
}
const
double alpha, beta;
double alpha, beta;
};
namespace detail
...
...
@@ -338,7 +338,7 @@ namespace cv { namespace gpu { namespace device
caller_t func = tab[sdepth][ddepth];
if (!func)
cv::gpu::error("Unsupported convert operation", __FILE__, __LINE__);
cv::gpu::error("Unsupported convert operation", __FILE__, __LINE__
, "convert_gpu"
);
func(src, dst, alpha, beta, stream);
}
...
...
modules/core/src/gpumat.cpp
View file @
c2783af7
This diff is collapsed.
Click to expand it.
modules/core/src/system.cpp
View file @
c2783af7
...
...
@@ -630,7 +630,9 @@ CV_IMPL const char* cvErrorStr( int status )
case
CV_StsBadMemBlock
:
return
"Memory block has been corrupted"
;
case
CV_StsAssert
:
return
"Assertion failed"
;
case
CV_GpuNotSupported
:
return
"No GPU support"
;
case
CV_GpuApiCallError
:
return
"Gpu Api call"
;
case
CV_GpuApiCallError
:
return
"Gpu API call"
;
case
CV_OpenGlNotSupported
:
return
"No OpenGL support"
;
case
CV_OpenGlApiCallError
:
return
"OpenGL API call"
;
};
sprintf
(
buf
,
"Unknown %s code %d"
,
status
>=
0
?
"status"
:
"error"
,
status
);
...
...
modules/gpu/src/cuda/bilateral_filter.cu
View file @
c2783af7
...
...
@@ -206,7 +206,7 @@ namespace cv { namespace gpu { namespace device
}
break;
default:
cv::gpu::error("Unsupported channels count", __FILE__, __LINE__);
cv::gpu::error("Unsupported channels count", __FILE__, __LINE__
, "bilateral_filter_caller"
);
}
if (stream != 0)
...
...
modules/gpu/src/cuda/hog.cu
View file @
c2783af7
...
...
@@ -314,7 +314,7 @@ namespace cv { namespace gpu { namespace device
else if (nthreads == 512)
normalize_hists_kernel_many_blocks<512, nblocks><<<grid, threads>>>(block_hist_size, img_block_width, block_hists, threshold);
else
cv::gpu::error("normalize_hists: histogram's size is too big, try to decrease number of bins", __FILE__, __LINE__);
cv::gpu::error("normalize_hists: histogram's size is too big, try to decrease number of bins", __FILE__, __LINE__
, "normalize_hists"
);
cudaSafeCall( cudaGetLastError() );
...
...
modules/gpu/src/cuda/split_merge.cu
View file @
c2783af7
...
...
@@ -291,7 +291,7 @@ namespace cv { namespace gpu { namespace device
MergeFunction merge_func = merge_func_tbl[merge_func_id];
if (merge_func == 0)
cv::gpu::error("Unsupported channel count or data type", __FILE__, __LINE__);
cv::gpu::error("Unsupported channel count or data type", __FILE__, __LINE__
, "merge_caller"
);
merge_func(src, dst, stream);
}
...
...
@@ -498,7 +498,7 @@ namespace cv { namespace gpu { namespace device
SplitFunction split_func = split_func_tbl[split_func_id];
if (split_func == 0)
cv::gpu::error("Unsupported channel count or data type", __FILE__, __LINE__);
cv::gpu::error("Unsupported channel count or data type", __FILE__, __LINE__
, "split_caller"
);
split_func(src, dst, stream);
}
...
...
modules/gpu/src/cuda/stereobm.cu
View file @
c2783af7
...
...
@@ -346,7 +346,7 @@ namespace cv { namespace gpu { namespace device
int winsz2 = winsz >> 1;
if (winsz2 == 0 || winsz2 >= calles_num)
cv::gpu::error("Unsupported window size", __FILE__, __LINE__);
cv::gpu::error("Unsupported window size", __FILE__, __LINE__
, "stereoBM_GPU"
);
//cudaSafeCall( cudaFuncSetCacheConfig(&stereoKernel, cudaFuncCachePreferL1) );
//cudaSafeCall( cudaFuncSetCacheConfig(&stereoKernel, cudaFuncCachePreferShared) );
...
...
modules/gpu/src/cuda/stereocsbp.cu
View file @
c2783af7
...
...
@@ -336,7 +336,7 @@ namespace cv { namespace gpu { namespace device
case 1: init_data_cost<T, 1><<<grid, threads, 0, stream>>>(h, w, level); break;
case 3: init_data_cost<T, 3><<<grid, threads, 0, stream>>>(h, w, level); break;
case 4: init_data_cost<T, 4><<<grid, threads, 0, stream>>>(h, w, level); break;
default: cv::gpu::error("Unsupported channels count", __FILE__, __LINE__);
default: cv::gpu::error("Unsupported channels count", __FILE__, __LINE__
, "init_data_cost_caller_"
);
}
}
...
...
@@ -355,7 +355,7 @@ namespace cv { namespace gpu { namespace device
case 1: init_data_cost_reduce<T, winsz, 1><<<grid, threads, smem_size, stream>>>(level, rows, cols, h); break;
case 3: init_data_cost_reduce<T, winsz, 3><<<grid, threads, smem_size, stream>>>(level, rows, cols, h); break;
case 4: init_data_cost_reduce<T, winsz, 4><<<grid, threads, smem_size, stream>>>(level, rows, cols, h); break;
default: cv::gpu::error("Unsupported channels count", __FILE__, __LINE__);
default: cv::gpu::error("Unsupported channels count", __FILE__, __LINE__
, "init_data_cost_reduce_caller_"
);
}
}
...
...
@@ -533,7 +533,7 @@ namespace cv { namespace gpu { namespace device
case 1: compute_data_cost<T, 1><<<grid, threads, 0, stream>>>(disp_selected_pyr, data_cost, h, w, level, nr_plane); break;
case 3: compute_data_cost<T, 3><<<grid, threads, 0, stream>>>(disp_selected_pyr, data_cost, h, w, level, nr_plane); break;
case 4: compute_data_cost<T, 4><<<grid, threads, 0, stream>>>(disp_selected_pyr, data_cost, h, w, level, nr_plane); break;
default: cv::gpu::error("Unsupported channels count", __FILE__, __LINE__);
default: cv::gpu::error("Unsupported channels count", __FILE__, __LINE__
, "compute_data_cost_caller_"
);
}
}
...
...
@@ -553,7 +553,7 @@ namespace cv { namespace gpu { namespace device
case 1: compute_data_cost_reduce<T, winsz, 1><<<grid, threads, smem_size, stream>>>(disp_selected_pyr, data_cost, level, rows, cols, h, nr_plane); break;
case 3: compute_data_cost_reduce<T, winsz, 3><<<grid, threads, smem_size, stream>>>(disp_selected_pyr, data_cost, level, rows, cols, h, nr_plane); break;
case 4: compute_data_cost_reduce<T, winsz, 4><<<grid, threads, smem_size, stream>>>(disp_selected_pyr, data_cost, level, rows, cols, h, nr_plane); break;
default: cv::gpu::error("Unsupported channels count", __FILE__, __LINE__);
default: cv::gpu::error("Unsupported channels count", __FILE__, __LINE__
, "compute_data_cost_reduce_caller_"
);
}
}
...
...
modules/gpu/src/opencv2/gpu/device/common.hpp
View file @
c2783af7
...
...
@@ -66,7 +66,7 @@
namespace
cv
{
namespace
gpu
{
void
error
(
const
char
*
error_string
,
const
char
*
file
,
const
int
line
,
const
char
*
func
=
""
);
void
error
(
const
char
*
error_string
,
const
char
*
file
,
const
int
line
,
const
char
*
func
);
}}
static
inline
void
___cudaSafeCall
(
cudaError_t
err
,
const
char
*
file
,
const
int
line
,
const
char
*
func
=
""
)
...
...
modules/gpu/src/opencv2/gpu/device/utility.hpp
View file @
c2783af7
...
...
@@ -76,7 +76,7 @@ namespace cv { namespace gpu { namespace device
return
mask
.
ptr
(
y
)[
x
]
!=
0
;
}
const
PtrStepb
mask
;
PtrStepb
mask
;
};
struct
MaskCollection
...
...
modules/highgui/include/opencv2/highgui/highgui.hpp
View file @
c2783af7
...
...
@@ -44,6 +44,7 @@
#define __OPENCV_HIGHGUI_HPP__
#include "opencv2/core/core.hpp"
#include "opencv2/core/gpumat.hpp"
#include "opencv2/highgui/highgui_c.h"
#ifdef __cplusplus
...
...
@@ -54,54 +55,34 @@ struct CvVideoWriter;
namespace
cv
{
enum
{
WINDOW_AUTOSIZE
=
1
};
enum
{
// Flags for namedWindow
WINDOW_NORMAL
=
CV_WINDOW_NORMAL
,
// the user can resize the window (no constraint) / also use to switch a fullscreen window to a normal size
WINDOW_AUTOSIZE
=
CV_WINDOW_AUTOSIZE
,
// the user cannot resize the window, the size is constrainted by the image displayed
WINDOW_OPENGL
=
CV_WINDOW_OPENGL
,
// window with opengl support
CV_EXPORTS_W
void
namedWindow
(
const
string
&
winname
,
int
flags
=
WINDOW_AUTOSIZE
);
CV_EXPORTS_W
void
destroyWindow
(
const
string
&
winname
);
CV_EXPORTS_W
void
destroyAllWindows
();
CV_EXPORTS_W
int
startWindowThread
();
CV_EXPORTS_W
void
resizeWindow
(
const
string
&
name
,
int
width
,
int
height
);
CV_EXPORTS_W
void
moveWindow
(
const
string
&
name
,
int
x
,
int
y
);
CV_EXPORTS_W
void
setWindowProperty
(
const
string
&
winname
,
int
prop_id
,
double
prop_value
);
//YV
CV_EXPORTS_W
double
getWindowProperty
(
const
string
&
winname
,
int
prop_id
);
//YV
//Only for Qt
//------------------------
CV_EXPORTS
CvFont
fontQt
(
const
string
&
nameFont
,
int
pointSize
=-
1
,
Scalar
color
=
Scalar
::
all
(
0
),
int
weight
=
CV_FONT_NORMAL
,
int
style
=
CV_STYLE_NORMAL
,
int
spacing
=
0
);
CV_EXPORTS
void
addText
(
const
Mat
&
img
,
const
string
&
text
,
Point
org
,
CvFont
font
);
CV_EXPORTS
void
displayOverlay
(
const
string
&
winname
,
const
string
&
text
,
int
delayms
);
CV_EXPORTS
void
displayStatusBar
(
const
string
&
winname
,
const
string
&
text
,
int
delayms
);
typedef
void
(
CV_CDECL
*
OpenGLCallback
)(
void
*
userdata
);
CV_EXPORTS
void
createOpenGLCallback
(
const
string
&
winname
,
CvOpenGLCallback
callbackOpenGL
,
void
*
userdata
=
0
);
// Flags for set / getWindowProperty
WND_PROP_FULLSCREEN
=
CV_WND_PROP_FULLSCREEN
,
// fullscreen property
WND_PROP_AUTOSIZE
=
CV_WND_PROP_AUTOSIZE
,
// autosize property
WND_PROP_ASPECT_RATIO
=
CV_WND_PROP_ASPECTRATIO
,
// window's aspect ration
WND_PROP_OPENGL
=
CV_WND_PROP_OPENGL
// opengl support
};
CV_EXPORTS
void
saveWindowParameters
(
const
string
&
windowName
);
CV_EXPORTS
void
loadWindowParameters
(
const
string
&
windowName
);
CV_EXPORTS
int
startLoop
(
int
(
*
pt2Func
)(
int
argc
,
char
*
argv
[]),
int
argc
,
char
*
argv
[]);
CV_EXPORTS
void
stopLoop
();
CV_EXPORTS_W
void
namedWindow
(
const
string
&
winname
,
int
flags
=
WINDOW_AUTOSIZE
);
CV_EXPORTS_W
void
destroyWindow
(
const
string
&
winname
);
CV_EXPORTS_W
void
destroyAllWindows
();
typedef
void
(
CV_CDECL
*
ButtonCallback
)(
int
state
,
void
*
userdata
);
CV_EXPORTS
int
createButton
(
const
string
&
bar_name
,
ButtonCallback
on_change
,
void
*
userdata
=
NULL
,
int
type
=
CV_PUSH_BUTTON
,
bool
initial_button_state
=
0
);
//-------------------------
CV_EXPORTS_W
int
startWindowThread
();
CV_EXPORTS_W
void
imshow
(
const
string
&
winname
,
InputArray
mat
);
CV_EXPORTS_W
int
waitKey
(
int
delay
=
0
);
typedef
void
(
CV_CDECL
*
TrackbarCallback
)(
int
pos
,
void
*
userdata
);
CV_EXPORTS_W
void
imshow
(
const
string
&
winname
,
InputArray
mat
);
CV_EXPORTS
int
createTrackbar
(
const
string
&
trackbarname
,
const
string
&
winname
,
int
*
value
,
int
count
,
TrackbarCallback
onChange
=
0
,
void
*
userdata
=
0
);
CV_EXPORTS_W
void
resizeWindow
(
const
string
&
winname
,
int
width
,
int
height
);
CV_EXPORTS_W
void
moveWindow
(
const
string
&
winname
,
int
x
,
int
y
);
CV_EXPORTS_W
int
getTrackbarPos
(
const
string
&
trackbarname
,
const
string
&
winname
);
CV_EXPORTS_W
void
setTrackbarPos
(
const
string
&
trackbarname
,
const
string
&
winname
,
int
pos
);
CV_EXPORTS_W
void
setWindowProperty
(
const
string
&
winname
,
int
prop_id
,
double
prop_value
);
//YV
CV_EXPORTS_W
double
getWindowProperty
(
const
string
&
winname
,
int
prop_id
);
//YV
enum
{
...
...
@@ -127,10 +108,65 @@ enum
EVENT_FLAG_ALTKEY
=
32
};
typedef
void
(
*
MouseCallback
)(
int
event
,
int
x
,
int
y
,
int
flags
,
void
*
param
);
typedef
void
(
*
MouseCallback
)(
int
event
,
int
x
,
int
y
,
int
flags
,
void
*
userdata
);
//! assigns callback for mouse events
CV_EXPORTS
void
setMouseCallback
(
const
string
&
windowName
,
MouseCallback
onMouse
,
void
*
param
=
0
);
CV_EXPORTS
void
setMouseCallback
(
const
string
&
winname
,
MouseCallback
onMouse
,
void
*
userdata
=
0
);
typedef
void
(
CV_CDECL
*
TrackbarCallback
)(
int
pos
,
void
*
userdata
);
CV_EXPORTS
int
createTrackbar
(
const
string
&
trackbarname
,
const
string
&
winname
,
int
*
value
,
int
count
,
TrackbarCallback
onChange
=
0
,
void
*
userdata
=
0
);
CV_EXPORTS_W
int
getTrackbarPos
(
const
string
&
trackbarname
,
const
string
&
winname
);
CV_EXPORTS_W
void
setTrackbarPos
(
const
string
&
trackbarname
,
const
string
&
winname
,
int
pos
);
// OpenGL support
typedef
void
(
CV_CDECL
*
OpenGLCallback
)(
void
*
userdata
);
CV_EXPORTS
void
createOpenGLCallback
(
const
string
&
winname
,
OpenGLCallback
onOpenGlDraw
,
void
*
userdata
=
0
);
typedef
void
(
CV_CDECL
*
OpenGlDrawCallback
)(
void
*
userdata
);
static
inline
void
setOpenGlDrawCallback
(
const
string
&
winname
,
OpenGlDrawCallback
onOpenGlDraw
,
void
*
userdata
=
0
)
{
createOpenGLCallback
(
winname
,
onOpenGlDraw
,
userdata
);
}
CV_EXPORTS
void
setOpenGlContext
(
const
string
&
winname
);
CV_EXPORTS
void
updateWindow
(
const
string
&
winname
);
CV_EXPORTS
void
imshow
(
const
string
&
winname
,
const
gpu
::
GpuMat
&
d_mat
);
CV_EXPORTS
void
imshow
(
const
string
&
winname
,
const
gpu
::
GlBuffer
&
buf
);
CV_EXPORTS
void
imshow
(
const
string
&
winname
,
const
gpu
::
GlTexture
&
tex
);
//Only for Qt
CV_EXPORTS
CvFont
fontQt
(
const
string
&
nameFont
,
int
pointSize
=-
1
,
Scalar
color
=
Scalar
::
all
(
0
),
int
weight
=
CV_FONT_NORMAL
,
int
style
=
CV_STYLE_NORMAL
,
int
spacing
=
0
);
CV_EXPORTS
void
addText
(
const
Mat
&
img
,
const
string
&
text
,
Point
org
,
CvFont
font
);
CV_EXPORTS
void
displayOverlay
(
const
string
&
winname
,
const
string
&
text
,
int
delayms
);
CV_EXPORTS
void
displayStatusBar
(
const
string
&
winname
,
const
string
&
text
,
int
delayms
);
CV_EXPORTS
void
saveWindowParameters
(
const
string
&
windowName
);
CV_EXPORTS
void
loadWindowParameters
(
const
string
&
windowName
);
CV_EXPORTS
int
startLoop
(
int
(
*
pt2Func
)(
int
argc
,
char
*
argv
[]),
int
argc
,
char
*
argv
[]);
CV_EXPORTS
void
stopLoop
();
typedef
void
(
CV_CDECL
*
ButtonCallback
)(
int
state
,
void
*
userdata
);
CV_EXPORTS
int
createButton
(
const
string
&
bar_name
,
ButtonCallback
on_change
,
void
*
userdata
=
NULL
,
int
type
=
CV_PUSH_BUTTON
,
bool
initial_button_state
=
0
);
//-------------------------
enum
{
...
...
@@ -167,8 +203,6 @@ CV_EXPORTS_W bool imencode( const string& ext, InputArray img,
CV_OUT
vector
<
uchar
>&
buf
,
const
vector
<
int
>&
params
=
vector
<
int
>
());
CV_EXPORTS_W
int
waitKey
(
int
delay
=
0
);
#ifndef CV_NO_VIDEO_CAPTURE_CPP_API
template
<>
void
CV_EXPORTS
Ptr
<
CvCapture
>::
delete_obj
();
...
...
modules/highgui/include/opencv2/highgui/highgui_c.h
View file @
c2783af7
...
...
@@ -76,9 +76,6 @@ CVAPI(void) cvAddText(const CvArr* img, const char* text, CvPoint org, CvFont *a
CVAPI
(
void
)
cvDisplayOverlay
(
const
char
*
name
,
const
char
*
text
,
int
delayms
);
CVAPI
(
void
)
cvDisplayStatusBar
(
const
char
*
name
,
const
char
*
text
,
int
delayms
);
typedef
void
(
CV_CDECL
*
CvOpenGLCallback
)(
void
*
userdata
);
CVAPI
(
void
)
cvCreateOpenGLCallback
(
const
char
*
window_name
,
CvOpenGLCallback
callbackOpenGL
,
void
*
userdata
CV_DEFAULT
(
NULL
),
double
angle
CV_DEFAULT
(
-
1
),
double
zmin
CV_DEFAULT
(
-
1
),
double
zmax
CV_DEFAULT
(
-
1
));
CVAPI
(
void
)
cvSaveWindowParameters
(
const
char
*
name
);
CVAPI
(
void
)
cvLoadWindowParameters
(
const
char
*
name
);
CVAPI
(
int
)
cvStartLoop
(
int
(
*
pt2Func
)(
int
argc
,
char
*
argv
[]),
int
argc
,
char
*
argv
[]);
...
...
@@ -99,18 +96,20 @@ CVAPI(int) cvStartWindowThread();
enum
{
//These 3 flags are used by cvSet/GetWindowProperty
CV_WND_PROP_FULLSCREEN
=
0
,
//to change/get window's fullscreen property
CV_WND_PROP_AUTOSIZE
=
1
,
//to change/get window's autosize property
CV_WND_PROP_ASPECTRATIO
=
2
,
//to change/get window's aspectratio property
//
CV_WND_PROP_FULLSCREEN
=
0
,
//to change/get window's fullscreen property
CV_WND_PROP_AUTOSIZE
=
1
,
//to change/get window's autosize property
CV_WND_PROP_ASPECTRATIO
=
2
,
//to change/get window's aspectratio property
CV_WND_PROP_OPENGL
=
3
,
//to change/get window's opengl support
//These 2 flags are used by cvNamedWindow and cvSet/GetWindowProperty
CV_WINDOW_NORMAL
=
0x00000000
,
//the user can resize the window (no constraint) / also use to switch a fullscreen window to a normal size
CV_WINDOW_AUTOSIZE
=
0x00000001
,
//the user cannot resize the window, the size is constrainted by the image displayed
//
CV_WINDOW_NORMAL
=
0x00000000
,
//the user can resize the window (no constraint) / also use to switch a fullscreen window to a normal size
CV_WINDOW_AUTOSIZE
=
0x00000001
,
//the user cannot resize the window, the size is constrainted by the image displayed
CV_WINDOW_OPENGL
=
0x00001000
,
//window with opengl support
//Those flags are only for Qt
CV_GUI_EXPANDED
=
0x00000000
,
//status bar and tool bar
CV_GUI_NORMAL
=
0x00000010
,
//old fashious way
//
CV_GUI_EXPANDED
=
0x00000000
,
//status bar and tool bar
CV_GUI_NORMAL
=
0x00000010
,
//old fashious way
//These 3 flags are used by cvNamedWindow and cvSet/GetWindowProperty
CV_WINDOW_FULLSCREEN
=
1
,
//change the window to fullscreen
CV_WINDOW_FREERATIO
=
0x00000100
,
//the image expends as much as it can (no ratio constraint)
...
...
@@ -250,6 +249,14 @@ CVAPI(void) cvConvertImage( const CvArr* src, CvArr* dst, int flags CV_DEFAULT(0
/* wait for key event infinitely (delay<=0) or for "delay" milliseconds */
CVAPI
(
int
)
cvWaitKey
(
int
delay
CV_DEFAULT
(
0
));
// OpenGL support
typedef
void
(
CV_CDECL
*
CvOpenGLCallback
)(
void
*
userdata
);
CVAPI
(
void
)
cvCreateOpenGLCallback
(
const
char
*
window_name
,
CvOpenGLCallback
callbackOpenGL
,
void
*
userdata
CV_DEFAULT
(
NULL
),
double
angle
CV_DEFAULT
(
-
1
),
double
zmin
CV_DEFAULT
(
-
1
),
double
zmax
CV_DEFAULT
(
-
1
));
CVAPI
(
void
)
cvSetOpenGlContext
(
const
char
*
window_name
);
CVAPI
(
void
)
cvUpdateWindow
(
const
char
*
window_name
);
/****************************************************************************************\
* Working with Video Files and Cameras *
\****************************************************************************************/
...
...
modules/highgui/src/precomp.hpp
View file @
c2783af7
...
...
@@ -176,14 +176,18 @@ CvCapture * cvCreateCameraCapture_PvAPI (const int index);
CvVideoWriter
*
cvCreateVideoWriter_GStreamer
(
const
char
*
filename
,
int
fourcc
,
double
fps
,
CvSize
frameSize
,
int
is_color
);
//Yannick Verdie 2010
//Yannick Verdie 2010
void
cvSetModeWindow_W32
(
const
char
*
name
,
double
prop_value
);
void
cvSetModeWindow_GTK
(
const
char
*
name
,
double
prop_value
);
void
cvSetModeWindow_CARBON
(
const
char
*
name
,
double
prop_value
);
double
cvGetModeWindow_W32
(
const
char
*
name
);
double
cvGetModeWindow_GTK
(
const
char
*
name
);
double
cvGetModeWindow_CARBON
(
const
char
*
name
);
void
cvSetModeWindow_W32
(
const
char
*
name
,
double
prop_valu
e
);
void
cvSetModeWindow_GTK
(
const
char
*
name
,
double
prop_valu
e
);
void
cvSetModeWindow_CARBON
(
const
char
*
name
,
double
prop_valu
e
);
double
cvGetPropWindowAutoSize_W32
(
const
char
*
nam
e
);
double
cvGetRatioWindow_W32
(
const
char
*
nam
e
);
double
cvGetOpenGlProp_W32
(
const
char
*
nam
e
);
//for QT
#if defined (HAVE_QT)
...
...
@@ -195,6 +199,11 @@ double cvGetRatioWindow_QT(const char* name);
void
cvSetRatioWindow_QT
(
const
char
*
name
,
double
prop_value
);
#endif
// OpenGL
typedef
void
(
CV_CDECL
*
CvOpenGlCleanCallback
)(
void
*
userdata
);
void
icvSetOpenGlCleanCallback
(
const
char
*
window_name
,
CvOpenGlCleanCallback
callback
,
void
*
userdata
);
/*namespace cv
{
...
...
modules/highgui/src/window.cpp
View file @
c2783af7
This diff is collapsed.
Click to expand it.
modules/highgui/src/window_w32.cpp
View file @
c2783af7
This diff is collapsed.
Click to expand it.
samples/gpu/highgui_gpu.cpp
0 → 100644
View file @
c2783af7
#include <iostream>
#include <string>
#include "opencv2/core/core.hpp"
#include "opencv2/core/gpumat.hpp"
#include "opencv2/gpu/gpu.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/contrib/contrib.hpp"
using
namespace
std
;
using
namespace
cv
;
using
namespace
cv
::
gpu
;
struct
Timer
{
Timer
(
const
string
&
msg_
)
{
msg
=
msg_
;
tm
.
reset
();
tm
.
start
();
}
~
Timer
()
{
tm
.
stop
();
cout
<<
msg
<<
" "
<<
tm
.
getTimeMilli
()
<<
" ms
\n
"
;
}
string
msg
;
TickMeter
tm
;
};
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
<
2
)
{
cout
<<
"Usage: "
<<
argv
[
0
]
<<
" image"
<<
endl
;
return
-
1
;
}
try
{
bool
haveCuda
=
getCudaEnabledDeviceCount
()
>
0
;
namedWindow
(
"OpenGL Mat"
,
WINDOW_OPENGL
|
WINDOW_AUTOSIZE
);
namedWindow
(
"OpenGL GlBuffer"
,
WINDOW_OPENGL
|
WINDOW_AUTOSIZE
);
namedWindow
(
"OpenGL GlTexture"
,
WINDOW_OPENGL
|
WINDOW_AUTOSIZE
);
if
(
haveCuda
)
namedWindow
(
"OpenGL GpuMat"
,
WINDOW_OPENGL
|
WINDOW_AUTOSIZE
);
namedWindow
(
"Mat"
,
WINDOW_AUTOSIZE
);
Mat
img
=
imread
(
argv
[
1
]);
if
(
haveCuda
)
setGlDevice
();
setOpenGlContext
(
"OpenGL GlBuffer"
);
GlBuffer
buf
(
img
,
GlBuffer
::
TEXTURE_BUFFER
);
setOpenGlContext
(
"OpenGL GlTexture"
);
GlTexture
tex
(
img
);
GpuMat
d_img
;
if
(
haveCuda
)
d_img
.
upload
(
img
);
cout
<<
"=== First call
\n\n
"
;
{
Timer
t
(
"OpenGL Mat "
);
imshow
(
"OpenGL Mat"
,
img
);
}
{
Timer
t
(
"OpenGL GlBuffer "
);
imshow
(
"OpenGL GlBuffer"
,
buf
);
}
{
Timer
t
(
"OpenGL GlTexture"
);
imshow
(
"OpenGL GlTexture"
,
tex
);
}
if
(
haveCuda
)
{
Timer
t
(
"OpenGL GpuMat "
);
imshow
(
"OpenGL GpuMat"
,
d_img
);
}
{
Timer
t
(
"Mat "
);
imshow
(
"Mat"
,
img
);
}
cout
<<
"
\n
=== Second call
\n\n
"
;
{
Timer
t
(
"OpenGL Mat "
);
imshow
(
"OpenGL Mat"
,
img
);
}
{
Timer
t
(
"OpenGL GlBuffer "
);
imshow
(
"OpenGL GlBuffer"
,
buf
);
}
{
Timer
t
(
"OpenGL GlTexture"
);
imshow
(
"OpenGL GlTexture"
,
tex
);
}
if
(
haveCuda
)
{
Timer
t
(
"OpenGL GpuMat "
);
imshow
(
"OpenGL GpuMat"
,
d_img
);
}
{
Timer
t
(
"Mat "
);
imshow
(
"Mat"
,
img
);
}
cout
<<
"
\n
"
;
waitKey
();
}
catch
(
const
exception
&
e
)
{
cout
<<
e
.
what
()
<<
endl
;
}
return
0
;
}
\ No newline at end of file
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