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
64bf5583
Commit
64bf5583
authored
Jul 17, 2014
by
Davis King
Browse files
Fixed a few things so they work with the new image generic interface.
parent
fa2499d8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
46 deletions
+29
-46
dlib/image_processing/scan_fhog_pyramid.h
dlib/image_processing/scan_fhog_pyramid.h
+2
-1
dlib/image_transforms/interpolation.h
dlib/image_transforms/interpolation.h
+2
-2
dlib/python/numpy_image.h
dlib/python/numpy_image.h
+25
-43
No files found.
dlib/image_processing/scan_fhog_pyramid.h
View file @
64bf5583
...
...
@@ -598,7 +598,8 @@ namespace dlib
if
(
feats
.
size
()
>
1
)
{
image_type
temp1
,
temp2
;
typedef
typename
image_traits
<
image_type
>::
pixel_type
pixel_type
;
array2d
<
pixel_type
>
temp1
,
temp2
;
pyr
(
img
,
temp1
);
fe
(
temp1
,
feats
[
1
],
cell_size
,
filter_rows_padding
,
filter_cols_padding
);
swap
(
temp1
,
temp2
);
...
...
dlib/image_transforms/interpolation.h
View file @
64bf5583
...
...
@@ -515,8 +515,8 @@ namespace dlib
<<
"
\n\t
is_same_object(in_img, out_img): "
<<
is_same_object
(
in_img
,
out_img
)
);
const
double
x_scale
=
(
in_img
.
nc
(
)
-
1
)
/
(
double
)
std
::
max
<
long
>
((
out_img
.
nc
(
)
-
1
),
1
);
const
double
y_scale
=
(
in_img
.
nr
(
)
-
1
)
/
(
double
)
std
::
max
<
long
>
((
out_img
.
nr
(
)
-
1
),
1
);
const
double
x_scale
=
(
num_columns
(
in_img
)
-
1
)
/
(
double
)
std
::
max
<
long
>
((
num_columns
(
out_img
)
-
1
),
1
);
const
double
y_scale
=
(
num_rows
(
in_img
)
-
1
)
/
(
double
)
std
::
max
<
long
>
((
num_rows
(
out_img
)
-
1
),
1
);
transform_image
(
in_img
,
out_img
,
interp
,
dlib
::
impl
::
helper_resize_image
(
x_scale
,
y_scale
));
}
...
...
dlib/python/numpy_image.h
View file @
64bf5583
...
...
@@ -13,8 +13,6 @@
class
numpy_gray_image
{
public:
typedef
unsigned
char
type
;
typedef
dlib
::
default_memory_manager
mem_manager_type
;
numpy_gray_image
()
:
_data
(
0
),
_nr
(
0
),
_nc
(
0
)
{}
numpy_gray_image
(
boost
::
python
::
object
&
img
)
...
...
@@ -25,34 +23,26 @@ public:
_nc
=
shape
[
1
];
}
unsigned
long
size
()
const
{
return
static_cast
<
unsigned
long
>
(
_nr
*
_nc
);
}
inline
type
*
operator
[](
const
long
row
)
{
return
_data
+
_nc
*
row
;
}
inline
const
type
*
operator
[](
const
long
row
)
const
{
return
_data
+
_nc
*
row
;
}
long
nr
()
const
{
return
_nr
;
}
long
nc
()
const
{
return
_nc
;
}
long
width_step
()
const
{
return
nc
()
*
sizeof
(
type
);
}
friend
inline
long
num_rows
(
const
numpy_gray_image
&
img
)
{
return
img
.
_nr
;
}
friend
inline
long
num_columns
(
const
numpy_gray_image
&
img
)
{
return
img
.
_nc
;
}
friend
inline
void
*
image_data
(
numpy_gray_image
&
img
)
{
return
img
.
_data
;
}
friend
inline
const
void
*
image_data
(
const
numpy_gray_image
&
img
)
{
return
img
.
_data
;
}
friend
inline
long
width_step
(
const
numpy_gray_image
&
img
)
{
return
img
.
_nc
*
sizeof
(
unsigned
char
);
}
private:
type
*
_data
;
unsigned
char
*
_data
;
long
_nr
;
long
_nc
;
};
// ----------------------------------------------------------------------------------------
inline
const
dlib
::
matrix_op
<
dlib
::
op_array2d_to_mat
<
numpy_gray_image
>
>
mat
(
const
numpy_gray_image
&
m
)
namespace
dlib
{
using
namespace
dlib
;
typedef
op_array2d_to_mat
<
numpy_gray_image
>
op
;
return
matrix_op
<
op
>
(
op
(
m
));
template
<
>
struct
image_traits
<
numpy_gray_image
>
{
typedef
unsigned
char
pixel_type
;
};
}
// ----------------------------------------------------------------------------------------
...
...
@@ -75,8 +65,6 @@ inline bool is_gray_python_image (boost::python::object& img)
class
numpy_rgb_image
{
public:
typedef
dlib
::
rgb_pixel
type
;
typedef
dlib
::
default_memory_manager
mem_manager_type
;
numpy_rgb_image
()
:
_data
(
0
),
_nr
(
0
),
_nc
(
0
)
{}
numpy_rgb_image
(
boost
::
python
::
object
&
img
)
...
...
@@ -89,38 +77,32 @@ public:
throw
dlib
::
error
(
"Error, python object is not a three band image and therefore can't be a RGB image."
);
}
unsigned
long
size
()
const
{
return
static_cast
<
unsigned
long
>
(
_nr
*
_nc
);
}
friend
inline
long
num_rows
(
const
numpy_rgb_image
&
img
)
{
return
img
.
_nr
;
}
friend
inline
long
num_columns
(
const
numpy_rgb_image
&
img
)
{
return
img
.
_nc
;
}
friend
inline
void
*
image_data
(
numpy_rgb_image
&
img
)
{
return
img
.
_data
;
}
friend
inline
const
void
*
image_data
(
const
numpy_rgb_image
&
img
)
{
return
img
.
_data
;
}
friend
inline
long
width_step
(
const
numpy_rgb_image
&
img
)
{
return
img
.
_nc
*
sizeof
(
dlib
::
rgb_pixel
);
}
inline
type
*
operator
[](
const
long
row
)
{
return
_data
+
_nc
*
row
;
}
inline
const
type
*
operator
[](
const
long
row
)
const
{
return
_data
+
_nc
*
row
;
}
long
nr
()
const
{
return
_nr
;
}
long
nc
()
const
{
return
_nc
;
}
long
width_step
()
const
{
return
nc
()
*
sizeof
(
type
);
}
private:
type
*
_data
;
dlib
::
rgb_pixel
*
_data
;
long
_nr
;
long
_nc
;
};
// ----------------------------------------------------------------------------------------
inline
const
dlib
::
matrix_op
<
dlib
::
op_array2d_to_mat
<
numpy_rgb_image
>
>
mat
(
const
numpy_rgb_image
&
m
)
namespace
dlib
{
using
namespace
dlib
;
typedef
op_array2d_to_mat
<
numpy_rgb_image
>
op
;
return
matrix_op
<
op
>
(
op
(
m
));
template
<
>
struct
image_traits
<
numpy_rgb_image
>
{
typedef
rgb_pixel
pixel_type
;
};
}
// ----------------------------------------------------------------------------------------
inline
bool
is_rgb_python_image
(
boost
::
python
::
object
&
img
)
{
try
...
...
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