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
7f32e813
Commit
7f32e813
authored
Aug 10, 2011
by
itsyplen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updating samples using cmd parser
parent
86cd9fad
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
31 deletions
+45
-31
bgfg_segm.cpp
samples/cpp/bgfg_segm.cpp
+20
-7
brief_match_test.cpp
samples/cpp/brief_match_test.cpp
+25
-24
No files found.
samples/cpp/bgfg_segm.cpp
View file @
7f32e813
#include "opencv2/core/core.hpp"
#include "opencv2/video/background_segm.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <stdio.h>
using
namespace
std
;
using
namespace
cv
;
void
help
()
...
...
@@ -9,22 +11,33 @@ void help()
printf
(
"
\n
Do background segmentation, especially demonstrating the use of cvUpdateBGStatModel().
\n
"
"Learns the background at the start and then segments.
\n
"
"Learning is togged by the space key. Will read from file or camera
\n
"
"
Call:
\n
"
"
./ bgfg_segm [file name -- if no name, read from camera]
\n\n
"
);
"
Usage:
\n
"
"
./bgfg_segm [--camera]=<use camera, if this key is present>, [--file_name]=<path to movie file>
\n\n
"
);
}
const
char
*
keys
=
{
"{c |camera |false | use camera or not}"
"{fn|file_name|tree.avi | movie file }"
};
//this is a sample for foreground detection functions
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
c
onst
c
har
**
argv
)
{
help
();
CommandLineParser
parser
(
argc
,
argv
,
keys
);
bool
useCamera
=
parser
.
get
<
bool
>
(
"camera"
);
string
file
=
parser
.
get
<
string
>
(
"file_name"
);
VideoCapture
cap
;
bool
update_bg_model
=
true
;
if
(
argc
<
2
)
if
(
useCamera
)
cap
.
open
(
0
);
else
cap
.
open
(
argv
[
1
]
);
help
();
cap
.
open
(
file
.
c_str
()
);
parser
.
printParams
();
if
(
!
cap
.
isOpened
()
)
{
printf
(
"can not open camera or video file
\n
"
);
...
...
samples/cpp/brief_match_test.cpp
View file @
7f32e813
...
...
@@ -4,6 +4,7 @@
* Created on: Oct 17, 2010
* Author: ethan
*/
#include "opencv2/core/core.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/imgproc/imgproc.hpp"
...
...
@@ -12,20 +13,7 @@
#include <iostream>
using
namespace
cv
;
using
std
::
cout
;
using
std
::
cerr
;
using
std
::
endl
;
using
std
::
vector
;
void
help
(
char
**
av
)
{
cerr
<<
"usage: "
<<
av
[
0
]
<<
" im1.jpg im2.jpg"
<<
"
\n
"
<<
"This program shows how to use BRIEF descriptor to match points in features2d
\n
"
<<
"It takes in two images, finds keypoints and matches them displaying matches and final homography warped results
\n
"
<<
endl
;
}
using
namespace
std
;
//Copy (x,y) location of descriptor matches found from KeyPoint data structures into Point2f vectors
void
matches2points
(
const
vector
<
DMatch
>&
matches
,
const
vector
<
KeyPoint
>&
kpts_train
,
...
...
@@ -53,25 +41,38 @@ double match(const vector<KeyPoint>& /*kpts_train*/, const vector<KeyPoint>& /*k
return
((
double
)
getTickCount
()
-
t
)
/
getTickFrequency
();
}
void
help
()
{
printf
(
"This program shows how to use BRIEF descriptor to match points in features2d
\n
"
"It takes in two images, finds keypoints and matches them displaying matches and final homography warped results
\n
"
"Usage:
\n
"
"image1 image2
\n
"
"Example:
\n
"
"box.png box_in_scene.png
\n
"
);
}
const
char
*
keys
=
{
"{1| |box.png |the first image}"
"{2| |box_in_scene.png|the second image}"
};
int
main
(
int
a
c
,
char
**
a
v
)
int
main
(
int
a
rgc
,
const
char
**
arg
v
)
{
if
(
ac
!=
3
)
{
help
(
av
);
return
1
;
}
string
im1_name
,
im2_name
;
im1_name
=
av
[
1
];
im2_name
=
av
[
2
];
help
();
CommandLineParser
parser
(
argc
,
argv
,
keys
);
string
im1_name
=
parser
.
get
<
string
>
(
"1"
);
string
im2_name
=
parser
.
get
<
string
>
(
"2"
);
Mat
im1
=
imread
(
im1_name
,
CV_LOAD_IMAGE_GRAYSCALE
);
Mat
im2
=
imread
(
im2_name
,
CV_LOAD_IMAGE_GRAYSCALE
);
if
(
im1
.
empty
()
||
im2
.
empty
())
{
cerr
<<
"could not open one of the images..."
<<
endl
;
printf
(
"could not open one of the images...
\n
"
);
printf
(
"the cmd parameters have next current value:
\n
"
);
parser
.
printParams
();
return
1
;
}
...
...
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