Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
2c84a66e
O
Opencv
项目概览
Greenplum
/
Opencv
11 个月 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2c84a66e
编写于
7月 15, 2010
作者:
A
Anatoly Baksheev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added support to build without cuda.
上级
e1bd5aea
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
164 addition
and
133 deletion
+164
-133
CMakeLists.txt
CMakeLists.txt
+16
-0
cvconfig.h.cmake
cvconfig.h.cmake
+3
-0
modules/core/include/opencv2/core/types_c.h
modules/core/include/opencv2/core/types_c.h
+3
-1
modules/gpu/CMakeLists.txt
modules/gpu/CMakeLists.txt
+83
-93
modules/gpu/include/opencv2/gpu/gpu.hpp
modules/gpu/include/opencv2/gpu/gpu.hpp
+10
-3
modules/gpu/src/cudastream.cpp
modules/gpu/src/cudastream.cpp
+15
-11
modules/gpu/src/initialization.cpp
modules/gpu/src/initialization.cpp
+13
-1
modules/gpu/src/precomp.hpp
modules/gpu/src/precomp.hpp
+20
-22
modules/gpu/src/stereobm_gpu.cpp
modules/gpu/src/stereobm_gpu.cpp
+1
-2
未找到文件。
CMakeLists.txt
浏览文件 @
2c84a66e
...
...
@@ -282,6 +282,7 @@ endif()
set
(
WITH_TBB OFF CACHE BOOL
"Include TBB support"
)
set
(
WITH_EIGEN2 ON CACHE BOOL
"Include Eigen2 support"
)
set
(
WITH_CUDA OFF CACHE BOOL
"Include NVidia Cuda Runtime support"
)
# ===================================================
# Macros that checks if module have been installed.
...
...
@@ -608,6 +609,15 @@ if (WITH_TBB)
endif
()
endif
()
############################### TBB ################################
if
(
WITH_CUDA
)
find_package
(
CUDA
)
if
(
CUDA_FOUND
)
message
(
STATUS
"CUDA detected."
)
set
(
HAVE_CUDA 1
)
endif
()
endif
()
############################## Eigen2 ##############################
...
...
@@ -1249,6 +1259,12 @@ else()
message
(
STATUS
" Use TBB: NO"
)
endif
()
if
(
HAVE_CUDA
)
message
(
STATUS
" Uue Cuda: YES"
)
else
()
message
(
STATUS
" Use Cuda: No"
)
endif
()
if
(
HAVE_EIGEN2
)
message
(
STATUS
" Use Eigen2: YES"
)
else
()
...
...
cvconfig.h.cmake
浏览文件 @
2c84a66e
...
...
@@ -165,3 +165,6 @@
/* Qt bindings use OpenGL */
#cmakedefine HAVE_HAVE_QT_OPENGL
/* NVidia Cuda Runtime API*/
#cmakedefine HAVE_CUDA
modules/core/include/opencv2/core/types_c.h
浏览文件 @
2c84a66e
...
...
@@ -229,7 +229,9 @@ enum {
CV_StsParseError
=
-
212
,
/* invalid syntax/structure of the parsed file */
CV_StsNotImplemented
=
-
213
,
/* the requested function/feature is not implemented */
CV_StsBadMemBlock
=
-
214
,
/* an allocated block has been corrupted */
CV_StsAssert
=
-
215
/* assertion failed */
CV_StsAssert
=
-
215
,
/* assertion failed */
CV_GpuNotFound
=
-
216
,
CV_GpuApiCallError
=
-
217
};
/****************************************************************************************\
...
...
modules/gpu/CMakeLists.txt
浏览文件 @
2c84a66e
include
(
FindCUDA
)
if
(
CUDA_FOUND
)
include_directories
(
${
CUDA_INCLUDE_DIRS
}
)
link_directories
(
${
CUDA_LIBRARIES
}
)
set
(
name
"gpu"
)
set
(
DEPS
"opencv_core"
)
#message ("CUDA_LIBRARIES = ${CUDA_LIBRARIES}")
#message ("CUDA_INCLUDE_DIRS = ${CUDA_INCLUDE_DIRS}")
#message ("CUDA_TARGET_LINK = ${CUDA_TARGET_LINK}")
set
(
the_target
"opencv_
${
name
}
"
)
project
(
${
the_target
}
)
#CUDA_GENERATED_OUTPUT_DIR (Default CMAKE_CURRENT_BINARY_DIR
)
add_definitions
(
-DCVAPI_EXPORTS
)
#====================================================================================
set
(
name
"gpu"
)
set
(
DEPS
"opencv_core"
)
project
(
opencv_
${
name
}
)
add_definitions
(
-DCVAPI_EXPORTS
)
include_directories
(
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/include"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/cuda"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/src"
"
${
CMAKE_CURRENT_BINARY_DIR
}
"
)
foreach
(
d
${
DEPS
}
)
if
(
${
d
}
MATCHES
"opencv_"
)
string
(
REPLACE
"opencv_"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../"
d_dir
${
d
}
)
include_directories
(
"
${
d_dir
}
/include"
)
endif
()
endforeach
()
file
(
GLOB lib_srcs
"src/*.cpp"
)
file
(
GLOB lib_int_hdrs
"src/*.h*"
)
file
(
GLOB lib_cuda
"cuda/*.cu"
)
file
(
GLOB lib_cuda_hdrs
"cuda/*.h*"
)
source_group
(
"Src"
FILES
${
lib_srcs
}
${
lib_int_hdrs
}
)
source_group
(
"Cuda"
FILES
${
lib_cuda
}
${
lib_cuda_hdrs
}
)
file
(
GLOB lib_hdrs
"include/opencv2/
${
name
}
/*.h*"
)
source_group
(
"Include"
FILES
${
lib_hdrs
}
)
if
(
UNIX OR APPLE
)
set
(
CUDA_NVCC_FLAGS
"-Xcompiler;-fPIC"
)
endif
()
include_directories
(
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/include"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/cuda"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/src"
"
${
CMAKE_CURRENT_BINARY_DIR
}
"
)
CUDA_COMPILE
(
cuda_objs
${
lib_cuda
}
)
#message ("lib cuda : ${cuda_objs}")
#CUDA_BUILD_CLEAN_TARGET()
set
(
the_target
"opencv_
${
name
}
"
)
#message ("cuda_add_library : ${the_target} ${lib_srcs} ${lib_hdrs} ${lib_int_hdrs} ${lib_cuda} ${lib_cuda_hdrs}")
add_library
(
${
the_target
}
${
lib_srcs
}
${
lib_hdrs
}
${
lib_int_hdrs
}
${
lib_cuda
}
${
lib_cuda_hdrs
}
${
cuda_objs
}
)
if
(
PCHSupport_FOUND
)
set
(
pch_header
${
CMAKE_CURRENT_SOURCE_DIR
}
/src/precomp.hpp
)
if
(
${
CMAKE_GENERATOR
}
MATCHES
"Visual*"
OR
${
CMAKE_GENERATOR
}
MATCHES
"Xcode*"
)
if
(
${
CMAKE_GENERATOR
}
MATCHES
"Visual*"
)
set
(
${
the_target
}
_pch
"src/precomp.cpp"
)
endif
()
add_native_precompiled_header
(
${
the_target
}
${
pch_header
}
)
elseif
(
CMAKE_COMPILER_IS_GNUCXX AND
${
CMAKE_GENERATOR
}
MATCHES
".*Makefiles"
)
add_precompiled_header
(
${
the_target
}
${
pch_header
}
)
endif
()
foreach
(
d
${
DEPS
}
)
if
(
${
d
}
MATCHES
"opencv_"
)
string
(
REPLACE
"opencv_"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../"
d_dir
${
d
}
)
include_directories
(
"
${
d_dir
}
/include"
)
endif
()
endforeach
()
# For dynamic link numbering convenions
set_target_properties
(
${
the_target
}
PROPERTIES
VERSION
${
OPENCV_VERSION
}
SOVERSION
${
OPENCV_SOVERSION
}
OUTPUT_NAME
"
${
the_target
}${
OPENCV_DLLVERSION
}
"
)
file
(
GLOB lib_srcs
"src/*.cpp"
)
file
(
GLOB lib_int_hdrs
"src/*.h*"
)
file
(
GLOB lib_cuda
"cuda/*.cu"
)
file
(
GLOB lib_cuda_hdrs
"cuda/*.h*"
)
source_group
(
"Src"
FILES
${
lib_srcs
}
${
lib_int_hdrs
}
)
source_group
(
"Cuda"
FILES
${
lib_cuda
}
${
lib_cuda_hdrs
}
)
# Additional target properties
set_target_properties
(
${
the_target
}
PROPERTIES
DEBUG_POSTFIX
"
${
OPENCV_DEBUG_POSTFIX
}
"
ARCHIVE_OUTPUT_DIRECTORY
"
${
CMAKE_BINARY_DIR
}
/lib/"
RUNTIME_OUTPUT_DIRECTORY
"
${
CMAKE_BINARY_DIR
}
/bin/"
INSTALL_NAME_DIR
"
${
CMAKE_INSTALL_PREFIX
}
/lib"
)
file
(
GLOB lib_hdrs
"include/opencv2/
${
name
}
/*.h*"
)
source_group
(
"Include"
FILES
${
lib_hdrs
}
)
# Add the required libraries for linking:
#message (" ++++ target_link_libraries = ${the_target} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${DEPS} ${CUDA_LIBRARIES}"
)
target_link_libraries
(
${
the_target
}
${
OPENCV_LINKER_LIBS
}
${
IPP_LIBS
}
${
DEPS
}
${
CUDA_LIBRARIES
}
)
if
(
HAVE_CUDA
)
include_directories
(
${
CUDA_INCLUDE_DIRS
}
)
link_directories
(
${
CUDA_LIBRARIES
}
)
if
(
MSVC
)
if
(
CMAKE_CROSSCOMPILING
)
set_target_properties
(
${
the_target
}
PROPERTIES
LINK_FLAGS
"/NODEFAULTLIB:secchk"
)
endif
()
if
(
UNIX OR APPLE
)
set
(
CUDA_NVCC_FLAGS
"-Xcompiler;-fPIC"
)
endif
()
CUDA_COMPILE
(
cuda_objs
${
lib_cuda
}
)
#CUDA_BUILD_CLEAN_TARGET()
endif
()
add_library
(
${
the_target
}
${
lib_srcs
}
${
lib_hdrs
}
${
lib_int_hdrs
}
${
lib_cuda
}
${
lib_cuda_hdrs
}
${
cuda_objs
}
)
if
(
PCHSupport_FOUND
)
set
(
pch_header
${
CMAKE_CURRENT_SOURCE_DIR
}
/src/precomp.hpp
)
if
(
${
CMAKE_GENERATOR
}
MATCHES
"Visual*"
OR
${
CMAKE_GENERATOR
}
MATCHES
"Xcode*"
)
if
(
${
CMAKE_GENERATOR
}
MATCHES
"Visual*"
)
set
(
${
the_target
}
_pch
"src/precomp.cpp"
)
endif
()
add_native_precompiled_header
(
${
the_target
}
${
pch_header
}
)
elseif
(
CMAKE_COMPILER_IS_GNUCXX AND
${
CMAKE_GENERATOR
}
MATCHES
".*Makefiles"
)
add_precompiled_header
(
${
the_target
}
${
pch_header
}
)
endif
()
endif
()
# For dynamic link numbering convenions
set_target_properties
(
${
the_target
}
PROPERTIES
VERSION
${
OPENCV_VERSION
}
SOVERSION
${
OPENCV_SOVERSION
}
OUTPUT_NAME
"
${
the_target
}${
OPENCV_DLLVERSION
}
"
)
# Additional target properties
set_target_properties
(
${
the_target
}
PROPERTIES
DEBUG_POSTFIX
"
${
OPENCV_DEBUG_POSTFIX
}
"
ARCHIVE_OUTPUT_DIRECTORY
"
${
CMAKE_BINARY_DIR
}
/lib/"
RUNTIME_OUTPUT_DIRECTORY
"
${
CMAKE_BINARY_DIR
}
/bin/"
INSTALL_NAME_DIR
"
${
CMAKE_INSTALL_PREFIX
}
/lib"
)
# Add the required libraries for linking:
target_link_libraries
(
${
the_target
}
${
OPENCV_LINKER_LIBS
}
${
IPP_LIBS
}
${
DEPS
}
${
CUDA_LIBRARIES
}
)
if
(
MSVC
)
if
(
CMAKE_CROSSCOMPILING
)
set_target_properties
(
${
the_target
}
PROPERTIES
LINK_FLAGS
"/NODEFAULTLIB:
libc
"
LINK_FLAGS
"/NODEFAULTLIB:
secchk
"
)
endif
()
set_target_properties
(
${
the_target
}
PROPERTIES
LINK_FLAGS
"/NODEFAULTLIB:libc"
)
endif
()
# Dependencies of this target:
add_dependencies
(
${
the_target
}
${
DEPS
}
)
# Dependencies of this target:
add_dependencies
(
${
the_target
}
${
DEPS
}
)
install
(
TARGETS
${
the_target
}
RUNTIME DESTINATION bin COMPONENT main
LIBRARY DESTINATION lib COMPONENT main
ARCHIVE DESTINATION lib COMPONENT main
)
install
(
TARGETS
${
the_target
}
RUNTIME DESTINATION bin COMPONENT main
LIBRARY DESTINATION lib COMPONENT main
ARCHIVE DESTINATION lib COMPONENT main
)
install
(
FILES
${
lib_hdrs
}
DESTINATION include/opencv2/
${
name
}
COMPONENT main
)
install
(
FILES
${
lib_hdrs
}
DESTINATION include/opencv2/
${
name
}
COMPONENT main
)
endif
()
modules/gpu/include/opencv2/gpu/gpu.hpp
浏览文件 @
2c84a66e
...
...
@@ -216,6 +216,9 @@ namespace cv
class
CudaStream
{
public:
static
CudaStream
empty
();
CudaStream
();
~
CudaStream
();
...
...
@@ -235,10 +238,14 @@ namespace cv
// converts matrix type, ex from float to uchar depending on type
void
enqueueConvert
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
int
type
);
//CUstream_st& getStream();
struct
Impl
;
const
Impl
&
getImpl
()
const
;
private:
void
*
impl
;
Impl
*
impl
;
CudaStream
(
const
CudaStream
&
);
CudaStream
&
operator
=
(
const
CudaStream
&
);
...
...
modules/gpu/src/cudastream.cpp
浏览文件 @
2c84a66e
...
...
@@ -41,33 +41,37 @@
//M*/
#include "precomp.hpp"
#include "opencv2/gpu/stream_access.hpp"
using
namespace
cv
;
using
namespace
cv
::
gpu
;
cv
::
gpu
::
CudaStream
::
CudaStream
()
:
impl
(
fastMalloc
(
sizeof
(
cudaStream_t
))
)
cv
::
gpu
::
CudaStream
::
CudaStream
()
:
impl
(
(
Impl
*
)
fastMalloc
(
sizeof
(
Impl
))
)
{
cudaSafeCall
(
cudaStreamCreate
((
cudaStream_t
*
)
impl
)
);
//cudaSafeCall( cudaStreamCreate( &impl->stream
) );
}
cv
::
gpu
::
CudaStream
::~
CudaStream
()
{
cudaSafeCall
(
cudaStreamDestroy
(
*
(
cudaStream_t
*
)
impl
)
);
cv
::
fastFree
(
impl
);
if
(
impl
)
{
cudaSafeCall
(
cudaStreamDestroy
(
*
(
cudaStream_t
*
)
impl
)
);
cv
::
fastFree
(
impl
);
}
}
bool
cv
::
gpu
::
CudaStream
::
queryIfComplete
()
{
cudaError_t
err
=
cudaStreamQuery
(
*
(
cudaStream_t
*
)
impl
);
//
cudaError_t err = cudaStreamQuery( *(cudaStream_t*)impl );
if
(
err
==
cudaSuccess
)
return
true
;
//
if (err == cudaSuccess)
//
return true;
if
(
err
==
cudaErrorNotReady
)
return
false
;
//
if (err == cudaErrorNotReady)
//
return false;
//cudaErrorInvalidResourceHandle
cudaSafeCall
(
err
);
//
//
cudaErrorInvalidResourceHandle
//
cudaSafeCall( err );
return
true
;
}
void
cv
::
gpu
::
CudaStream
::
waitForCompletion
()
...
...
modules/gpu/src/initialization.cpp
浏览文件 @
2c84a66e
...
...
@@ -45,6 +45,16 @@
using
namespace
cv
;
using
namespace
cv
::
gpu
;
#ifndef HAVE_CUDA
CV_EXPORTS
int
cv
::
gpu
::
getCudaEnabledDeviceCount
()
{
return
0
;
}
CV_EXPORTS
string
cv
::
gpu
::
getDeviceName
(
int
/*device*/
)
{
cudaSafeCall
(
0
);
return
0
;
}
CV_EXPORTS
void
cv
::
gpu
::
setDevice
(
int
/*device*/
)
{
cudaSafeCall
(
0
);
}
CV_EXPORTS
void
cv
::
gpu
::
getComputeCapability
(
int
/*device*/
,
int
*
/*major*/
,
int
*
/*minor*/
)
{
cudaSafeCall
(
0
);
}
CV_EXPORTS
int
cv
::
gpu
::
getNumberOfSMs
(
int
/*device*/
)
{
cudaSafeCall
(
0
);
return
0
;
}
#else
CV_EXPORTS
int
cv
::
gpu
::
getCudaEnabledDeviceCount
()
{
int
count
;
...
...
@@ -78,4 +88,6 @@ CV_EXPORTS int cv::gpu::getNumberOfSMs(int device)
cudaDeviceProp
prop
;
cudaSafeCall
(
cudaGetDeviceProperties
(
&
prop
,
device
)
);
return
prop
.
multiProcessorCount
;
}
\ No newline at end of file
}
#endif
\ No newline at end of file
modules/gpu/src/precomp.hpp
浏览文件 @
2c84a66e
...
...
@@ -57,41 +57,39 @@
#include "cuda_shared.hpp"
#ifndef HAVE_CUDA
#define cudaSafeCall(err) CV_Error(CV_GpuNotFound, "The library is compilled with no GPU support")
#define cudaCallerSafeCall(err) CV_Error(CV_GpuNotFound, "The library is compilled with no GPU support")
#else
/* HAVE_CUDA */
#if _MSC_VER >= 1200
#pragma warning (disable : 4100 4211 4201 4408)
#pragma warning (disable : 4100 4211 4201 4408)
#endif
#include "cuda_runtime_api.h"
#define cudaCallerSafeCall(err) err;
#define cudaSafeCall(err) __cudaSafeCall(err, __FILE__, __LINE__)
//inline void __cudaSafeCall( cudaError err, const char *file, const int line )
//{
// if( cudaSuccess != err)
// CV_Error_(CV_StsAssert, ("%s(%i) : Runtime API error : %s.\n", cudaGetErrorString(err)));
//}
#ifdef __GNUC__
#define cudaSafeCall(err) __cudaSafeCall(err, __FILE__, __LINE__, __func__)
#else
#define cudaSafeCall(err) __cudaSafeCall(err, __FILE__, __LINE__)
#endif
namespace
cv
{
namespace
gpu
{
inline
void
__cudaSafeCall
(
cudaError
err
,
const
char
*
file
,
const
int
line
)
{
static
inline
void
__cudaSafeCall
(
cudaError
err
,
const
char
*
file
,
const
int
line
,
const
char
*
func
=
""
)
{
if
(
cudaSuccess
!=
err
)
{
std
::
cerr
<<
file
<<
"("
<<
line
<<
") : cudaSafeCall() Runtime API error : "
<<
cudaGetErrorString
(
err
)
<<
"
\n
"
;
exit
(
-
1
);
}
}
template
<
class
T
>
inline
DevMem2D_
<
T
>
getDevMem
(
const
GpuMat
&
mat
)
{
return
DevMem2D_
<
T
>
(
mat
.
rows
,
mat
.
cols
,
mat
.
data
,
mat
.
step
);
}
cv
::
error
(
cv
::
Exception
(
CV_GpuApiCallError
,
cudaGetErrorString
(
err
),
func
,
file
,
line
)
);
}
}
}
#endif
/* HAVE_CUDA */
#endif
modules/gpu/src/stereobm_gpu.cpp
浏览文件 @
2c84a66e
...
...
@@ -41,7 +41,6 @@
//M*/
#include "precomp.hpp"
#include <limits>
using
namespace
cv
;
using
namespace
cv
::
gpu
;
...
...
@@ -69,5 +68,5 @@ void StereoBM_GPU::operator() ( const GpuMat& left, const GpuMat& right, GpuMat&
DevMem2D
disp
=
disparity
;
DevMem2D_
<
uint
>
mssd
=
minSSD
;
impl
::
stereoBM_GPU
(
left
,
right
,
disp
,
ndisp
,
mssd
);
cudaCallerSafeCall
(
impl
::
stereoBM_GPU
(
left
,
right
,
disp
,
ndisp
,
mssd
)
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录