Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
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_contrib
Commits
32ffe6c8
Commit
32ffe6c8
authored
May 31, 2014
by
Vlad Shakhuro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add icf app
parent
0d975987
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
196 additions
and
0 deletions
+196
-0
CMakeLists.txt
apps/CMakeLists.txt
+4
-0
CMakeLists.txt
apps/icf/CMakeLists.txt
+33
-0
main.cpp
apps/icf/main.cpp
+159
-0
No files found.
apps/CMakeLists.txt
0 → 100644
View file @
32ffe6c8
add_definitions
(
-D__OPENCV_BUILD=1
)
link_libraries
(
${
OPENCV_LINKER_LIBS
}
)
add_subdirectory
(
icf
)
apps/icf/CMakeLists.txt
0 → 100644
View file @
32ffe6c8
set
(
name icf
)
set
(
the_target opencv_
${
name
}
)
set
(
OPENCV_
${
the_target
}
_DEPS opencv_core opencv_imgproc
)
ocv_check_dependencies
(
${
OPENCV_
${
the_target
}
_DEPS
}
)
if
(
NOT OCV_DEPENDENCIES_FOUND
)
return
()
endif
()
project
(
${
the_target
}
)
ocv_include_directories
(
"
${
OpenCV_SOURCE_DIR
}
/include/opencv"
)
ocv_include_modules
(
${
OPENCV_
${
the_target
}
_DEPS
}
)
file
(
GLOB
${
the_target
}
_SOURCES
${
CMAKE_CURRENT_SOURCE_DIR
}
/*.cpp
)
add_executable
(
${
the_target
}
${${
the_target
}
_SOURCES
}
)
target_link_libraries
(
${
the_target
}
${
OPENCV_
${
the_target
}
_DEPS
}
)
set_target_properties
(
${
the_target
}
PROPERTIES
DEBUG_POSTFIX
"
${
OPENCV_DEBUG_POSTFIX
}
"
ARCHIVE_OUTPUT_DIRECTORY
${
LIBRARY_OUTPUT_PATH
}
RUNTIME_OUTPUT_DIRECTORY
${
EXECUTABLE_OUTPUT_PATH
}
INSTALL_NAME_DIR lib
OUTPUT_NAME
"opencv_trainicfcascade"
)
if
(
ENABLE_SOLUTION_FOLDERS
)
set_target_properties
(
${
the_target
}
PROPERTIES FOLDER
"applications"
)
endif
()
install
(
TARGETS
${
the_target
}
RUNTIME DESTINATION bin COMPONENT main
)
apps/icf/main.cpp
0 → 100644
View file @
32ffe6c8
#include <cstdio>
#include <cstring>
#include <string>
using
std
::
string
;
#include <vector>
using
std
::
vector
;
#include <opencv2/core.hpp>
using
cv
::
Rect
;
#include "icfdetector.hpp"
#include "waldboost.hpp"
static
bool
read_pos_int
(
const
char
*
str
,
int
*
n
)
{
int
pos
=
0
;
if
(
sscanf
(
str
,
"%d%n"
,
n
,
&
pos
)
!=
1
||
str
[
pos
]
!=
'\0'
||
*
n
<=
0
)
{
return
false
;
}
return
true
;
}
static
bool
read_model_size
(
char
*
str
,
int
*
rows
,
int
*
cols
)
{
int
pos
=
0
;
if
(
sscanf
(
str
,
"%dx%d%n"
,
rows
,
cols
,
&
pos
)
!=
2
||
str
[
pos
]
!=
'\0'
||
*
rows
<=
0
||
*
cols
<=
0
)
{
return
false
;
}
return
true
;
}
static
bool
read_overlap
(
const
char
*
str
,
double
*
overlap
)
{
int
pos
=
0
;
if
(
sscanf
(
str
,
"%lf%n"
,
overlap
,
&
pos
)
!=
1
||
str
[
pos
]
!=
'\0'
||
*
overlap
<
0
||
*
overlap
>
1
)
{
return
false
;
}
return
true
;
}
static
vector
<
vector
<
Rect
>
>
read_labelling
(
const
string
&
filename
)
{
return
vector
<
vector
<
Rect
>
>
();
}
static
vector
<
string
>
get_filenames
(
const
string
&
labelling_path
)
{
return
vector
<
string
>
();
}
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
==
1
)
{
printf
(
"Usage: %s OPTIONS, where OPTIONS are:
\n
"
"
\n
"
"--labelling <path> - path to labelling
\n
"
" (data should be in the same directory)
\n
"
"
\n
"
"--feature_count <count> - number of features to generate
\n
"
"
\n
"
"--weak_count <count> - number of weak classifiers in cascade
\n
"
"
\n
"
"--model_size <rowsxcols> - model size in pixels
\n
"
"
\n
"
"--overlap <measure> - number from [0, 1], means maximum
\n
"
" overlap with objects while sampling background
\n
"
"
\n
"
"--model_filename <path> - filename for saving model
\n
"
,
argv
[
0
]);
return
0
;
}
string
labelling_path
,
model_path
;
ICFDetectorParams
params
;
for
(
int
i
=
1
;
i
<
argc
;
++
i
)
{
if
(
!
strcmp
(
"--labelling"
,
argv
[
i
])
)
{
i
+=
1
;
labelling_path
=
argv
[
i
];
}
else
if
(
!
strcmp
(
"--feature_count"
,
argv
[
i
])
)
{
i
+=
1
;
if
(
!
read_pos_int
(
argv
[
i
],
&
params
.
feature_count
)
)
{
fprintf
(
stderr
,
"Error reading feature count from `%s`
\n
"
,
argv
[
i
]);
return
1
;
}
}
else
if
(
!
strcmp
(
"--weak_count"
,
argv
[
i
])
)
{
i
+=
1
;
if
(
!
read_pos_int
(
argv
[
i
],
&
params
.
weak_count
)
)
{
fprintf
(
stderr
,
"Error reading weak count from `%s`
\n
"
,
argv
[
i
]);
return
1
;
}
}
else
if
(
!
strcmp
(
"--model_size"
,
argv
[
i
])
)
{
i
+=
1
;
if
(
!
read_model_size
(
argv
[
i
],
&
params
.
model_n_rows
,
&
params
.
model_n_cols
)
)
{
fprintf
(
stderr
,
"Error reading model size from `%s`
\n
"
,
argv
[
i
]);
return
1
;
}
}
else
if
(
!
strcmp
(
"--overlap"
,
argv
[
i
])
)
{
i
+=
1
;
if
(
!
read_overlap
(
argv
[
i
],
&
params
.
overlap
)
)
{
fprintf
(
stderr
,
"Error reading overlap from `%s`
\n
"
,
argv
[
i
]);
return
1
;
}
}
else
if
(
!
strcmp
(
"--model_filename"
,
argv
[
i
])
)
{
i
+=
1
;
model_path
=
argv
[
i
];
}
else
{
fprintf
(
stderr
,
"Error: unknown argument `%s`
\n
"
,
argv
[
i
]);
return
1
;
}
}
try
{
ICFDetector
detector
;
vector
<
vector
<
Rect
>
>
labelling
=
read_labelling
(
labelling_path
);
vector
<
string
>
filenames
=
get_filenames
(
labelling_path
);
detector
.
train
(
filenames
,
labelling
,
params
);
}
catch
(
const
char
*
err
)
{
fprintf
(
stderr
,
"%s"
,
err
);
}
catch
(
...
)
{
fprintf
(
stderr
,
"Unknown error
\n
"
);
}
}
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