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
bc64567d
Commit
bc64567d
authored
Aug 11, 2011
by
itsyplen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update samples using cmd parser
parent
1863f58a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
54 deletions
+72
-54
dft.cpp
samples/cpp/dft.cpp
+16
-10
distrans.cpp
samples/cpp/distrans.cpp
+29
-23
drawing.cpp
samples/cpp/drawing.cpp
+7
-7
edge.cpp
samples/cpp/edge.cpp
+20
-14
No files found.
samples/cpp/dft.cpp
View file @
bc64567d
...
...
@@ -2,31 +2,37 @@
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <iostream>
#include <stdio.h>
using
namespace
cv
;
using
namespace
std
;
void
help
()
{
cout
<<
"
\n
This program demonstrated the use of the discrete Fourier transform (dft)
\n
"
"The dft of an image is taken and it's power spectrum is displayed.
\n
"
"Call
:
\n
"
"./dft [image_name -- default lena.jpg]
\n
"
<<
endl
;
printf
(
"
\n
This program demonstrated the use of the discrete Fourier transform (dft)
\n
"
"The dft of an image is taken and it's power spectrum is displayed.
\n
"
"Usage
:
\n
"
"./dft [image_name -- default lena.jpg]
\n
"
)
;
}
const
char
*
keys
=
{
"{1| |lena.jpg|input image file}"
};
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
const
char
**
argv
)
{
const
char
*
filename
=
argc
>=
2
?
argv
[
1
]
:
"lena.jpg"
;
help
();
CommandLineParser
parser
(
argc
,
argv
,
keys
);
string
filename
=
parser
.
get
<
string
>
(
"1"
);
Mat
img
=
imread
(
filename
,
CV_LOAD_IMAGE_GRAYSCALE
);
Mat
img
=
imread
(
filename
.
c_str
()
,
CV_LOAD_IMAGE_GRAYSCALE
);
if
(
img
.
empty
()
)
{
help
();
printf
(
"Cannot read image file: %s
\n
"
,
filename
.
c_str
());
return
-
1
;
}
help
();
int
M
=
getOptimalDFTSize
(
img
.
rows
);
int
N
=
getOptimalDFTSize
(
img
.
cols
);
Mat
padded
;
...
...
samples/cpp/distrans.cpp
View file @
bc64567d
...
...
@@ -5,24 +5,6 @@
using
namespace
cv
;
void
help
()
{
printf
(
"
\n
Program to demonstrate the use of the distance transform function between edge images.
\n
"
"Usage:
\n
"
"./distrans [image_name -- default image is stuff.jpg]
\n
"
);
printf
(
"
\n
Hot keys:
\n
"
"
\t
ESC - quit the program
\n
"
"
\t
C - use C/Inf metric
\n
"
"
\t
L1 - use L1 metric
\n
"
"
\t
L2 - use L2 metric
\n
"
"
\t
3 - use 3x3 mask
\n
"
"
\t
5 - use 5x5 mask
\n
"
"
\t
0 - use precise distance transform
\n
"
"
\t
v - switch Voronoi diagram mode on/off
\n
"
"
\t
SPACE - loop through all the modes
\n
"
);
}
int
maskSize0
=
CV_DIST_MASK_5
;
bool
buildVoronoi
=
false
;
int
edgeThresh
=
100
;
...
...
@@ -101,17 +83,41 @@ void onTrackbar( int, void* )
imshow
(
"Distance Map"
,
dist8u
);
}
int
main
(
int
argc
,
char
**
argv
)
void
help
()
{
printf
(
"
\n
Program to demonstrate the use of the distance transform function between edge images.
\n
"
"Usage:
\n
"
"./distrans [image_name -- default image is stuff.jpg]
\n
"
"
\n
Hot keys:
\n
"
"
\t
ESC - quit the program
\n
"
"
\t
C - use C/Inf metric
\n
"
"
\t
L1 - use L1 metric
\n
"
"
\t
L2 - use L2 metric
\n
"
"
\t
3 - use 3x3 mask
\n
"
"
\t
5 - use 5x5 mask
\n
"
"
\t
0 - use precise distance transform
\n
"
"
\t
v - switch Voronoi diagram mode on/off
\n
"
"
\t
SPACE - loop through all the modes
\n\n
"
);
}
const
char
*
keys
=
{
char
*
filename
=
argc
==
2
?
argv
[
1
]
:
(
char
*
)
"stuff.jpg"
;
gray
=
imread
(
filename
,
0
);
"{1| |stuff.jpg|input image file}"
};
int
main
(
int
argc
,
const
char
**
argv
)
{
help
();
CommandLineParser
parser
(
argc
,
argv
,
keys
);
string
filename
=
parser
.
get
<
string
>
(
"1"
);
gray
=
imread
(
filename
.
c_str
(),
0
);
if
(
gray
.
empty
())
{
help
();
printf
(
"Cannot read image file: %s
\n
"
,
filename
.
c_str
());
help
();
return
-
1
;
}
help
();
namedWindow
(
"Distance Map"
,
1
);
createTrackbar
(
"Brightness Threshold"
,
"Distance Map"
,
&
edgeThresh
,
255
,
onTrackbar
,
0
);
...
...
samples/cpp/drawing.cpp
View file @
bc64567d
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <
iostream
>
#include <
stdio.h
>
using
namespace
cv
;
void
help
()
{
std
::
cout
<<
"
\n
This program demonstrates OpenCV drawing and text output functions.
\n
"
"Call:
\n
"
"./drawing
\n
"
<<
std
::
endl
;
printf
(
"
\n
This program demonstrates OpenCV drawing and text output functions.
\n
"
"Usage:
\n
"
" ./drawing
\n
"
);
}
static
Scalar
randomColor
(
RNG
&
rng
)
{
...
...
@@ -16,9 +15,10 @@ static Scalar randomColor(RNG& rng)
return
Scalar
(
icolor
&
255
,
(
icolor
>>
8
)
&
255
,
(
icolor
>>
16
)
&
255
);
}
int
main
(
int
,
char
**
)
int
main
()
{
char
wndname
[]
=
"Drawing Demo"
;
help
();
char
wndname
[]
=
"Drawing Demo"
;
const
int
NUMBER
=
100
;
const
int
DELAY
=
5
;
int
lineType
=
CV_AA
;
// change it to 8 to see non-antialiased graphics
...
...
samples/cpp/edge.cpp
View file @
bc64567d
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <
iostream
>
#include <
stdio.h
>
using
namespace
cv
;
using
namespace
std
;
void
help
()
{
cout
<<
"
\n
Demonstrate Canny edge detection
\n
"
"Call:
\n
"
"/.edge [image_name -- Default is fruits.jpg]
\n
"
<<
endl
;
}
int
edgeThresh
=
1
;
Mat
image
,
gray
,
edge
,
cedge
;
...
...
@@ -31,17 +22,32 @@ void onTrackbar(int, void*)
imshow
(
"Edge map"
,
cedge
);
}
int
main
(
int
argc
,
char
**
argv
)
void
help
()
{
printf
(
"
\n
This sample demonstrates Canny edge detection
\n
"
"Call:
\n
"
" /.edge [image_name -- Default is fruits.jpg]
\n\n
"
);
}
const
char
*
keys
=
{
char
*
filename
=
argc
==
2
?
argv
[
1
]
:
(
char
*
)
"fruits.jpg"
;
"{1| |fruits.jpg|input image name}"
};
int
main
(
int
argc
,
const
char
**
argv
)
{
help
();
CommandLineParser
parser
(
argc
,
argv
,
keys
);
string
filename
=
parser
.
get
<
string
>
(
"1"
);
image
=
imread
(
filename
,
1
);
if
(
image
.
empty
())
{
help
();
printf
(
"Cannot read image file: %s
\n
"
,
filename
.
c_str
());
help
();
return
-
1
;
}
help
();
cedge
.
create
(
image
.
size
(),
image
.
type
());
cvtColor
(
image
,
gray
,
CV_BGR2GRAY
);
...
...
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