Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
a2090a44
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,发现更多精彩内容 >>
提交
a2090a44
编写于
10月 24, 2011
作者:
A
Alexey Spizhevoy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Updated CLI for GPU samples
上级
5656a9dd
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
247 addition
and
131 deletion
+247
-131
samples/gpu/cascadeclassifier.cpp
samples/gpu/cascadeclassifier.cpp
+55
-21
samples/gpu/driver_api_multi.cpp
samples/gpu/driver_api_multi.cpp
+7
-1
samples/gpu/driver_api_stereo_multi.cpp
samples/gpu/driver_api_stereo_multi.cpp
+25
-12
samples/gpu/hog.cpp
samples/gpu/hog.cpp
+57
-49
samples/gpu/morfology.cpp
samples/gpu/morfology.cpp
+1
-1
samples/gpu/optical_flow.cpp
samples/gpu/optical_flow.cpp
+18
-7
samples/gpu/opticalflow_nvidia_api.cpp
samples/gpu/opticalflow_nvidia_api.cpp
+14
-4
samples/gpu/stereo_match.cpp
samples/gpu/stereo_match.cpp
+26
-16
samples/gpu/stereo_multi.cpp
samples/gpu/stereo_multi.cpp
+24
-12
samples/gpu/surf_keypoint_matcher.cpp
samples/gpu/surf_keypoint_matcher.cpp
+20
-8
未找到文件。
samples/gpu/cascadeclassifier.cpp
浏览文件 @
a2090a44
...
...
@@ -19,7 +19,7 @@ using namespace cv::gpu;
void
help
()
{
cout
<<
"Usage: ./cascadeclassifier
<cascade_file> <image_or_video_or_cameraid>
\n
"
cout
<<
"Usage: ./cascadeclassifier
_gpu
\n\t
--cascade <cascade_file>
\n\t
(<image>|--video <video>|--camera <camera_id>)
\n
"
"Using OpenCV version "
<<
CV_VERSION
<<
endl
<<
endl
;
}
...
...
@@ -98,9 +98,10 @@ void displayState(Mat &canvas, bool bHelp, bool bGpu, bool bLargestFace, bool bF
int
main
(
int
argc
,
const
char
*
argv
[])
{
if
(
argc
!=
3
)
if
(
argc
==
1
)
{
return
help
(),
-
1
;
help
();
return
-
1
;
}
if
(
getCudaEnabledDeviceCount
()
==
0
)
...
...
@@ -108,10 +109,42 @@ int main(int argc, const char *argv[])
return
cerr
<<
"No GPU found or the library is compiled without GPU support"
<<
endl
,
-
1
;
}
VideoCapture
capture
;
string
cascadeName
;
string
inputName
;
bool
isInputImage
=
false
;
bool
isInputVideo
=
false
;
bool
isInputCamera
=
false
;
string
cascadeName
=
argv
[
1
];
string
inputName
=
argv
[
2
];
for
(
int
i
=
1
;
i
<
argc
;
++
i
)
{
if
(
string
(
argv
[
i
])
==
"--cascade"
)
cascadeName
=
argv
[
++
i
];
else
if
(
string
(
argv
[
i
])
==
"--video"
)
{
inputName
=
argv
[
++
i
];
isInputVideo
=
true
;
}
else
if
(
string
(
argv
[
i
])
==
"--camera"
)
{
inputName
=
argv
[
++
i
];
isInputCamera
=
true
;
}
else
if
(
string
(
argv
[
i
])
==
"--help"
)
{
help
();
return
-
1
;
}
else
if
(
!
isInputImage
)
{
inputName
=
argv
[
i
];
isInputImage
=
true
;
}
else
{
cout
<<
"Unknown key: "
<<
argv
[
i
]
<<
endl
;
return
-
1
;
}
}
CascadeClassifier_GPU
cascade_gpu
;
if
(
!
cascade_gpu
.
load
(
cascadeName
))
...
...
@@ -125,22 +158,23 @@ int main(int argc, const char *argv[])
return
cerr
<<
"ERROR: Could not load cascade classifier
\"
"
<<
cascadeName
<<
"
\"
"
<<
endl
,
help
(),
-
1
;
}
Mat
image
=
imread
(
inputName
);
VideoCapture
capture
;
Mat
image
;
if
(
i
mage
.
empty
()
)
if
(
i
sInputImage
)
{
i
f
(
!
capture
.
open
(
inputName
))
{
int
camid
=
-
1
;
istringstream
iss
(
inputName
);
iss
>>
camid
;
if
(
!
capture
.
open
(
camid
))
{
cout
<<
"Can't open source"
<<
endl
;
return
help
(),
-
1
;
}
}
i
mage
=
imread
(
inputName
);
CV_Assert
(
!
image
.
empty
());
}
else
if
(
isInputVideo
)
{
capture
.
open
(
inputName
);
CV_Assert
(
capture
.
isOpened
());
}
else
{
capture
.
open
(
atoi
(
inputName
.
c_str
()));
CV_Assert
(
capture
.
isOpened
());
}
namedWindow
(
"result"
,
1
);
...
...
@@ -160,7 +194,7 @@ int main(int argc, const char *argv[])
int
detections_num
;
for
(;;)
{
if
(
capture
.
isOpened
()
)
if
(
isInputCamera
||
isInputVideo
)
{
capture
>>
frame
;
if
(
frame
.
empty
())
...
...
samples/gpu/driver_api_multi.cpp
浏览文件 @
a2090a44
...
...
@@ -54,8 +54,14 @@ inline void safeCall_(int code, const char* expr, const char* file, int line)
// Each GPU is associated with its own context
CUcontext
contexts
[
2
];
int
main
()
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
>
1
)
{
cout
<<
"CUDA driver API sample
\n
"
;
return
-
1
;
}
int
num_devices
=
getCudaEnabledDeviceCount
();
if
(
num_devices
<
2
)
{
...
...
samples/gpu/driver_api_stereo_multi.cpp
浏览文件 @
a2090a44
...
...
@@ -76,11 +76,16 @@ GpuMat d_result[2];
// CPU result
Mat
result
;
void
printHelp
()
{
std
::
cout
<<
"Usage: driver_api_stereo_multi_gpu --left <left_image> --right <right_image>
\n
"
;
}
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
<
3
)
if
(
argc
<
5
)
{
std
::
cout
<<
"Usage: stereo_multi_gpu <left_image> <right_image>
\n
"
;
printHelp
();
return
-
1
;
}
...
...
@@ -104,19 +109,27 @@ int main(int argc, char** argv)
}
// Load input data
Mat
left
=
imread
(
argv
[
1
],
CV_LOAD_IMAGE_GRAYSCALE
);
Mat
right
=
imread
(
argv
[
2
],
CV_LOAD_IMAGE_GRAYSCALE
);
if
(
left
.
empty
())
{
std
::
cout
<<
"Cannot open '"
<<
argv
[
1
]
<<
"'
\n
"
;
return
-
1
;
}
if
(
right
.
empty
())
Mat
left
,
right
;
for
(
int
i
=
1
;
i
<
argc
;
++
i
)
{
std
::
cout
<<
"Cannot open '"
<<
argv
[
2
]
<<
"'
\n
"
;
return
-
1
;
if
(
string
(
argv
[
i
])
==
"--left"
)
{
left
=
imread
(
argv
[
++
i
],
CV_LOAD_IMAGE_GRAYSCALE
);
CV_Assert
(
!
left
.
empty
());
}
else
if
(
string
(
argv
[
i
])
==
"--right"
)
{
right
=
imread
(
argv
[
++
i
],
CV_LOAD_IMAGE_GRAYSCALE
);
CV_Assert
(
!
right
.
empty
());
}
else
if
(
string
(
argv
[
i
])
==
"--help"
)
{
printHelp
();
return
-
1
;
}
}
// Init CUDA Driver API
safeCall
(
cuInit
(
0
));
...
...
samples/gpu/hog.cpp
浏览文件 @
a2090a44
...
...
@@ -10,6 +10,8 @@
using
namespace
std
;
using
namespace
cv
;
bool
help_showed
=
false
;
class
Args
{
public:
...
...
@@ -84,35 +86,39 @@ private:
};
void
printHelp
()
{
cout
<<
"Histogram of Oriented Gradients descriptor and detector sample.
\n
"
<<
"
\n
Usage: hog_gpu
\n
"
<<
" (<image>|--video <vide>|--camera <camera_id>) # frames source
\n
"
<<
" [--make_gray <true/false>] # convert image to gray one or not
\n
"
<<
" [--resize_src <true/false>] # do resize of the source image or not
\n
"
<<
" [--width <int>] # resized image width
\n
"
<<
" [--height <int>] # resized image height
\n
"
<<
" [--hit_threshold <double>] # classifying plane distance threshold (0.0 usually)
\n
"
<<
" [--scale <double>] # HOG window scale factor
\n
"
<<
" [--nlevels <int>] # max number of HOG window scales
\n
"
<<
" [--win_width <int>] # width of the window (48 or 64)
\n
"
<<
" [--win_stride_width <int>] # distance by OX axis between neighbour wins
\n
"
<<
" [--win_stride_height <int>] # distance by OY axis between neighbour wins
\n
"
<<
" [--gr_threshold <int>] # merging similar rects constant
\n
"
<<
" [--gamma_correct <int>] # do gamma correction or not
\n
"
<<
" [--write_video <bool>] # write video or not
\n
"
<<
" [--dst_video <path>] # output video path
\n
"
<<
" [--dst_video_fps <double>] # output video fps
\n
"
;
help_showed
=
true
;
}
int
main
(
int
argc
,
char
**
argv
)
{
try
{
cout
<<
"Histogram of Oriented Gradients descriptor and detector sample.
\n
"
;
if
(
argc
<
2
)
{
cout
<<
"
\n
Usage: hog_gpu
\n
"
<<
" --src <path> # it's image file by default
\n
"
<<
" [--src-is-video <true/false>] # says to interpretate src as video
\n
"
<<
" [--src-is-camera <true/false>] # says to interpretate src as camera
\n
"
<<
" [--make-gray <true/false>] # convert image to gray one or not
\n
"
<<
" [--resize-src <true/false>] # do resize of the source image or not
\n
"
<<
" [--width <int>] # resized image width
\n
"
<<
" [--height <int>] # resized image height
\n
"
<<
" [--hit-threshold <double>] # classifying plane distance threshold (0.0 usually)
\n
"
<<
" [--scale <double>] # HOG window scale factor
\n
"
<<
" [--nlevels <int>] # max number of HOG window scales
\n
"
<<
" [--win-width <int>] # width of the window (48 or 64)
\n
"
<<
" [--win-stride-width <int>] # distance by OX axis between neighbour wins
\n
"
<<
" [--win-stride-height <int>] # distance by OY axis between neighbour wins
\n
"
<<
" [--gr-threshold <int>] # merging similar rects constant
\n
"
<<
" [--gamma-correct <int>] # do gamma correction or not
\n
"
<<
" [--write-video <bool>] # write video or not
\n
"
<<
" [--dst-video <path>] # output video path
\n
"
<<
" [--dst-video-fps <double>] # output video fps
\n
"
;
return
1
;
}
App
app
(
Args
::
read
(
argc
,
argv
));
printHelp
();
Args
args
=
Args
::
read
(
argc
,
argv
);
if
(
help_showed
)
return
-
1
;
App
app
(
args
);
app
.
run
();
}
catch
(
const
Exception
&
e
)
{
return
cout
<<
"error: "
<<
e
.
what
()
<<
endl
,
1
;
}
...
...
@@ -154,34 +160,32 @@ Args::Args()
Args
Args
::
read
(
int
argc
,
char
**
argv
)
{
Args
args
;
for
(
int
i
=
1
;
i
<
argc
-
1
;
i
+=
2
)
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
string
key
=
argv
[
i
];
string
val
=
argv
[
i
+
1
];
if
(
key
==
"--src"
)
args
.
src
=
val
;
else
if
(
key
==
"--src-is-video"
)
args
.
src_is_video
=
(
val
==
"true"
);
else
if
(
key
==
"--src-is-camera"
)
args
.
src_is_camera
=
(
val
==
"true"
);
else
if
(
key
==
"--camera-id"
)
args
.
camera_id
=
atoi
(
val
.
c_str
());
else
if
(
key
==
"--make-gray"
)
args
.
make_gray
=
(
val
==
"true"
);
else
if
(
key
==
"--resize-src"
)
args
.
resize_src
=
(
val
==
"true"
);
else
if
(
key
==
"--width"
)
args
.
width
=
atoi
(
val
.
c_str
());
else
if
(
key
==
"--height"
)
args
.
height
=
atoi
(
val
.
c_str
());
else
if
(
key
==
"--hit-threshold"
)
if
(
string
(
argv
[
i
])
==
"--make_gray"
)
args
.
make_gray
=
(
string
(
argv
[
++
i
])
==
"true"
);
else
if
(
string
(
argv
[
i
])
==
"--resize_src"
)
args
.
resize_src
=
(
string
(
argv
[
++
i
])
==
"true"
);
else
if
(
string
(
argv
[
i
])
==
"--width"
)
args
.
width
=
atoi
(
argv
[
++
i
]);
else
if
(
string
(
argv
[
i
])
==
"--height"
)
args
.
height
=
atoi
(
argv
[
++
i
]);
else
if
(
string
(
argv
[
i
])
==
"--hit_threshold"
)
{
args
.
hit_threshold
=
atof
(
val
.
c_str
()
);
args
.
hit_threshold
=
atof
(
argv
[
++
i
]
);
args
.
hit_threshold_auto
=
false
;
}
else
if
(
key
==
"--scale"
)
args
.
scale
=
atof
(
val
.
c_str
());
else
if
(
key
==
"--nlevels"
)
args
.
nlevels
=
atoi
(
val
.
c_str
());
else
if
(
key
==
"--win-width"
)
args
.
win_width
=
atoi
(
val
.
c_str
());
else
if
(
key
==
"--win-stride-width"
)
args
.
win_stride_width
=
atoi
(
val
.
c_str
());
else
if
(
key
==
"--win-stride-height"
)
args
.
win_stride_height
=
atoi
(
val
.
c_str
());
else
if
(
key
==
"--gr-threshold"
)
args
.
gr_threshold
=
atoi
(
val
.
c_str
());
else
if
(
key
==
"--gamma-correct"
)
args
.
gamma_corr
=
(
val
==
"true"
);
else
if
(
key
==
"--write-video"
)
args
.
write_video
=
(
val
==
"true"
);
else
if
(
key
==
"--dst-video"
)
args
.
dst_video
=
val
;
else
if
(
key
==
"--dst-video-fps"
)
args
.
dst_video_fps
=
atof
(
val
.
c_str
());
else
throw
runtime_error
((
string
(
"unknown key: "
)
+
key
));
else
if
(
string
(
argv
[
i
])
==
"--scale"
)
args
.
scale
=
atof
(
argv
[
++
i
]);
else
if
(
string
(
argv
[
i
])
==
"--nlevels"
)
args
.
nlevels
=
atoi
(
argv
[
++
i
]);
else
if
(
string
(
argv
[
i
])
==
"--win_width"
)
args
.
win_width
=
atoi
(
argv
[
++
i
]);
else
if
(
string
(
argv
[
i
])
==
"--win_stride_width"
)
args
.
win_stride_width
=
atoi
(
argv
[
++
i
]);
else
if
(
string
(
argv
[
i
])
==
"--win_stride_height"
)
args
.
win_stride_height
=
atoi
(
argv
[
++
i
]);
else
if
(
string
(
argv
[
i
])
==
"--gr_threshold"
)
args
.
gr_threshold
=
atoi
(
argv
[
++
i
]);
else
if
(
string
(
argv
[
i
])
==
"--gamma_correct"
)
args
.
gamma_corr
=
(
string
(
argv
[
++
i
])
==
"true"
);
else
if
(
string
(
argv
[
i
])
==
"--write_video"
)
args
.
write_video
=
(
string
(
argv
[
++
i
])
==
"true"
);
else
if
(
string
(
argv
[
i
])
==
"--dst_video"
)
args
.
dst_video
=
argv
[
++
i
];
else
if
(
string
(
argv
[
i
])
==
"--dst_video_fps"
)
args
.
dst_video_fps
=
atof
(
argv
[
++
i
]);
else
if
(
string
(
argv
[
i
])
==
"--help"
)
printHelp
();
else
if
(
string
(
argv
[
i
])
==
"--video"
)
{
args
.
src
=
argv
[
++
i
];
args
.
src_is_video
=
true
;
}
else
if
(
string
(
argv
[
i
])
==
"--camera"
)
{
args
.
camera_id
=
atoi
(
argv
[
++
i
]);
args
.
src_is_camera
=
true
;
}
else
if
(
args
.
src
.
empty
())
args
.
src
=
argv
[
i
];
else
throw
runtime_error
((
string
(
"unknown key: "
)
+
argv
[
i
]));
}
return
args
;
}
...
...
@@ -267,7 +271,11 @@ void App::run()
{
vc
.
open
(
args
.
camera_id
);
if
(
!
vc
.
isOpened
())
throw
runtime_error
(
string
(
"can't open video file: "
+
args
.
src
));
{
stringstream
msg
;
msg
<<
"can't open camera: "
<<
args
.
camera_id
;
throw
runtime_error
(
msg
.
str
());
}
vc
>>
frame
;
}
else
...
...
samples/gpu/morfology.cpp
浏览文件 @
a2090a44
...
...
@@ -61,7 +61,7 @@ void ErodeDilate(int, void*)
int
main
(
int
argc
,
char
**
argv
)
{
char
*
filename
=
argc
==
2
?
argv
[
1
]
:
(
char
*
)
"baboon.jpg"
;
if
(
(
src
=
imread
(
filename
,
1
)).
data
==
0
)
if
(
string
(
argv
[
1
])
==
"--help"
||
(
src
=
imread
(
filename
,
1
)).
data
==
0
)
return
help
(),
-
1
;
help
();
...
...
samples/gpu/optical_flow.cpp
浏览文件 @
a2090a44
...
...
@@ -25,16 +25,19 @@ int main(int argc, const char* argv[])
#else
#define PARAM_INPUT "--input"
#define PARAM_LEFT "--left"
#define PARAM_RIGHT "--right"
#define PARAM_SCALE "--scale"
#define PARAM_ALPHA "--alpha"
#define PARAM_GAMMA "--gamma"
#define PARAM_INNER "--inner"
#define PARAM_OUTER "--outer"
#define PARAM_SOLVER "--solver"
#define PARAM_TIME_STEP "--time
-
step"
#define PARAM_TIME_STEP "--time
_
step"
#define PARAM_HELP "--help"
bool
help_showed
=
false
;
void
printHelp
()
{
cout
<<
"Usage help:
\n
"
;
...
...
@@ -42,12 +45,14 @@ void printHelp()
cout
<<
"
\t
"
<<
setw
(
15
)
<<
PARAM_ALPHA
<<
" - set alpha
\n
"
;
cout
<<
"
\t
"
<<
setw
(
15
)
<<
PARAM_GAMMA
<<
" - set gamma
\n
"
;
cout
<<
"
\t
"
<<
setw
(
15
)
<<
PARAM_INNER
<<
" - set number of inner iterations
\n
"
;
cout
<<
"
\t
"
<<
setw
(
15
)
<<
PARAM_INPUT
<<
" - specify input file names (2 image files)
\n
"
;
cout
<<
"
\t
"
<<
setw
(
15
)
<<
PARAM_LEFT
<<
" - specify left image
\n
"
;
cout
<<
"
\t
"
<<
setw
(
15
)
<<
PARAM_RIGHT
<<
" - specify right image
\n
"
;
cout
<<
"
\t
"
<<
setw
(
15
)
<<
PARAM_OUTER
<<
" - set number of outer iterations
\n
"
;
cout
<<
"
\t
"
<<
setw
(
15
)
<<
PARAM_SCALE
<<
" - set pyramid scale factor
\n
"
;
cout
<<
"
\t
"
<<
setw
(
15
)
<<
PARAM_SOLVER
<<
" - set number of basic solver iterations
\n
"
;
cout
<<
"
\t
"
<<
setw
(
15
)
<<
PARAM_TIME_STEP
<<
" - set frame interpolation time step
\n
"
;
cout
<<
"
\t
"
<<
setw
(
15
)
<<
PARAM_HELP
<<
" - display this help message
\n
"
;
help_showed
=
true
;
}
int
processCommandLine
(
int
argc
,
const
char
*
argv
[],
float
&
timeStep
,
string
&
frame0Name
,
string
&
frame1Name
,
BroxOpticalFlow
&
flow
)
...
...
@@ -56,13 +61,17 @@ int processCommandLine(int argc, const char* argv[], float& timeStep, string& fr
for
(
int
iarg
=
1
;
iarg
<
argc
;
++
iarg
)
{
if
(
strcmp
(
argv
[
iarg
],
PARAM_
INPU
T
)
==
0
)
if
(
strcmp
(
argv
[
iarg
],
PARAM_
LEF
T
)
==
0
)
{
if
(
iarg
+
2
<
argc
)
{
if
(
iarg
+
1
<
argc
)
frame0Name
=
argv
[
++
iarg
];
else
return
-
1
;
}
if
(
strcmp
(
argv
[
iarg
],
PARAM_RIGHT
)
==
0
)
{
if
(
iarg
+
1
<
argc
)
frame1Name
=
argv
[
++
iarg
];
}
else
return
-
1
;
}
...
...
@@ -181,6 +190,8 @@ int main(int argc, const char* argv[])
10
/*inner_iterations*/
,
77
/*outer_iterations*/
,
10
/*solver_iterations*/
);
int
result
=
processCommandLine
(
argc
,
argv
,
timeStep
,
frame0Name
,
frame1Name
,
d_flow
);
if
(
help_showed
)
return
-
1
;
if
(
argc
==
1
||
result
)
{
printHelp
();
...
...
samples/gpu/opticalflow_nvidia_api.cpp
浏览文件 @
a2090a44
...
...
@@ -30,7 +30,8 @@ int main( int argc, const char** argv )
//using std::tr1::shared_ptr;
using
cv
::
Ptr
;
#define PARAM_INPUT "--input"
#define PARAM_LEFT "--left"
#define PARAM_RIGHT "--right"
#define PARAM_SCALE "--scale"
#define PARAM_ALPHA "--alpha"
#define PARAM_GAMMA "--gamma"
...
...
@@ -276,7 +277,8 @@ void PrintHelp ()
std
::
cout
<<
"
\t
"
<<
std
::
setw
(
15
)
<<
PARAM_ALPHA
<<
" - set alpha
\n
"
;
std
::
cout
<<
"
\t
"
<<
std
::
setw
(
15
)
<<
PARAM_GAMMA
<<
" - set gamma
\n
"
;
std
::
cout
<<
"
\t
"
<<
std
::
setw
(
15
)
<<
PARAM_INNER
<<
" - set number of inner iterations
\n
"
;
std
::
cout
<<
"
\t
"
<<
std
::
setw
(
15
)
<<
PARAM_INPUT
<<
" - specify input file names (2 image files)
\n
"
;
std
::
cout
<<
"
\t
"
<<
std
::
setw
(
15
)
<<
PARAM_LEFT
<<
" - specify left image
\n
"
;
std
::
cout
<<
"
\t
"
<<
std
::
setw
(
15
)
<<
PARAM_RIGHT
<<
" - specify right image
\n
"
;
std
::
cout
<<
"
\t
"
<<
std
::
setw
(
15
)
<<
PARAM_OUTER
<<
" - set number of outer iterations
\n
"
;
std
::
cout
<<
"
\t
"
<<
std
::
setw
(
15
)
<<
PARAM_SCALE
<<
" - set pyramid scale factor
\n
"
;
std
::
cout
<<
"
\t
"
<<
std
::
setw
(
15
)
<<
PARAM_SOLVER
<<
" - set number of basic solver iterations
\n
"
;
...
...
@@ -293,11 +295,19 @@ int ProcessCommandLine(int argc, char **argv,
timeStep
=
0.25
f
;
for
(
int
iarg
=
1
;
iarg
<
argc
;
++
iarg
)
{
if
(
strcmp
(
argv
[
iarg
],
PARAM_
INPU
T
)
==
0
)
if
(
strcmp
(
argv
[
iarg
],
PARAM_
LEF
T
)
==
0
)
{
if
(
iarg
+
2
<
argc
)
if
(
iarg
+
1
<
argc
)
{
frame0Name
=
argv
[
++
iarg
];
}
else
return
-
1
;
}
if
(
strcmp
(
argv
[
iarg
],
PARAM_RIGHT
)
==
0
)
{
if
(
iarg
+
1
<
argc
)
{
frame1Name
=
argv
[
++
iarg
];
}
else
...
...
samples/gpu/stereo_match.cpp
浏览文件 @
a2090a44
...
...
@@ -9,6 +9,7 @@
using
namespace
cv
;
using
namespace
std
;
bool
help_showed
=
false
;
struct
Params
{
...
...
@@ -71,6 +72,14 @@ private:
double
work_fps
;
};
void
printHelp
()
{
cout
<<
"Usage: stereo_match_gpu
\n
"
<<
"
\t
--left <left_view> --right <right_view> # must be rectified
\n
"
<<
"
\t
--method <stereo_match_method> # BM | BP | CSBP
\n
"
<<
"
\t
--ndisp <number> # number of disparity levels
\n
"
;
help_showed
=
true
;
}
int
main
(
int
argc
,
char
**
argv
)
{
...
...
@@ -78,12 +87,13 @@ int main(int argc, char** argv)
{
if
(
argc
<
2
)
{
cout
<<
"Usage: stereo_match_gpu
\n
"
<<
"
\t
-l <left_view> -r <right_view> # must be rectified
\n
"
<<
"
\t
-m <stereo_match_method> # BM | BP | CSBP
\n
"
;
printHelp
();
return
1
;
}
App
app
(
Params
::
read
(
argc
,
argv
));
Params
args
=
Params
::
read
(
argc
,
argv
);
if
(
help_showed
)
return
-
1
;
App
app
(
args
);
app
.
run
();
}
catch
(
const
exception
&
e
)
...
...
@@ -105,21 +115,21 @@ Params Params::read(int argc, char** argv)
{
Params
p
;
for
(
int
i
=
1
;
i
<
argc
-
1
;
i
+=
2
)
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
string
key
=
argv
[
i
];
string
val
=
argv
[
i
+
1
];
if
(
key
==
"-l"
)
p
.
left
=
val
;
else
if
(
key
==
"-r"
)
p
.
right
=
val
;
else
if
(
key
==
"-m"
)
if
(
string
(
argv
[
i
])
==
"--left"
)
p
.
left
=
argv
[
++
i
];
else
if
(
string
(
argv
[
i
])
==
"--right"
)
p
.
right
=
argv
[
++
i
];
else
if
(
string
(
argv
[
i
])
==
"--method"
)
{
if
(
val
==
"BM"
)
p
.
method
=
BM
;
else
if
(
val
==
"BP"
)
p
.
method
=
BP
;
else
if
(
val
==
"CSBP"
)
p
.
method
=
CSBP
;
else
throw
runtime_error
(
"unknown stereo match method: "
+
val
);
if
(
string
(
argv
[
i
+
1
])
==
"BM"
)
p
.
method
=
BM
;
else
if
(
string
(
argv
[
i
+
1
])
==
"BP"
)
p
.
method
=
BP
;
else
if
(
string
(
argv
[
i
+
1
])
==
"CSBP"
)
p
.
method
=
CSBP
;
else
throw
runtime_error
(
"unknown stereo match method: "
+
string
(
argv
[
i
+
1
]));
i
++
;
}
else
if
(
key
==
"-ndisp"
)
p
.
ndisp
=
atoi
(
val
.
c_str
());
else
throw
runtime_error
(
"unknown key: "
+
key
);
else
if
(
string
(
argv
[
i
])
==
"--ndisp"
)
p
.
ndisp
=
atoi
(
argv
[
++
i
]);
else
if
(
string
(
argv
[
i
])
==
"--help"
)
printHelp
();
else
throw
runtime_error
(
"unknown key: "
+
string
(
argv
[
i
]));
}
return
p
;
...
...
samples/gpu/stereo_multi.cpp
浏览文件 @
a2090a44
...
...
@@ -47,11 +47,16 @@ GpuMat d_result[2];
// CPU result
Mat
result
;
void
printHelp
()
{
std
::
cout
<<
"Usage: stereo_multi_gpu --left <image> --right <image>
\n
"
;
}
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
<
3
)
if
(
argc
<
5
)
{
std
::
cout
<<
"Usage: stereo_multi_gpu <left_image> <right_image>
\n
"
;
printHelp
()
;
return
-
1
;
}
...
...
@@ -74,17 +79,24 @@ int main(int argc, char** argv)
}
// Load input data
Mat
left
=
imread
(
argv
[
1
],
CV_LOAD_IMAGE_GRAYSCALE
);
Mat
right
=
imread
(
argv
[
2
],
CV_LOAD_IMAGE_GRAYSCALE
);
if
(
left
.
empty
())
Mat
left
,
right
;
for
(
int
i
=
1
;
i
<
argc
;
++
i
)
{
std
::
cout
<<
"Cannot open '"
<<
argv
[
1
]
<<
"'
\n
"
;
return
-
1
;
}
if
(
right
.
empty
())
{
std
::
cout
<<
"Cannot open '"
<<
argv
[
2
]
<<
"'
\n
"
;
return
-
1
;
if
(
string
(
argv
[
i
])
==
"--left"
)
{
left
=
imread
(
argv
[
++
i
],
CV_LOAD_IMAGE_GRAYSCALE
);
CV_Assert
(
!
left
.
empty
());
}
else
if
(
string
(
argv
[
i
])
==
"--right"
)
{
right
=
imread
(
argv
[
++
i
],
CV_LOAD_IMAGE_GRAYSCALE
);
CV_Assert
(
!
right
.
empty
());
}
else
if
(
string
(
argv
[
i
])
==
"--help"
)
{
printHelp
();
return
-
1
;
}
}
// Split source images for processing on the GPU #0
...
...
samples/gpu/surf_keypoint_matcher.cpp
浏览文件 @
a2090a44
...
...
@@ -12,23 +12,35 @@ using namespace cv::gpu;
void
help
()
{
cout
<<
"
\n
This program demonstrates using SURF_GPU features detector, descriptor extractor and BruteForceMatcher_GPU"
<<
endl
;
cout
<<
"
\n
Usage:
\n\t
matcher_simple_gpu
<image1>
<image2>"
<<
endl
;
cout
<<
"
\n
Usage:
\n\t
matcher_simple_gpu
--left <image1> --right
<image2>"
<<
endl
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
!=
3
)
if
(
argc
!=
5
)
{
help
();
return
-
1
;
}
GpuMat
img1
(
imread
(
argv
[
1
],
CV_LOAD_IMAGE_GRAYSCALE
));
GpuMat
img2
(
imread
(
argv
[
2
],
CV_LOAD_IMAGE_GRAYSCALE
));
if
(
img1
.
empty
()
||
img2
.
empty
())
{
cout
<<
"Can't read one of the images"
<<
endl
;
return
-
1
;
GpuMat
img1
,
img2
;
for
(
int
i
=
1
;
i
<
argc
;
++
i
)
{
if
(
string
(
argv
[
i
])
==
"--left"
)
{
img1
=
imread
(
argv
[
++
i
],
CV_LOAD_IMAGE_GRAYSCALE
);
CV_Assert
(
!
img1
.
empty
());
}
else
if
(
string
(
argv
[
i
])
==
"--right"
)
{
img2
=
imread
(
argv
[
++
i
],
CV_LOAD_IMAGE_GRAYSCALE
);
CV_Assert
(
!
img2
.
empty
());
}
else
if
(
string
(
argv
[
i
])
==
"--help"
)
{
help
();
return
-
1
;
}
}
SURF_GPU
surf
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录