Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
b6267d7e
Commit
b6267d7e
authored
Jun 01, 2018
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made the image view objects implement the generic image interface. Not sure
why I didn't do this a long time ago.
parent
771036ce
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
92 additions
and
0 deletions
+92
-0
generic_image.h
dlib/image_processing/generic_image.h
+92
-0
No files found.
dlib/image_processing/generic_image.h
View file @
b6267d7e
...
...
@@ -293,6 +293,8 @@ namespace dlib
- sets the image to have 0 pixels in it.
!*/
long
get_width_step
()
const
{
return
_width_step
;
}
private
:
char
*
_data
;
...
...
@@ -362,6 +364,8 @@ namespace dlib
}
#endif
long
get_width_step
()
const
{
return
_width_step
;
}
private
:
const
char
*
_data
;
long
_width_step
;
...
...
@@ -393,6 +397,14 @@ namespace dlib
- constructs a const_image_view from an image object
!*/
// Don't stack image views on image views since that's pointless and just slows the
// compilation.
template
<
typename
T
>
image_view
<
T
>&
make_image_view
(
image_view
<
T
>&
img
)
{
return
img
;
}
template
<
typename
T
>
const
image_view
<
T
>&
make_image_view
(
const
image_view
<
T
>&
img
)
{
return
img
;
}
template
<
typename
T
>
const_image_view
<
T
>&
make_image_view
(
const_image_view
<
T
>&
img
)
{
return
img
;
}
template
<
typename
T
>
const
const_image_view
<
T
>&
make_image_view
(
const
const_image_view
<
T
>&
img
)
{
return
img
;
}
// ----------------------------------------------------------------------------------------
template
<
typename
image_type
>
...
...
@@ -431,6 +443,86 @@ namespace dlib
objects should provide their own overload of num_rows() if needed.
!*/
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// Make the image views implement the generic image interface
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
struct
image_traits
<
image_view
<
T
>>
{
typedef
typename
image_traits
<
T
>::
pixel_type
pixel_type
;
};
template
<
typename
T
>
struct
image_traits
<
const
image_view
<
T
>>
{
typedef
typename
image_traits
<
T
>::
pixel_type
pixel_type
;
};
template
<
typename
T
>
inline
long
num_rows
(
const
image_view
<
T
>&
img
)
{
return
img
.
nr
();
}
template
<
typename
T
>
inline
long
num_columns
(
const
image_view
<
T
>&
img
)
{
return
img
.
nc
();
}
template
<
typename
T
>
inline
void
set_image_size
(
image_view
<
T
>&
img
,
long
rows
,
long
cols
)
{
img
.
set_size
(
rows
,
cols
);
}
template
<
typename
T
>
inline
void
*
image_data
(
image_view
<
T
>&
img
)
{
if
(
img
.
size
()
!=
0
)
return
&
img
[
0
][
0
];
else
return
0
;
}
template
<
typename
T
>
inline
const
void
*
image_data
(
const
image_view
<
T
>&
img
)
{
if
(
img
.
size
()
!=
0
)
return
&
img
[
0
][
0
];
else
return
0
;
}
template
<
typename
T
>
inline
long
width_step
(
const
image_view
<
T
>&
img
)
{
return
img
.
get_width_step
();
}
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
struct
image_traits
<
const_image_view
<
T
>>
{
typedef
typename
image_traits
<
T
>::
pixel_type
pixel_type
;
};
template
<
typename
T
>
struct
image_traits
<
const
const_image_view
<
T
>>
{
typedef
typename
image_traits
<
T
>::
pixel_type
pixel_type
;
};
template
<
typename
T
>
inline
long
num_rows
(
const
const_image_view
<
T
>&
img
)
{
return
img
.
nr
();
}
template
<
typename
T
>
inline
long
num_columns
(
const
const_image_view
<
T
>&
img
)
{
return
img
.
nc
();
}
template
<
typename
T
>
inline
const
void
*
image_data
(
const
const_image_view
<
T
>&
img
)
{
if
(
img
.
size
()
!=
0
)
return
&
img
[
0
][
0
];
else
return
0
;
}
template
<
typename
T
>
inline
long
width_step
(
const
const_image_view
<
T
>&
img
)
{
return
img
.
get_width_step
();
}
// ----------------------------------------------------------------------------------------
}
...
...
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