Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
2369ae1e
Commit
2369ae1e
authored
Mar 02, 2014
by
Davis King
Browse files
Made the python object detection tools process color images
in color instead of always converting to grayscale.
parent
849f3eb1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
4 deletions
+5
-4
python_examples/train_object_detector.py
python_examples/train_object_detector.py
+1
-1
tools/python/src/object_detection.cpp
tools/python/src/object_detection.cpp
+2
-1
tools/python/src/simple_object_detector.h
tools/python/src/simple_object_detector.h
+2
-2
No files found.
python_examples/train_object_detector.py
View file @
2369ae1e
...
@@ -46,7 +46,7 @@ options.add_left_right_image_flips = True
...
@@ -46,7 +46,7 @@ options.add_left_right_image_flips = True
# empirically by checking how well the trained detector works on a test set of
# empirically by checking how well the trained detector works on a test set of
# images you haven't trained on. Don't just leave the value set at 1. Try a
# images you haven't trained on. Don't just leave the value set at 1. Try a
# few different C values and see what works best for your data.
# few different C values and see what works best for your data.
options
.
C
=
1
options
.
C
=
5
# Tell the code how many CPU cores your computer has for the fastest training.
# Tell the code how many CPU cores your computer has for the fastest training.
options
.
num_threads
=
4
options
.
num_threads
=
4
options
.
be_verbose
=
True
options
.
be_verbose
=
True
...
...
tools/python/src/object_detection.cpp
View file @
2369ae1e
...
@@ -68,10 +68,10 @@ std::vector<rectangle> run_detector (
...
@@ -68,10 +68,10 @@ std::vector<rectangle> run_detector (
)
)
{
{
pyramid_down
<
2
>
pyr
;
pyramid_down
<
2
>
pyr
;
array2d
<
unsigned
char
>
temp
;
if
(
is_gray_python_image
(
img
))
if
(
is_gray_python_image
(
img
))
{
{
array2d
<
unsigned
char
>
temp
;
if
(
upsampling_amount
==
0
)
if
(
upsampling_amount
==
0
)
{
{
return
detector
(
numpy_gray_image
(
img
));
return
detector
(
numpy_gray_image
(
img
));
...
@@ -94,6 +94,7 @@ std::vector<rectangle> run_detector (
...
@@ -94,6 +94,7 @@ std::vector<rectangle> run_detector (
}
}
else
if
(
is_rgb_python_image
(
img
))
else
if
(
is_rgb_python_image
(
img
))
{
{
array2d
<
rgb_pixel
>
temp
;
if
(
upsampling_amount
==
0
)
if
(
upsampling_amount
==
0
)
{
{
return
detector
(
numpy_rgb_image
(
img
));
return
detector
(
numpy_rgb_image
(
img
));
...
...
tools/python/src/simple_object_detector.h
View file @
2369ae1e
...
@@ -127,7 +127,7 @@ namespace dlib
...
@@ -127,7 +127,7 @@ namespace dlib
if
(
options
.
C
<=
0
)
if
(
options
.
C
<=
0
)
throw
error
(
"Invalid C value given to train_simple_object_detector(), C must be > 0."
);
throw
error
(
"Invalid C value given to train_simple_object_detector(), C must be > 0."
);
dlib
::
array
<
array2d
<
unsigned
char
>
>
images
;
dlib
::
array
<
array2d
<
rgb_pixel
>
>
images
;
std
::
vector
<
std
::
vector
<
rectangle
>
>
boxes
,
ignore
;
std
::
vector
<
std
::
vector
<
rectangle
>
>
boxes
,
ignore
;
ignore
=
load_image_dataset
(
images
,
boxes
,
dataset_filename
);
ignore
=
load_image_dataset
(
images
,
boxes
,
dataset_filename
);
...
@@ -225,7 +225,7 @@ namespace dlib
...
@@ -225,7 +225,7 @@ namespace dlib
const
std
::
string
&
detector_filename
const
std
::
string
&
detector_filename
)
)
{
{
dlib
::
array
<
array2d
<
unsigned
char
>
>
images
;
dlib
::
array
<
array2d
<
rgb_pixel
>
>
images
;
std
::
vector
<
std
::
vector
<
rectangle
>
>
boxes
,
ignore
;
std
::
vector
<
std
::
vector
<
rectangle
>
>
boxes
,
ignore
;
ignore
=
load_image_dataset
(
images
,
boxes
,
dataset_filename
);
ignore
=
load_image_dataset
(
images
,
boxes
,
dataset_filename
);
...
...
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