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
5c673477
Commit
5c673477
authored
Feb 20, 2016
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #547 from cbalint13:hdf
parents
280af826
133f9c83
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
25 deletions
+66
-25
CMakeLists.txt
modules/hdf/CMakeLists.txt
+21
-3
hdf5.cpp
modules/hdf/src/hdf5.cpp
+45
-22
No files found.
modules/hdf/CMakeLists.txt
View file @
5c673477
set
(
CMAKE_MODULE_PATH
${
CMAKE_MODULE_PATH
}
${
CMAKE_CURRENT_SOURCE_DIR
}
)
find_package
(
HDF5
)
if
(
WIN32
)
# windows cmake internal lookups are broken for now
# will lookup for headers and shared libs given HDF_DIR env
find_path
(
HDF5_INCLUDE_DIRS hdf5.h HINTS
"$ENV{HDF5_DIR}
\\
..
\\
include"
)
find_library
(
HDF5_C_LIBRARY NAMES hdf5 HINTS
"$ENV{HDF5_DIR}
\\
..
\\
lib"
)
if
(
HDF5_INCLUDE_DIRS AND HDF5_C_LIBRARY
)
set
(
HDF5_FOUND
"YES"
)
set
(
HDF5_LIBRARIES
${
HDF5_C_LIBRARY
}
)
mark_as_advanced
(
HDF5_LIBRARIES
)
mark_as_advanced
(
HDF5_C_LIBRARY
)
mark_as_advanced
(
HDF5_INCLUDE_DIRS
)
add_definitions
(
-DH5_BUILT_AS_DYNAMIC_LIB -D_HDF5USEDLL_
)
else
()
set
(
HDF5_FOUND
"NO"
)
endif
()
else
()
find_package
(
HDF5
)
endif
()
if
(
HDF5_FOUND
)
set
(
HAVE_HDF5 1
)
message
(
STATUS
"HDF5: YES"
)
...
...
@@ -9,13 +27,13 @@ else()
message
(
STATUS
"HDF5: NO"
)
endif
()
if
(
${
HDF5_FOUND
}
)
if
(
HDF5_FOUND
)
include_directories
(
${
HDF5_INCLUDE_DIRS
}
)
endif
()
set
(
the_description
"Hierarchical Data Format I/O"
)
ocv_define_module
(
hdf opencv_core WRAP python
)
if
(
${
HDF5_FOUND
}
)
if
(
HDF5_FOUND
)
target_link_libraries
(
opencv_hdf
${
HDF5_LIBRARIES
}
)
endif
()
modules/hdf/src/hdf5.cpp
View file @
5c673477
...
...
@@ -329,7 +329,7 @@ vector<int> HDF5Impl::dsgetsize( String dslabel, int dims_flag ) const
int
n_dims
=
H5Sget_simple_extent_ndims
(
fspace
);
// dims storage
hsize_t
dims
[
n_dims
];
hsize_t
*
dims
=
new
hsize_t
[
n_dims
];
// output storage
vector
<
int
>
SizeVect
(
0
);
...
...
@@ -367,6 +367,8 @@ vector<int> HDF5Impl::dsgetsize( String dslabel, int dims_flag ) const
H5Dclose
(
dsdata
);
H5Sclose
(
fspace
);
delete
dims
;
return
SizeVect
;
}
...
...
@@ -386,7 +388,7 @@ int HDF5Impl::dsgettype( String dslabel ) const
// fetch channs
hsize_t
ardims
[
1
];
H5Tget_array_dims
(
dstype
,
ardims
);
channs
=
ardims
[
0
];
channs
=
(
int
)
ardims
[
0
];
// fetch depth
hid_t
tsuper
=
H5Tget_super
(
dstype
);
h5type
=
H5Tget_native_type
(
tsuper
,
H5T_DIR_ASCEND
);
...
...
@@ -481,9 +483,9 @@ void HDF5Impl::dscreate( const int n_dims, const int* sizes, const int type,
int
channs
=
CV_MAT_CN
(
type
);
hsize_t
chunks
[
n_dims
];
hsize_t
dsdims
[
n_dims
];
hsize_t
maxdim
[
n_dims
];
hsize_t
*
chunks
=
new
hsize_t
[
n_dims
];
hsize_t
*
dsdims
=
new
hsize_t
[
n_dims
];
hsize_t
*
maxdim
=
new
hsize_t
[
n_dims
];
// dimension space
for
(
int
d
=
0
;
d
<
n_dims
;
d
++
)
...
...
@@ -529,7 +531,7 @@ void HDF5Impl::dscreate( const int n_dims, const int* sizes, const int type,
// expand channs
if
(
channs
>
1
)
{
hsize_t
adims
[
1
]
=
{
channs
};
hsize_t
adims
[
1
]
=
{
(
hsize_t
)
channs
};
dstype
=
H5Tarray_create
(
dstype
,
1
,
adims
);
}
...
...
@@ -540,6 +542,10 @@ void HDF5Impl::dscreate( const int n_dims, const int* sizes, const int type,
if
(
channs
>
1
)
H5Tclose
(
dstype
);
delete
chunks
;
delete
dsdims
;
delete
maxdim
;
H5Pclose
(
dsdcpl
);
H5Sclose
(
dspace
);
}
...
...
@@ -554,7 +560,7 @@ void HDF5Impl::dsread( OutputArray Array, String dslabel ) const
void
HDF5Impl
::
dsread
(
OutputArray
Array
,
String
dslabel
,
const
int
*
dims_offset
)
const
{
dsread
(
Array
,
dslabel
,
dims_offset
);
dsread
(
Array
,
dslabel
,
dims_offset
,
NULL
);
}
// overload
...
...
@@ -585,7 +591,7 @@ void HDF5Impl::dsread( OutputArray Array, String dslabel,
// fetch channs
hsize_t
ardims
[
1
];
H5Tget_array_dims
(
dstype
,
ardims
);
channs
=
ardims
[
0
];
channs
=
(
int
)
ardims
[
0
];
// fetch depth
hid_t
tsuper
=
H5Tget_super
(
dstype
);
h5type
=
H5Tget_native_type
(
tsuper
,
H5T_DIR_ASCEND
);
...
...
@@ -602,7 +608,7 @@ void HDF5Impl::dsread( OutputArray Array, String dslabel,
int
n_dims
=
H5Sget_simple_extent_ndims
(
fspace
);
// fetch dims
hsize_t
dsdims
[
n_dims
];
hsize_t
*
dsdims
=
new
hsize_t
[
n_dims
];
H5Sget_simple_extent_dims
(
fspace
,
dsdims
,
NULL
);
// set amount by custom offset
...
...
@@ -620,8 +626,8 @@ void HDF5Impl::dsread( OutputArray Array, String dslabel,
}
// get memory write window
int
mxdims
[
n_dims
];
hsize_t
foffse
t
[
n_dims
];
int
*
mxdims
=
new
int
[
n_dims
];
hsize_t
*
foffset
=
new
hsize_
t
[
n_dims
];
for
(
int
d
=
0
;
d
<
n_dims
;
d
++
)
{
foffset
[
d
]
=
0
;
...
...
@@ -653,6 +659,10 @@ void HDF5Impl::dsread( OutputArray Array, String dslabel,
Mat
matrix
=
Array
.
getMat
();
H5Dread
(
dsdata
,
dstype
,
dspace
,
fspace
,
H5P_DEFAULT
,
matrix
.
data
);
delete
dsdims
;
delete
mxdims
;
delete
foffset
;
H5Tclose
(
dstype
);
H5Sclose
(
dspace
);
H5Sclose
(
fspace
);
...
...
@@ -692,9 +702,9 @@ void HDF5Impl::dswrite( InputArray Array, String dslabel,
int
n_dims
=
matrix
.
dims
;
int
channs
=
matrix
.
channels
();
int
dsizes
[
n_dims
];
hsize_t
dsdims
[
n_dims
];
hsize_t
offse
t
[
n_dims
];
int
*
dsizes
=
new
int
[
n_dims
];
hsize_t
*
dsdims
=
new
hsize_t
[
n_dims
];
hsize_t
*
offset
=
new
hsize_
t
[
n_dims
];
// replicate Mat dimensions
for
(
int
d
=
0
;
d
<
n_dims
;
d
++
)
{
...
...
@@ -738,7 +748,7 @@ void HDF5Impl::dswrite( InputArray Array, String dslabel,
// expand channs
if
(
matrix
.
channels
()
>
1
)
{
hsize_t
adims
[
1
]
=
{
channs
};
hsize_t
adims
[
1
]
=
{
(
hsize_t
)
channs
};
dstype
=
H5Tarray_create
(
dstype
,
1
,
adims
);
}
...
...
@@ -749,6 +759,10 @@ void HDF5Impl::dswrite( InputArray Array, String dslabel,
if
(
matrix
.
channels
()
>
1
)
H5Tclose
(
dstype
);
delete
dsizes
;
delete
dsdims
;
delete
offset
;
H5Sclose
(
dspace
);
H5Sclose
(
fspace
);
H5Dclose
(
dsdata
);
...
...
@@ -793,8 +807,8 @@ void HDF5Impl::dsinsert( InputArray Array, String dslabel,
int
n_dims
=
matrix
.
dims
;
int
channs
=
matrix
.
channels
();
hsize_t
dsdims
[
n_dims
];
hsize_t
offse
t
[
n_dims
];
hsize_t
*
dsdims
=
new
hsize_t
[
n_dims
];
hsize_t
*
offset
=
new
hsize_
t
[
n_dims
];
// replicate Mat dimensions
for
(
int
d
=
0
;
d
<
n_dims
;
d
++
)
{
...
...
@@ -828,14 +842,14 @@ void HDF5Impl::dsinsert( InputArray Array, String dslabel,
// get actual file space and dims
hid_t
fspace
=
H5Dget_space
(
dsdata
);
int
f_dims
=
H5Sget_simple_extent_ndims
(
fspace
);
hsize_t
fsdims
[
f_dims
];
hsize_t
*
fsdims
=
new
hsize_t
[
f_dims
];
H5Sget_simple_extent_dims
(
fspace
,
fsdims
,
NULL
);
H5Sclose
(
fspace
);
CV_Assert
(
f_dims
==
n_dims
);
// compute new extents
hsize_t
nwdims
[
n_dims
];
hsize_t
*
nwdims
=
new
hsize_t
[
n_dims
];
for
(
int
d
=
0
;
d
<
n_dims
;
d
++
)
{
// init
...
...
@@ -869,7 +883,7 @@ void HDF5Impl::dsinsert( InputArray Array, String dslabel,
// expand channs
if
(
matrix
.
channels
()
>
1
)
{
hsize_t
adims
[
1
]
=
{
channs
};
hsize_t
adims
[
1
]
=
{
(
hsize_t
)
channs
};
dstype
=
H5Tarray_create
(
dstype
,
1
,
adims
);
}
...
...
@@ -880,6 +894,11 @@ void HDF5Impl::dsinsert( InputArray Array, String dslabel,
if
(
matrix
.
channels
()
>
1
)
H5Tclose
(
dstype
);
delete
dsdims
;
delete
offset
;
delete
fsdims
;
delete
nwdims
;
H5Sclose
(
dspace
);
H5Sclose
(
fspace
);
H5Dclose
(
dsdata
);
...
...
@@ -976,16 +995,18 @@ void HDF5Impl::kpwrite( const vector<KeyPoint> keypoints, String kplabel,
{
CV_Assert
(
keypoints
.
size
()
>
0
);
int
dskdims
[
1
];
hsize_t
dsddims
[
1
];
hsize_t
doffset
[
1
];
// replicate vector dimension
doffset
[
0
]
=
0
;
dsddims
[
0
]
=
keypoints
.
size
();
dskdims
[
0
]
=
(
int
)
keypoints
.
size
();
// pre-create dataset if needed
if
(
hlexists
(
kplabel
)
==
false
)
kpcreate
(
ds
d
dims
[
0
],
kplabel
);
kpcreate
(
ds
k
dims
[
0
],
kplabel
);
// set custom amount of data
if
(
counts
!=
H5_NONE
)
...
...
@@ -1058,7 +1079,7 @@ void HDF5Impl::kpinsert( const vector<KeyPoint> keypoints, String kplabel,
// get actual file space and dims
hid_t
fspace
=
H5Dget_space
(
dsdata
);
int
f_dims
=
H5Sget_simple_extent_ndims
(
fspace
);
hsize_t
fsdims
[
f_dims
];
hsize_t
*
fsdims
=
new
hsize_t
[
f_dims
];
H5Sget_simple_extent_dims
(
fspace
,
fsdims
,
NULL
);
H5Sclose
(
fspace
);
...
...
@@ -1101,6 +1122,8 @@ void HDF5Impl::kpinsert( const vector<KeyPoint> keypoints, String kplabel,
// write into dataset
H5Dwrite
(
dsdata
,
mmtype
,
dspace
,
fspace
,
H5P_DEFAULT
,
&
keypoints
[
0
]
);
delete
fsdims
;
H5Tclose
(
mmtype
);
H5Sclose
(
dspace
);
H5Sclose
(
fspace
);
...
...
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