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
6982ea5a
Commit
6982ea5a
authored
Jun 28, 2013
by
yao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some tweaks to samples
parent
c1a59b8d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
134 additions
and
7 deletions
+134
-7
clahe.cpp
samples/ocl/clahe.cpp
+108
-0
facedetect.cpp
samples/ocl/facedetect.cpp
+6
-1
hog.cpp
samples/ocl/hog.cpp
+9
-1
stereo_match.cpp
samples/ocl/stereo_match.cpp
+11
-5
No files found.
samples/ocl/clahe.cpp
0 → 100644
View file @
6982ea5a
#include <iostream>
#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/ocl/ocl.hpp"
using
namespace
cv
;
using
namespace
std
;
Ptr
<
CLAHE
>
pFilter
;
int
tilesize
;
int
cliplimit
;
string
outfile
;
static
void
TSize_Callback
(
int
pos
)
{
if
(
pos
==
0
)
{
pFilter
->
setTilesGridSize
(
Size
(
1
,
1
));
}
pFilter
->
setTilesGridSize
(
Size
(
tilesize
,
tilesize
));
}
static
void
Clip_Callback
(
int
)
{
pFilter
->
setClipLimit
(
cliplimit
);
}
int
main
(
int
argc
,
char
**
argv
)
{
const
char
*
keys
=
"{ i | input | | specify input image }"
"{ c | camera | 0 | specify camera id }"
"{ s | use_cpu | false | use cpu algorithm }"
"{ o | output | clahe_output.jpg | specify output save path}"
;
CommandLineParser
cmd
(
argc
,
argv
,
keys
);
string
infile
=
cmd
.
get
<
string
>
(
"i"
);
outfile
=
cmd
.
get
<
string
>
(
"o"
);
int
camid
=
cmd
.
get
<
int
>
(
"c"
);
bool
use_cpu
=
cmd
.
get
<
bool
>
(
"s"
);
CvCapture
*
capture
=
0
;
bool
running
=
true
;
namedWindow
(
"CLAHE"
);
createTrackbar
(
"Tile Size"
,
"CLAHE"
,
&
tilesize
,
32
,
(
TrackbarCallback
)
TSize_Callback
);
createTrackbar
(
"Clip Limit"
,
"CLAHE"
,
&
cliplimit
,
20
,
(
TrackbarCallback
)
Clip_Callback
);
Mat
frame
,
outframe
;
ocl
::
oclMat
d_outframe
;
int
cur_clip
;
Size
cur_tilesize
;
if
(
use_cpu
)
{
pFilter
=
createCLAHE
();
}
else
{
pFilter
=
ocl
::
createCLAHE
();
}
cur_clip
=
(
int
)
pFilter
->
getClipLimit
();
cur_tilesize
=
pFilter
->
getTilesGridSize
();
setTrackbarPos
(
"Tile Size"
,
"CLAHE"
,
cur_tilesize
.
width
);
setTrackbarPos
(
"Clip Limit"
,
"CLAHE"
,
cur_clip
);
if
(
infile
!=
""
)
{
frame
=
imread
(
infile
);
if
(
frame
.
empty
())
{
cout
<<
"error read image: "
<<
infile
<<
endl
;
return
-
1
;
}
}
else
{
capture
=
cvCaptureFromCAM
(
camid
);
}
cout
<<
"
\n
Controls:
\n
"
<<
"
\t
o - save output image
\n
"
<<
"
\t
ESC - exit
\n
"
;
while
(
running
)
{
if
(
capture
)
frame
=
cvQueryFrame
(
capture
);
else
frame
=
imread
(
infile
);
if
(
frame
.
empty
())
{
continue
;
}
if
(
use_cpu
)
{
cvtColor
(
frame
,
frame
,
COLOR_BGR2GRAY
);
pFilter
->
apply
(
frame
,
outframe
);
}
else
{
ocl
::
oclMat
d_frame
(
frame
);
ocl
::
cvtColor
(
d_frame
,
d_outframe
,
COLOR_BGR2GRAY
);
pFilter
->
apply
(
d_outframe
,
d_outframe
);
d_outframe
.
download
(
outframe
);
}
imshow
(
"CLAHE"
,
outframe
);
char
key
=
(
char
)
cvWaitKey
(
3
);
if
(
key
==
'o'
)
imwrite
(
outfile
,
outframe
);
else
if
(
key
==
27
)
running
=
false
;
}
return
0
;
}
samples/ocl/facedetect.cpp
View file @
6982ea5a
...
...
@@ -252,8 +252,13 @@ void Draw(Mat& img, vector<Rect>& faces, double scale)
radius
=
cvRound
((
r
->
width
+
r
->
height
)
*
0.25
*
scale
);
circle
(
img
,
center
,
radius
,
color
,
3
,
8
,
0
);
}
imshow
(
"result"
,
img
);
imwrite
(
outputName
,
img
);
if
(
abs
(
scale
-
1.0
)
>
.001
)
{
resize
(
img
,
img
,
Size
(
img
.
cols
/
scale
,
img
.
rows
/
scale
));
}
imshow
(
"result"
,
img
);
}
...
...
samples/ocl/hog.cpp
View file @
6982ea5a
...
...
@@ -57,6 +57,7 @@ private:
string
vdo_source
;
string
output
;
int
camera_id
;
bool
write_once
;
};
int
main
(
int
argc
,
char
**
argv
)
...
...
@@ -97,6 +98,7 @@ App::App(CommandLineParser& cmd)
<<
"
\t
ESC - exit
\n
"
<<
"
\t
m - change mode GPU <-> CPU
\n
"
<<
"
\t
g - convert image to gray or not
\n
"
<<
"
\t
o - save output image once, or switch on/off video save
\n
"
<<
"
\t
1/q - increase/decrease HOG scale
\n
"
<<
"
\t
2/w - increase/decrease levels count
\n
"
<<
"
\t
3/e - increase/decrease HOG group threshold
\n
"
...
...
@@ -120,6 +122,7 @@ App::App(CommandLineParser& cmd)
hit_threshold
=
win_width
==
48
?
1.4
:
0.
;
scale
=
1.05
;
gamma_corr
=
true
;
write_once
=
false
;
cout
<<
"Group threshold: "
<<
gr_threshold
<<
endl
;
cout
<<
"Levels number: "
<<
nlevels
<<
endl
;
...
...
@@ -254,10 +257,11 @@ void App::run()
workEnd
();
if
(
output
!=
""
)
if
(
output
!=
""
&&
write_once
)
{
if
(
img_source
!=
""
)
// wirte image
{
write_once
=
false
;
imwrite
(
output
,
img_to_show
);
}
else
//write video
...
...
@@ -340,6 +344,10 @@ void App::handleKey(char key)
gamma_corr
=
!
gamma_corr
;
cout
<<
"Gamma correction: "
<<
gamma_corr
<<
endl
;
break
;
case
'o'
:
case
'O'
:
write_once
=
!
write_once
;
break
;
}
}
...
...
samples/ocl/stereo_match.cpp
View file @
6982ea5a
...
...
@@ -49,7 +49,7 @@ struct App
return
ss
.
str
();
}
private
:
bool
running
;
bool
running
,
write_once
;
Mat
left_src
,
right_src
;
Mat
left
,
right
;
...
...
@@ -115,6 +115,7 @@ App::App(CommandLineParser& cmd)
cout
<<
"stereo_match_ocl sample
\n
"
;
cout
<<
"
\n
Controls:
\n
"
<<
"
\t
esc - exit
\n
"
<<
"
\t
o - save output image once
\n
"
<<
"
\t
p - print current parameters
\n
"
<<
"
\t
g - convert source images into gray
\n
"
<<
"
\t
m - change stereo match method
\n
"
...
...
@@ -132,6 +133,7 @@ App::App(CommandLineParser& cmd)
else
cout
<<
"unknown method!
\n
"
;
ndisp
=
cmd
.
get
<
int
>
(
"n"
);
out_img
=
cmd
.
get
<
string
>
(
"o"
);
write_once
=
false
;
}
...
...
@@ -161,10 +163,8 @@ void App::run()
printParams
();
running
=
true
;
bool
written
=
false
;
while
(
running
)
{
// Prepare disparity map of specified type
Mat
disp
;
oclMat
d_disp
;
...
...
@@ -192,19 +192,21 @@ void App::run()
csbp
(
d_left
,
d_right
,
d_disp
);
break
;
}
// Show results
d_disp
.
download
(
disp
);
workEnd
();
if
(
method
!=
BM
)
{
disp
.
convertTo
(
disp
,
0
);
}
putText
(
disp
,
text
(),
Point
(
5
,
25
),
FONT_HERSHEY_SIMPLEX
,
1.0
,
Scalar
::
all
(
255
));
imshow
(
"disparity"
,
disp
);
if
(
!
written
)
if
(
write_once
)
{
imwrite
(
out_img
,
disp
);
writ
ten
=
tru
e
;
writ
e_once
=
fals
e
;
}
handleKey
((
char
)
waitKey
(
3
));
}
...
...
@@ -378,6 +380,10 @@ void App::handleKey(char key)
cout
<<
"level_count: "
<<
csbp
.
levels
<<
endl
;
}
break
;
case
'o'
:
case
'O'
:
write_once
=
true
;
break
;
}
}
...
...
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