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
0fd21baa
Commit
0fd21baa
authored
Sep 02, 2014
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3174 from rokm:samples-fix
parents
7dd666e4
d9db950c
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
79 additions
and
178 deletions
+79
-178
cascadeclassifier.cpp
samples/gpu/cascadeclassifier.cpp
+2
-1
generalized_hough.cpp
samples/gpu/generalized_hough.cpp
+2
-1
CMakeLists.txt
samples/gpu/performance/CMakeLists.txt
+9
-1
tests.cpp
samples/gpu/performance/tests.cpp
+9
-59
softcascade.cpp
samples/gpu/softcascade.cpp
+0
-109
stereo_multi.cpp
samples/gpu/stereo_multi.cpp
+2
-1
super_resolution.cpp
samples/gpu/super_resolution.cpp
+4
-3
tick_meter.hpp
samples/gpu/tick_meter.hpp
+48
-0
video_reader.cpp
samples/gpu/video_reader.cpp
+3
-2
video_writer.cpp
samples/gpu/video_writer.cpp
+0
-1
No files found.
samples/gpu/cascadeclassifier.cpp
View file @
0fd21baa
...
...
@@ -6,7 +6,6 @@
#include <iostream>
#include <iomanip>
#include "opencv2/contrib/contrib.hpp"
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
...
...
@@ -14,6 +13,8 @@
#include "opencv2/cudaimgproc.hpp"
#include "opencv2/cudawarping.hpp"
#include "tick_meter.hpp"
using
namespace
std
;
using
namespace
cv
;
using
namespace
cv
::
cuda
;
...
...
samples/gpu/generalized_hough.cpp
View file @
0fd21baa
...
...
@@ -7,7 +7,8 @@
#include "opencv2/imgproc.hpp"
#include "opencv2/cudaimgproc.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/contrib.hpp"
#include "tick_meter.hpp"
using
namespace
std
;
using
namespace
cv
;
...
...
samples/gpu/performance/CMakeLists.txt
View file @
0fd21baa
...
...
@@ -4,7 +4,11 @@ file(GLOB sources "performance/*.cpp")
file
(
GLOB headers
"performance/*.h"
)
if
(
HAVE_opencv_xfeatures2d
)
ocv_include_directories
(
"
${
OpenCV_SOURCE_DIR
}
/modules/xfeatures2d/include"
)
ocv_include_directories
(
"
${
opencv_xfeatures2d_SOURCE_DIR
}
/include"
)
endif
()
if
(
HAVE_opencv_bgsegm
)
ocv_include_directories
(
"
${
opencv_bgsegm_SOURCE_DIR
}
/include"
)
endif
()
add_executable
(
${
the_target
}
${
sources
}
${
headers
}
)
...
...
@@ -14,6 +18,10 @@ if(HAVE_opencv_xfeatures2d)
ocv_target_link_libraries
(
${
the_target
}
opencv_xfeatures2d
)
endif
()
if
(
HAVE_opencv_bgsegm
)
ocv_target_link_libraries
(
${
the_target
}
opencv_bgsegm
)
endif
()
set_target_properties
(
${
the_target
}
PROPERTIES
OUTPUT_NAME
"performance_gpu"
PROJECT_LABEL
"(EXAMPLE_CUDA) performance"
)
...
...
samples/gpu/performance/tests.cpp
View file @
0fd21baa
...
...
@@ -12,7 +12,6 @@
#include "opencv2/cudaoptflow.hpp"
#include "opencv2/cudabgsegm.hpp"
#include "opencv2/legacy.hpp"
#include "performance.h"
#include "opencv2/opencv_modules.hpp"
...
...
@@ -22,6 +21,10 @@
#include "opencv2/xfeatures2d/nonfree.hpp"
#endif
#ifdef HAVE_OPENCV_BGSEGM
#include "opencv2/bgsegm.hpp"
#endif
using
namespace
std
;
using
namespace
cv
;
...
...
@@ -281,7 +284,7 @@ TEST(SURF)
Mat
src
=
imread
(
abspath
(
"aloeL.jpg"
),
IMREAD_GRAYSCALE
);
if
(
src
.
empty
())
throw
runtime_error
(
"can't open aloeL.jpg"
);
SURF
surf
;
xfeatures2d
::
SURF
surf
;
vector
<
KeyPoint
>
keypoints
;
Mat
descriptors
;
...
...
@@ -1267,62 +1270,7 @@ TEST(FarnebackOpticalFlow)
}}}
}
namespace
cv
{
template
<>
void
DefaultDeleter
<
CvBGStatModel
>::
operator
()(
CvBGStatModel
*
obj
)
const
{
cvReleaseBGStatModel
(
&
obj
);
}
}
TEST
(
FGDStatModel
)
{
const
std
::
string
inputFile
=
abspath
(
"768x576.avi"
);
VideoCapture
cap
(
inputFile
);
if
(
!
cap
.
isOpened
())
throw
runtime_error
(
"can't open 768x576.avi"
);
Mat
frame
;
cap
>>
frame
;
IplImage
ipl_frame
=
frame
;
Ptr
<
CvBGStatModel
>
model
(
cvCreateFGDStatModel
(
&
ipl_frame
));
while
(
!
TestSystem
::
instance
().
stop
())
{
cap
>>
frame
;
ipl_frame
=
frame
;
TestSystem
::
instance
().
cpuOn
();
cvUpdateBGStatModel
(
&
ipl_frame
,
model
);
TestSystem
::
instance
().
cpuOff
();
}
TestSystem
::
instance
().
cpuComplete
();
cap
.
open
(
inputFile
);
cap
>>
frame
;
cuda
::
GpuMat
d_frame
(
frame
),
d_fgmask
;
Ptr
<
BackgroundSubtractor
>
d_fgd
=
cuda
::
createBackgroundSubtractorFGD
();
d_fgd
->
apply
(
d_frame
,
d_fgmask
);
while
(
!
TestSystem
::
instance
().
stop
())
{
cap
>>
frame
;
d_frame
.
upload
(
frame
);
TestSystem
::
instance
().
gpuOn
();
d_fgd
->
apply
(
d_frame
,
d_fgmask
);
TestSystem
::
instance
().
gpuOff
();
}
TestSystem
::
instance
().
gpuComplete
();
}
#ifdef HAVE_OPENCV_BGSEGM
TEST
(
MOG
)
{
...
...
@@ -1334,7 +1282,7 @@ TEST(MOG)
cv
::
Mat
frame
;
cap
>>
frame
;
cv
::
Ptr
<
cv
::
BackgroundSubtractor
>
mog
=
cv
::
createBackgroundSubtractorMOG
();
cv
::
Ptr
<
cv
::
BackgroundSubtractor
>
mog
=
cv
::
bgsegm
::
createBackgroundSubtractorMOG
();
cv
::
Mat
foreground
;
mog
->
apply
(
frame
,
foreground
,
0.01
);
...
...
@@ -1375,6 +1323,8 @@ TEST(MOG)
TestSystem
::
instance
().
gpuComplete
();
}
#endif
TEST
(
MOG2
)
{
const
std
::
string
inputFile
=
abspath
(
"768x576.avi"
);
...
...
samples/gpu/softcascade.cpp
deleted
100644 → 0
View file @
7dd666e4
#include <opencv2/core/utility.hpp>
#include <opencv2/cuda.hpp>
#include <opencv2/softcascade.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>
typedef
cv
::
softcascade
::
Detection
Detection
;
int
main
(
int
argc
,
char
**
argv
)
{
const
std
::
string
keys
=
"{help h usage ? | | print this message }"
"{cascade c | | path to configuration xml }"
"{frames f | | path to configuration xml }"
"{min_scale |0.4f | path to configuration xml }"
"{max_scale |5.0f | path to configuration xml }"
"{total_scales |55 | path to configuration xml }"
"{device d |0 | path to configuration xml }"
;
cv
::
CommandLineParser
parser
(
argc
,
argv
,
keys
);
parser
.
about
(
"Soft cascade training application."
);
if
(
parser
.
has
(
"help"
))
{
parser
.
printMessage
();
return
0
;
}
if
(
!
parser
.
check
())
{
parser
.
printErrors
();
return
1
;
}
cv
::
cuda
::
setDevice
(
parser
.
get
<
int
>
(
"device"
));
std
::
string
cascadePath
=
parser
.
get
<
std
::
string
>
(
"cascade"
);
cv
::
FileStorage
fs
(
cascadePath
,
cv
::
FileStorage
::
READ
);
if
(
!
fs
.
isOpened
())
{
std
::
cout
<<
"Soft Cascade file "
<<
cascadePath
<<
" can't be opened."
<<
std
::
endl
<<
std
::
flush
;
return
1
;
}
std
::
cout
<<
"Read cascade from file "
<<
cascadePath
<<
std
::
endl
;
float
minScale
=
parser
.
get
<
float
>
(
"min_scale"
);
float
maxScale
=
parser
.
get
<
float
>
(
"max_scale"
);
int
scales
=
parser
.
get
<
int
>
(
"total_scales"
);
using
cv
::
softcascade
::
SCascade
;
SCascade
cascade
(
minScale
,
maxScale
,
scales
);
if
(
!
cascade
.
load
(
fs
.
getFirstTopLevelNode
()))
{
std
::
cout
<<
"Soft Cascade can't be parsed."
<<
std
::
endl
<<
std
::
flush
;
return
1
;
}
std
::
string
frames
=
parser
.
get
<
std
::
string
>
(
"frames"
);
cv
::
VideoCapture
capture
(
frames
);
if
(
!
capture
.
isOpened
())
{
std
::
cout
<<
"Frame source "
<<
frames
<<
" can't be opened."
<<
std
::
endl
<<
std
::
flush
;
return
1
;
}
cv
::
cuda
::
GpuMat
objects
(
1
,
sizeof
(
Detection
)
*
10000
,
CV_8UC1
);
cv
::
cuda
::
printShortCudaDeviceInfo
(
parser
.
get
<
int
>
(
"device"
));
for
(;;)
{
cv
::
Mat
frame
;
if
(
!
capture
.
read
(
frame
))
{
std
::
cout
<<
"Nothing to read. "
<<
std
::
endl
<<
std
::
flush
;
return
0
;
}
cv
::
cuda
::
GpuMat
dframe
(
frame
),
roi
(
frame
.
rows
,
frame
.
cols
,
CV_8UC1
);
roi
.
setTo
(
cv
::
Scalar
::
all
(
1
));
cascade
.
detect
(
dframe
,
roi
,
objects
);
cv
::
Mat
dt
(
objects
);
Detection
*
dts
=
((
Detection
*
)
dt
.
data
)
+
1
;
int
*
count
=
dt
.
ptr
<
int
>
(
0
);
std
::
cout
<<
*
count
<<
std
::
endl
;
cv
::
Mat
result
;
frame
.
copyTo
(
result
);
for
(
int
i
=
0
;
i
<
*
count
;
++
i
)
{
Detection
d
=
dts
[
i
];
cv
::
rectangle
(
result
,
cv
::
Rect
(
d
.
x
,
d
.
y
,
d
.
w
,
d
.
h
),
cv
::
Scalar
(
255
,
0
,
0
,
255
),
1
);
}
std
::
cout
<<
"working..."
<<
std
::
endl
;
cv
::
imshow
(
"Soft Cascade demo"
,
result
);
if
(
27
==
cv
::
waitKey
(
10
))
break
;
}
return
0
;
}
samples/gpu/stereo_multi.cpp
View file @
0fd21baa
...
...
@@ -15,9 +15,10 @@
#include "opencv2/core.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/contrib.hpp"
#include "opencv2/cudastereo.hpp"
#include "tick_meter.hpp"
using
namespace
std
;
using
namespace
cv
;
using
namespace
cv
::
cuda
;
...
...
samples/gpu/super_resolution.cpp
View file @
0fd21baa
...
...
@@ -7,11 +7,12 @@
#include "opencv2/core/utility.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/contrib.hpp"
#include "opencv2/superres.hpp"
#include "opencv2/superres/optical_flow.hpp"
#include "opencv2/opencv_modules.hpp"
#include "tick_meter.hpp"
using
namespace
std
;
using
namespace
cv
;
using
namespace
cv
::
superres
;
...
...
@@ -34,8 +35,8 @@ static Ptr<DenseOpticalFlowExt> createOptFlow(const string& name, bool useGpu)
else
return
createOptFlow_Farneback
();
}
else
if
(
name
==
"simple"
)
return
createOptFlow_Simple
();
/*
else if (name == "simple")
return createOptFlow_Simple();
*/
else
if
(
name
==
"tvl1"
)
{
if
(
useGpu
)
...
...
samples/gpu/tick_meter.hpp
0 → 100644
View file @
0fd21baa
#ifndef OPENCV_CUDA_SAMPLES_TICKMETER_
#define OPENCV_CUDA_SAMPLES_TICKMETER_
class
CV_EXPORTS
TickMeter
{
public
:
TickMeter
();
void
start
();
void
stop
();
int64
getTimeTicks
()
const
;
double
getTimeMicro
()
const
;
double
getTimeMilli
()
const
;
double
getTimeSec
()
const
;
int64
getCounter
()
const
;
void
reset
();
private
:
int64
counter
;
int64
sumTime
;
int64
startTime
;
};
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
TickMeter
&
tm
);
TickMeter
::
TickMeter
()
{
reset
();
}
int64
TickMeter
::
getTimeTicks
()
const
{
return
sumTime
;
}
double
TickMeter
::
getTimeMicro
()
const
{
return
(
double
)
getTimeTicks
()
/
cv
::
getTickFrequency
();
}
double
TickMeter
::
getTimeMilli
()
const
{
return
getTimeMicro
()
*
1e-3
;
}
double
TickMeter
::
getTimeSec
()
const
{
return
getTimeMilli
()
*
1e-3
;
}
int64
TickMeter
::
getCounter
()
const
{
return
counter
;
}
void
TickMeter
::
reset
()
{
startTime
=
0
;
sumTime
=
0
;
counter
=
0
;
}
void
TickMeter
::
start
(){
startTime
=
cv
::
getTickCount
();
}
void
TickMeter
::
stop
()
{
int64
time
=
cv
::
getTickCount
();
if
(
startTime
==
0
)
return
;
++
counter
;
sumTime
+=
(
time
-
startTime
);
startTime
=
0
;
}
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
TickMeter
&
tm
)
{
return
out
<<
tm
.
getTimeSec
()
<<
"sec"
;
}
#endif
samples/gpu/video_reader.cpp
View file @
0fd21baa
...
...
@@ -13,7 +13,8 @@
#include <opencv2/core/opengl.hpp>
#include <opencv2/cudacodec.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/contrib.hpp>
#include "tick_meter.hpp"
int
main
(
int
argc
,
const
char
*
argv
[])
{
...
...
@@ -32,7 +33,7 @@ int main(int argc, const char* argv[])
cv
::
cuda
::
GpuMat
d_frame
;
cv
::
Ptr
<
cv
::
cudacodec
::
VideoReader
>
d_reader
=
cv
::
cudacodec
::
createVideoReader
(
fname
);
cv
::
TickMeter
tm
;
TickMeter
tm
;
std
::
vector
<
double
>
cpu_times
;
std
::
vector
<
double
>
gpu_times
;
...
...
samples/gpu/video_writer.cpp
View file @
0fd21baa
...
...
@@ -10,7 +10,6 @@
#include "opencv2/core.hpp"
#include "opencv2/cudacodec.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/contrib.hpp"
int
main
(
int
argc
,
const
char
*
argv
[])
{
...
...
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