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
ad6c87b0
Commit
ad6c87b0
authored
Dec 27, 2014
by
Davis King
Browse files
Merge github.com:davisking/dlib
parents
1ab34825
d4cbaecd
Changes
26
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
3115 additions
and
2896 deletions
+3115
-2896
.hgtags
.hgtags
+1
-0
dlib/CMakeLists.txt
dlib/CMakeLists.txt
+3
-0
dlib/add_python_module
dlib/add_python_module
+11
-6
dlib/cmake
dlib/cmake
+3
-0
dlib/image_processing/shape_predictor.h
dlib/image_processing/shape_predictor.h
+0
-11
dlib/image_processing/shape_predictor_abstract.h
dlib/image_processing/shape_predictor_abstract.h
+1
-1
dlib/image_transforms/interpolation.h
dlib/image_transforms/interpolation.h
+1
-1
dlib/image_transforms/morphological_operations.h
dlib/image_transforms/morphological_operations.h
+177
-0
dlib/image_transforms/morphological_operations_abstract.h
dlib/image_transforms/morphological_operations_abstract.h
+24
-0
dlib/image_transforms/spatial_filtering.h
dlib/image_transforms/spatial_filtering.h
+2
-2
dlib/image_transforms/spatial_filtering_abstract.h
dlib/image_transforms/spatial_filtering_abstract.h
+3
-1
dlib/matlab/CMakeLists.txt
dlib/matlab/CMakeLists.txt
+15
-15
dlib/matlab/README.txt
dlib/matlab/README.txt
+20
-20
dlib/matlab/call_matlab.h
dlib/matlab/call_matlab.h
+458
-458
dlib/matlab/cmake_mex_wrapper
dlib/matlab/cmake_mex_wrapper
+70
-70
dlib/matlab/example_mex_callback.cpp
dlib/matlab/example_mex_callback.cpp
+52
-51
dlib/matlab/example_mex_function.cpp
dlib/matlab/example_mex_function.cpp
+72
-71
dlib/matlab/mex_wrapper.cpp
dlib/matlab/mex_wrapper.cpp
+2191
-2188
dlib/test/image.cpp
dlib/test/image.cpp
+10
-0
docs/.current_minor_release_number
docs/.current_minor_release_number
+1
-1
No files found.
.hgtags
View file @
ad6c87b0
...
...
@@ -21,3 +21,4 @@ a6c2b16111b8023dbded7299dcc7e6acd26671b8 v18.8
4de62892e10850e8f0205b4857cf48b31fd730c8 v18.9
5a14394843c04628990857e5db94ff6bc43c2da0 v18.10
dd8e950033d5026373acce9ed4b2ffb85908d3b5 v18.11
4e3941b13ca859f788853cfcef9973ac4b161e65 v18.12
dlib/CMakeLists.txt
View file @
ad6c87b0
...
...
@@ -12,6 +12,9 @@ set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
# Suppress cmake warnings about changes in new versions.
if
(
COMMAND cmake_policy
)
cmake_policy
(
SET CMP0003 NEW
)
if
(
POLICY CMP0054
)
cmake_policy
(
SET CMP0054 NEW
)
endif
()
endif
()
...
...
dlib/add_python_module
View file @
ad6c87b0
...
...
@@ -20,10 +20,13 @@
# A list of various paths you need to search on windows since people install
# boost in a bunch of different places.
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH}
"C:/local/boost_1_*"
"C:/Program Files (x86)/boost/boost_1_*"
"C:/Program Files/boost/boost_1_*")
set(BOOST_LIBRARYDIR "C:/local/boost_1_*/lib32-msvc-*")
C:/local/boost_*
C:/Program\ Files\ \(x86\)/boost/boost_*
C:/Program\ Files/boost/boost_*
)
set(BOOST_LIBRARYDIR ${BOOST_LIBRARYDIR} $ENV{BOOST_LIBRARYDIR}
C:/local/boost_*/lib32-msvc-*
)
...
...
@@ -32,8 +35,10 @@ set(BOOST_LIBRARYDIR "C:/local/boost_1_*/lib32-msvc-*")
#SET(Boost_USE_STATIC_RUNTIME OFF)
set(Boost_NO_BOOST_CMAKE ON)
set(BOOST_LIBRARYDIR /usr/lib/x86_64-linux-gnu/)
if (NOT WIN32)
set(BOOST_LIBRARYDIR ${BOOST_LIBRARYDIR} $ENV{BOOST_LIBRARYDIR}
/usr/lib/x86_64-linux-gnu/)
endif()
if (PYTHON3)
FIND_PACKAGE(Boost 1.41.0 COMPONENTS python-py34 REQUIRED)
FIND_PACKAGE(PythonLibs 3.4 REQUIRED)
...
...
dlib/cmake
View file @
ad6c87b0
...
...
@@ -3,6 +3,9 @@ cmake_minimum_required(VERSION 2.6.4)
set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
if (POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
endif()
# Don't add dlib if it's already been added to the cmake project
if (NOT TARGET dlib)
...
...
dlib/image_processing/shape_predictor.h
View file @
ad6c87b0
...
...
@@ -315,10 +315,6 @@ namespace dlib
unsigned
long
num_parts
(
)
const
/*!
ensures
- returns the number of points in the shape
!*/
{
return
initial_shape
.
size
()
/
2
;
}
...
...
@@ -328,13 +324,6 @@ namespace dlib
const
image_type
&
img
,
const
rectangle
&
rect
)
const
/*!
ensures
- runs the tree regressor on the detection rect inside img and returns a
full_object_detection DET such that:
- DET.get_rect() == rect
- DET.num_parts() == num_parts()
!*/
{
using
namespace
impl
;
matrix
<
float
,
0
,
1
>
current_shape
=
initial_shape
;
...
...
dlib/image_processing/shape_predictor_abstract.h
View file @
ad6c87b0
...
...
@@ -270,7 +270,7 @@ namespace dlib
of the box. So a padding of 0.5 would cause the algorithm to sample
pixels from a box that was 2x2, effectively multiplying the area pixels
are sampled from by 4. Similarly, setting the padding to -0.2 would
cause it to sample from a box 0.
8
x0.
8
in size.
cause it to sample from a box 0.
6
x0.
6
in size.
!*/
void
set_feature_pool_region_padding
(
...
...
dlib/image_transforms/interpolation.h
View file @
ad6c87b0
...
...
@@ -1621,7 +1621,7 @@ namespace dlib
}
// now make an image pyramid
dlib
::
array
<
image_type
1
>
levels
(
max_depth
);
dlib
::
array
<
image_type
2
>
levels
(
max_depth
);
if
(
levels
.
size
()
!=
0
)
pyr
(
img
,
levels
[
0
]);
for
(
unsigned
long
i
=
1
;
i
<
levels
.
size
();
++
i
)
...
...
dlib/image_transforms/morphological_operations.h
View file @
ad6c87b0
...
...
@@ -6,6 +6,7 @@
#include "../pixel.h"
#include "thresholding.h"
#include "morphological_operations_abstract.h"
#include "assign_image.h"
namespace
dlib
{
...
...
@@ -662,6 +663,182 @@ namespace dlib
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
namespace
impl
{
template
<
typename
image_type
>
inline
bool
should_remove_pixel
(
const
image_type
&
img
,
long
r
,
long
c
,
int
iter
)
{
unsigned
int
p2
=
img
[
r
-
1
][
c
];
unsigned
int
p3
=
img
[
r
-
1
][
c
+
1
];
unsigned
int
p4
=
img
[
r
][
c
+
1
];
unsigned
int
p5
=
img
[
r
+
1
][
c
+
1
];
unsigned
int
p6
=
img
[
r
+
1
][
c
];
unsigned
int
p7
=
img
[
r
+
1
][
c
-
1
];
unsigned
int
p8
=
img
[
r
][
c
-
1
];
unsigned
int
p9
=
img
[
r
-
1
][
c
-
1
];
int
A
=
(
p2
==
0
&&
p3
==
255
)
+
(
p3
==
0
&&
p4
==
255
)
+
(
p4
==
0
&&
p5
==
255
)
+
(
p5
==
0
&&
p6
==
255
)
+
(
p6
==
0
&&
p7
==
255
)
+
(
p7
==
0
&&
p8
==
255
)
+
(
p8
==
0
&&
p9
==
255
)
+
(
p9
==
0
&&
p2
==
255
);
int
B
=
p2
+
p3
+
p4
+
p5
+
p6
+
p7
+
p8
+
p9
;
int
m1
=
iter
==
0
?
(
p2
*
p4
*
p6
)
:
(
p2
*
p4
*
p8
);
int
m2
=
iter
==
0
?
(
p4
*
p6
*
p8
)
:
(
p2
*
p6
*
p8
);
// Decide if we should remove the pixel img[r][c].
return
(
A
==
1
&&
(
B
>=
2
*
255
&&
B
<=
6
*
255
)
&&
m1
==
0
&&
m2
==
0
);
}
template
<
typename
image_type
>
inline
void
add_to_remove
(
std
::
vector
<
point
>&
to_remove
,
array2d
<
unsigned
char
>&
marker
,
const
image_type
&
img
,
long
r
,
long
c
,
int
iter
)
{
if
(
marker
[
r
][
c
]
&&
should_remove_pixel
(
img
,
r
,
c
,
iter
))
{
to_remove
.
push_back
(
point
(
c
,
r
));
marker
[
r
][
c
]
=
0
;
}
}
template
<
typename
image_type
>
inline
bool
is_bw_border_pixel
(
const
image_type
&
img
,
long
r
,
long
c
)
{
unsigned
int
p2
=
img
[
r
-
1
][
c
];
unsigned
int
p3
=
img
[
r
-
1
][
c
+
1
];
unsigned
int
p4
=
img
[
r
][
c
+
1
];
unsigned
int
p5
=
img
[
r
+
1
][
c
+
1
];
unsigned
int
p6
=
img
[
r
+
1
][
c
];
unsigned
int
p7
=
img
[
r
+
1
][
c
-
1
];
unsigned
int
p8
=
img
[
r
][
c
-
1
];
unsigned
int
p9
=
img
[
r
-
1
][
c
-
1
];
int
B
=
p2
+
p3
+
p4
+
p5
+
p6
+
p7
+
p8
+
p9
;
// If you are on but at least one of your neighbors isn't.
return
B
<
8
*
255
&&
img
[
r
][
c
];
}
inline
void
add_if
(
std
::
vector
<
point
>&
to_check2
,
const
array2d
<
unsigned
char
>&
marker
,
long
c
,
long
r
)
{
if
(
marker
[
r
][
c
])
to_check2
.
push_back
(
point
(
c
,
r
));
}
}
// end namespace impl
// ----------------------------------------------------------------------------------------
template
<
typename
image_type
>
void
skeleton
(
image_type
&
img_
)
{
/*
The implementation of this function is based on the paper
"A fast parallel algorithm for thinning digital patterns” by T.Y. Zhang and C.Y. Suen.
and also the excellent discussion of it at:
http://opencv-code.com/quick-tips/implementation-of-thinning-algorithm-in-opencv/
*/
typedef
typename
image_traits
<
image_type
>::
pixel_type
pixel_type
;
// This function only works on grayscale images
COMPILE_TIME_ASSERT
(
pixel_traits
<
pixel_type
>::
grayscale
);
using
namespace
impl
;
// Note that it's important to zero the border for 2 reasons. First, it allows
// thinning to being at the border of the image. But more importantly, it causes
// the mask to have a border of 0 pixels as well which we use later to avoid
// indexing outside the image inside add_to_remove().
zero_border_pixels
(
img_
,
1
,
1
);
image_view
<
image_type
>
img
(
img_
);
// We use the marker to keep track of pixels we have committed to removing but
// haven't yet removed from img.
array2d
<
unsigned
char
>
marker
(
img
.
nr
(),
img
.
nc
());
assign_image
(
marker
,
img
);
// Begin by making a list of the pixels on the borders of binary blobs.
std
::
vector
<
point
>
to_remove
,
to_check
,
to_check2
;
for
(
int
r
=
1
;
r
<
img
.
nr
()
-
1
;
r
++
)
{
for
(
int
c
=
1
;
c
<
img
.
nc
()
-
1
;
c
++
)
{
if
(
is_bw_border_pixel
(
img
,
r
,
c
))
{
to_check
.
push_back
(
point
(
c
,
r
));
}
}
}
// Now start iteratively looking at the border pixels and removing them.
while
(
to_check
.
size
()
!=
0
)
{
for
(
int
iter
=
0
;
iter
<=
1
;
++
iter
)
{
// Check which pixels we should remove
to_remove
.
clear
();
for
(
unsigned
long
i
=
0
;
i
<
to_check
.
size
();
++
i
)
{
long
r
=
to_check
[
i
].
y
();
long
c
=
to_check
[
i
].
x
();
add_to_remove
(
to_remove
,
marker
,
img
,
r
,
c
,
iter
);
}
for
(
unsigned
long
i
=
0
;
i
<
to_check2
.
size
();
++
i
)
{
long
r
=
to_check2
[
i
].
y
();
long
c
=
to_check2
[
i
].
x
();
add_to_remove
(
to_remove
,
marker
,
img
,
r
,
c
,
iter
);
}
// Now remove those pixels. Also add their neighbors into the "to check"
// pixel list for the next iteration.
for
(
unsigned
long
i
=
0
;
i
<
to_remove
.
size
();
++
i
)
{
long
r
=
to_remove
[
i
].
y
();
long
c
=
to_remove
[
i
].
x
();
// remove the pixel
img
[
r
][
c
]
=
0
;
add_if
(
to_check2
,
marker
,
c
-
1
,
r
-
1
);
add_if
(
to_check2
,
marker
,
c
,
r
-
1
);
add_if
(
to_check2
,
marker
,
c
+
1
,
r
-
1
);
add_if
(
to_check2
,
marker
,
c
-
1
,
r
);
add_if
(
to_check2
,
marker
,
c
+
1
,
r
);
add_if
(
to_check2
,
marker
,
c
-
1
,
r
+
1
);
add_if
(
to_check2
,
marker
,
c
,
r
+
1
);
add_if
(
to_check2
,
marker
,
c
+
1
,
r
+
1
);
}
}
to_check
.
clear
();
to_check
.
swap
(
to_check2
);
}
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
}
...
...
dlib/image_transforms/morphological_operations_abstract.h
View file @
ad6c87b0
...
...
@@ -283,6 +283,30 @@ namespace dlib
- calls binary_complement(img,img);
!*/
// ----------------------------------------------------------------------------------------
template
<
typename
image_type
>
void
skeleton
(
image_type
&
img
);
/*!
requires
- image_type is an object that implement the interface defined in
dlib/image_processing/generic_image.h
- img must contain a grayscale pixel type.
- all pixels in img are set to either on_pixel or off_pixel.
(i.e. it must be a binary image)
ensures
- This function computes the skeletonization of img and stores the result in
#img. That is, given a binary image, we progressively thin the binary blobs
(composed of on_pixel values) until only a single pixel wide skeleton of the
original blobs remains.
- #img.nc() == img.nc()
- #img.nr() == img.nr()
!*/
// ----------------------------------------------------------------------------------------
}
...
...
dlib/image_transforms/spatial_filtering.h
View file @
ad6c87b0
...
...
@@ -1217,7 +1217,7 @@ namespace dlib
typename
in_image_type
,
typename
out_image_type
>
void
gaussian_blur
(
rectangle
gaussian_blur
(
const
in_image_type
&
in_img
,
out_image_type
&
out_img
,
double
sigma
=
1
,
...
...
@@ -1241,7 +1241,7 @@ namespace dlib
ptype
scale
=
sum
(
filt
);
scale
=
scale
*
scale
;
spatially_filter_image_separable
(
in_img
,
out_img
,
filt
,
filt
,
scale
);
return
spatially_filter_image_separable
(
in_img
,
out_img
,
filt
,
filt
,
scale
);
}
...
...
dlib/image_transforms/spatial_filtering_abstract.h
View file @
ad6c87b0
...
...
@@ -353,7 +353,7 @@ namespace dlib
typename
in_image_type
,
typename
out_image_type
>
void
gaussian_blur
(
rectangle
gaussian_blur
(
const
in_image_type
&
in_img
,
out_image_type
&
out_img
,
double
sigma
=
1
,
...
...
@@ -384,6 +384,8 @@ namespace dlib
inside the image are set to zero.
- #out_img.nc() == in_img.nc()
- #out_img.nr() == in_img.nr()
- returns a rectangle which indicates what pixels in #out_img are considered
non-border pixels and therefore contain output from the filter.
!*/
// ----------------------------------------------------------------------------------------
...
...
dlib/matlab/CMakeLists.txt
View file @
ad6c87b0
dlib/matlab/README.txt
View file @
ad6c87b0
dlib/matlab/call_matlab.h
View file @
ad6c87b0
dlib/matlab/cmake_mex_wrapper
View file @
ad6c87b0
# This file figure
d
out where MATLAB is and then defines a macro, add_mex_function(name)
# This file figure
s
out where MATLAB is and then defines a macro, add_mex_function(name)
# which when called instructs CMake to build a mex file from a file called name.cpp. Note
# that additional library dependencies can be added like this: add_mex_function(name lib1 dlib libetc).
# That is, just add more libraries after the name and they will be build into the mex file.
...
...
dlib/matlab/example_mex_callback.cpp
View file @
ad6c87b0
// The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt
#include "call_matlab.h"
#include "dlib/matrix.h"
...
...
dlib/matlab/example_mex_function.cpp
View file @
ad6c87b0
// The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt
#include "dlib/matrix.h"
using
namespace
dlib
;
...
...
dlib/matlab/mex_wrapper.cpp
View file @
ad6c87b0
// Copyright (C) 2012 Massachusetts Institute of Technology, Lincoln Laboratory
// License: Boost Software License See LICENSE.txt for the full license.
// Authors: Davis E. King (davis@dlib.net)
/*
READ THIS FIRST
######
...
...
dlib/test/image.cpp
View file @
ad6c87b0
...
...
@@ -1800,6 +1800,16 @@ namespace
for
(
int
i
=
0
;
i
<
100
;
++
i
)
test_separable_filtering_center
<
float
>
(
rnd
);
{
print_spinner
();
matrix
<
unsigned
char
>
img
(
40
,
80
);
assign_all_pixels
(
img
,
255
);
skeleton
(
img
);
DLIB_TEST
(
sum
(
matrix_cast
<
int
>
(
mat
(
img
)))
/
255
==
40
);
draw_line
(
img
,
point
(
20
,
19
),
point
(
59
,
19
),
00
);
DLIB_TEST
(
sum
(
matrix_cast
<
int
>
(
mat
(
img
)))
==
0
);
}
}
}
a
;
...
...
docs/.current_minor_release_number
View file @
ad6c87b0
1
1
1
2
Prev
1
2
Next
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