Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
8fb6b689
O
Opencv
项目概览
Greenplum
/
Opencv
大约 1 年 前同步成功
通知
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,发现更多精彩内容 >>
提交
8fb6b689
编写于
8月 16, 2013
作者:
J
Jin Ma
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1. Added OpenCL version of superres to the sample.
2. Modified according to the feedback of the community.
上级
95143fdc
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
136 addition
and
13 deletion
+136
-13
samples/gpu/CMakeLists.txt
samples/gpu/CMakeLists.txt
+8
-1
samples/gpu/super_resolution.cpp
samples/gpu/super_resolution.cpp
+128
-12
未找到文件。
samples/gpu/CMakeLists.txt
浏览文件 @
8fb6b689
...
...
@@ -2,7 +2,6 @@ SET(OPENCV_GPU_SAMPLES_REQUIRED_DEPS opencv_core opencv_flann opencv_imgproc ope
opencv_ml opencv_video opencv_objdetect opencv_features2d
opencv_calib3d opencv_legacy opencv_contrib opencv_gpu
opencv_superres
)
ocv_check_dependencies
(
${
OPENCV_GPU_SAMPLES_REQUIRED_DEPS
}
)
if
(
BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND
)
...
...
@@ -25,6 +24,10 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
ocv_include_directories
(
${
CUDA_INCLUDE_DIRS
}
)
endif
()
if
(
HAVE_OPENCL
)
ocv_include_directories
(
"
${
OpenCV_SOURCE_DIR
}
/modules/ocl/include"
)
endif
()
if
(
CMAKE_COMPILER_IS_GNUCXX AND NOT ENABLE_NOISY_WARNINGS
)
set
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
-Wno-unused-function"
)
endif
()
...
...
@@ -41,6 +44,10 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
target_link_libraries
(
${
the_target
}
opencv_nonfree
)
endif
()
if
(
HAVE_OPENCL
)
target_link_libraries
(
${
the_target
}
opencv_ocl
)
endif
()
set_target_properties
(
${
the_target
}
PROPERTIES
OUTPUT_NAME
"
${
project
}
-example-
${
name
}
"
PROJECT_LABEL
"(EXAMPLE_
${
project_upper
}
)
${
name
}
"
)
...
...
samples/gpu/super_resolution.cpp
浏览文件 @
8fb6b689
...
...
@@ -7,11 +7,16 @@
#include "opencv2/contrib/contrib.hpp"
#include "opencv2/superres/superres.hpp"
#include "opencv2/superres/optical_flow.hpp"
#include "opencv2/opencv_modules.hpp"
#if defined(HAVE_OPENCV_OCL)
#include "opencv2/ocl/ocl.hpp"
#endif
using
namespace
std
;
using
namespace
cv
;
using
namespace
cv
::
superres
;
bool
useOclChanged
;
#define MEASURE_TIME(op) \
{ \
TickMeter tm; \
...
...
@@ -49,9 +54,38 @@ static Ptr<DenseOpticalFlowExt> createOptFlow(const string& name, bool useGpu)
exit
(
-
1
);
}
}
#if defined(HAVE_OPENCV_OCL)
static
Ptr
<
DenseOpticalFlowExt
>
createOptFlow
(
const
string
&
name
)
{
if
(
name
==
"farneback"
)
{
return
createOptFlow_Farneback_OCL
();
}
else
if
(
name
==
"simple"
)
{
useOclChanged
=
true
;
std
::
cout
<<
"simple on OpenCL has not been implemented. Use CPU instead!
\n
"
;
return
createOptFlow_Simple
();
}
else
if
(
name
==
"tvl1"
)
return
createOptFlow_DualTVL1_OCL
();
else
if
(
name
==
"brox"
)
{
std
::
cout
<<
"brox has not been implemented!
\n
"
;
return
NULL
;
}
else
if
(
name
==
"pyrlk"
)
return
createOptFlow_PyrLK_OCL
();
else
{
cerr
<<
"Incorrect Optical Flow algorithm - "
<<
name
<<
endl
;
}
return
0
;
}
#endif
int
main
(
int
argc
,
const
char
*
argv
[])
{
useOclChanged
=
false
;
CommandLineParser
cmd
(
argc
,
argv
,
"{ v | video | | Input video }"
"{ o | output | | Output video }"
...
...
@@ -59,7 +93,7 @@ int main(int argc, const char* argv[])
"{ i | iterations | 180 | Iteration count }"
"{ t | temporal | 4 | Radius of the temporal search area }"
"{ f | flow | farneback | Optical flow algorithm (farneback, simple, tvl1, brox, pyrlk) }"
"{ g
pu | gpu | false | Use GPU
}"
"{ g
| gpu | | CPU as default device, cuda for CUDA and ocl for OpenCL
}"
"{ h | help | false | Print help message }"
);
...
...
@@ -76,21 +110,79 @@ int main(int argc, const char* argv[])
const
int
iterations
=
cmd
.
get
<
int
>
(
"iterations"
);
const
int
temporalAreaRadius
=
cmd
.
get
<
int
>
(
"temporal"
);
const
string
optFlow
=
cmd
.
get
<
string
>
(
"flow"
);
const
bool
useGpu
=
cmd
.
get
<
bool
>
(
"gpu"
);
string
gpuOption
=
cmd
.
get
<
string
>
(
"gpu"
);
std
::
transform
(
gpuOption
.
begin
(),
gpuOption
.
end
(),
gpuOption
.
begin
(),
::
tolower
);
bool
useCuda
=
false
;
bool
useOcl
=
false
;
if
(
gpuOption
.
compare
(
"ocl"
)
==
0
)
useOcl
=
true
;
else
if
(
gpuOption
.
compare
(
"cuda"
)
==
0
)
useCuda
=
true
;
#ifndef HAVE_OPENCV_OCL
if
(
useOcl
)
{
{
cout
<<
"OPENCL is not compiled
\n
"
;
return
0
;
}
}
#endif
#if defined(HAVE_OPENCV_OCL)
std
::
vector
<
cv
::
ocl
::
Info
>
info
;
if
(
useCuda
)
{
CV_Assert
(
!
useOcl
);
info
.
clear
();
}
if
(
useOcl
)
{
CV_Assert
(
!
useCuda
);
cv
::
ocl
::
getDevice
(
info
);
}
#endif
Ptr
<
SuperResolution
>
superRes
;
if
(
useGpu
)
superRes
=
createSuperResolution_BTVL1_GPU
();
#if defined(HAVE_OPENCV_OCL)
if
(
useOcl
)
{
Ptr
<
DenseOpticalFlowExt
>
of
=
createOptFlow
(
optFlow
);
if
(
of
.
empty
())
exit
(
-
1
);
if
(
useOclChanged
)
{
superRes
=
createSuperResolution_BTVL1
();
useOcl
=
!
useOcl
;
}
else
superRes
=
createSuperResolution_BTVL1_OCL
();
superRes
->
set
(
"opticalFlow"
,
of
);
}
else
superRes
=
createSuperResolution_BTVL1
();
#endif
{
if
(
useCuda
)
superRes
=
createSuperResolution_BTVL1_GPU
();
else
superRes
=
createSuperResolution_BTVL1
();
Ptr
<
DenseOpticalFlowExt
>
of
=
createOptFlow
(
optFlow
,
useCuda
);
if
(
of
.
empty
())
exit
(
-
1
);
superRes
->
set
(
"opticalFlow"
,
of
);
}
superRes
->
set
(
"scale"
,
scale
);
superRes
->
set
(
"iterations"
,
iterations
);
superRes
->
set
(
"temporalAreaRadius"
,
temporalAreaRadius
);
superRes
->
set
(
"opticalFlow"
,
createOptFlow
(
optFlow
,
useGpu
));
Ptr
<
FrameSource
>
frameSource
;
if
(
use
Gpu
)
if
(
use
Cuda
)
{
// Try to use gpu Video Decoding
try
...
...
@@ -116,7 +208,11 @@ int main(int argc, const char* argv[])
cout
<<
"Iterations : "
<<
iterations
<<
endl
;
cout
<<
"Temporal radius : "
<<
temporalAreaRadius
<<
endl
;
cout
<<
"Optical Flow : "
<<
optFlow
<<
endl
;
cout
<<
"Mode : "
<<
(
useGpu
?
"GPU"
:
"CPU"
)
<<
endl
;
#if defined(HAVE_OPENCV_OCL)
cout
<<
"Mode : "
<<
(
useCuda
?
"CUDA"
:
useOcl
?
"OpenCL"
:
"CPU"
)
<<
endl
;
#else
cout
<<
"Mode : "
<<
(
useGpu
?
"CUDA"
:
"CPU"
)
<<
endl
;
#endif
}
superRes
->
setInput
(
frameSource
);
...
...
@@ -126,10 +222,30 @@ int main(int argc, const char* argv[])
for
(
int
i
=
0
;;
++
i
)
{
cout
<<
'['
<<
setw
(
3
)
<<
i
<<
"] : "
;
Mat
result
;
MEASURE_TIME
(
superRes
->
nextFrame
(
result
));
#if defined(HAVE_OPENCV_OCL)
cv
::
ocl
::
oclMat
result_
;
if
(
useOcl
)
{
MEASURE_TIME
(
superRes
->
nextFrame
(
result_
));
}
else
#endif
{
MEASURE_TIME
(
superRes
->
nextFrame
(
result
));
}
#ifdef HAVE_OPENCV_OCL
if
(
useOcl
)
{
if
(
!
result_
.
empty
())
{
result_
.
download
(
result
);
}
}
#endif
if
(
result
.
empty
())
break
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录