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
57337b5a
Commit
57337b5a
authored
Jan 14, 2016
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #502 from cbalint13:hdf
parents
a153fd88
a01002f6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
15 deletions
+42
-15
hdf5.hpp
modules/hdf/include/opencv2/hdf/hdf5.hpp
+6
-3
hdf5.cpp
modules/hdf/src/hdf5.cpp
+36
-12
No files found.
modules/hdf/include/opencv2/hdf/hdf5.hpp
View file @
57337b5a
...
...
@@ -63,7 +63,7 @@ public:
CV_WRAP
enum
{
H5_UNLIMITED
=
-
1
,
H5_NONE
=
-
1
,
H5_GETDIMS
=
100
,
H5_GETMAXDIMS
=
101
,
H5_UNLIMITED
=
-
1
,
H5_NONE
=
-
1
,
H5_GETDIMS
=
100
,
H5_GETMAXDIMS
=
101
,
H5_GETCHUNKDIMS
=
102
,
};
virtual
~
HDF5
()
{}
...
...
@@ -278,7 +278,9 @@ public:
actual dataset dimensions. Using H5_GETMAXDIM flag will get maximum allowed dimension which normally match
actual dataset dimension but can hold H5_UNLIMITED value if dataset was prepared in **unlimited** mode on
some of its dimension. It can be useful to check existing dataset dimensions before overwrite it as whole or subset.
Trying to write with oversized source data into dataset target will thrown exception.
Trying to write with oversized source data into dataset target will thrown exception. The H5_GETCHUNKDIMS will
return the dimension of chunk if dataset was created with chunking options otherwise returned vector size
will be zero.
*/
CV_WRAP
virtual
vector
<
int
>
dsgetsize
(
String
dslabel
,
int
dims_flag
=
HDF5
::
H5_GETDIMS
)
const
=
0
;
...
...
@@ -488,7 +490,8 @@ public:
Using H5_GETMAXDIM flag will get maximum allowed dimension which normally match actual dataset dimension but can hold
H5_UNLIMITED value if dataset was prepared in **unlimited** mode. It can be useful to check existing dataset dimension
before overwrite it as whole or subset. Trying to write with oversized source data into dataset target will thrown
exception.
exception. The H5_GETCHUNKDIMS will return the dimension of chunk if dataset was created with chunking options otherwise
returned vector size will be zero.
*/
CV_WRAP
virtual
int
kpgetsize
(
String
kplabel
,
int
dims_flag
=
HDF5
::
H5_GETDIMS
)
const
=
0
;
...
...
modules/hdf/src/hdf5.cpp
View file @
57337b5a
...
...
@@ -266,14 +266,16 @@ HDF5Impl::HDF5Impl( String _hdf5_filename )
// restore previous error handler
H5Eset_auto
(
stackid
,
errfunc
,
errdata
);
if
(
check
==
1
)
if
(
check
==
1
||
check
==
0
)
// open the HDF5 file
m_h5_file_id
=
H5Fopen
(
m_hdf5_filename
.
c_str
(),
H5F_ACC_RDWR
,
H5P_DEFAULT
);
else
//
create the HDF5 file
else
if
(
check
==
-
1
)
//
file does not exist
m_h5_file_id
=
H5Fcreate
(
m_hdf5_filename
.
c_str
(),
H5F_ACC_TRUNC
,
H5P_DEFAULT
,
H5P_DEFAULT
);
else
CV_Error
(
Error
::
StsInternal
,
"Unknown file state."
);
}
void
HDF5Impl
::
close
()
...
...
@@ -282,8 +284,6 @@ void HDF5Impl::close()
H5Fclose
(
m_h5_file_id
);
// mark closed
m_h5_file_id
=
-
1
;
H5close
(
);
}
/*
...
...
@@ -328,17 +328,41 @@ vector<int> HDF5Impl::dsgetsize( String dslabel, int dims_flag ) const
// fetch rank
int
n_dims
=
H5Sget_simple_extent_ndims
(
fspace
);
// dims storage
hsize_t
dims
[
n_dims
];
// output storage
vector
<
int
>
SizeVect
(
0
);
// fetch dims
hsize_t
dsdims
[
n_dims
];
if
(
dims_flag
==
H5_GETDIMS
)
H5Sget_simple_extent_dims
(
fspace
,
dsdims
,
NULL
);
if
(
dims_flag
==
H5_GETDIMS
||
dims_flag
==
H5_GETMAXDIMS
)
{
if
(
dims_flag
==
H5_GETDIMS
)
H5Sget_simple_extent_dims
(
fspace
,
dims
,
NULL
);
else
H5Sget_simple_extent_dims
(
fspace
,
NULL
,
dims
);
SizeVect
.
resize
(
n_dims
);
}
else
if
(
dims_flag
==
H5_GETCHUNKDIMS
)
{
// rank size
int
rank_chunk
=
-
1
;
// fetch chunk size
hid_t
cparms
=
H5Dget_create_plist
(
dsdata
);
if
(
H5D_CHUNKED
==
H5Pget_layout
(
cparms
)
)
{
rank_chunk
=
H5Pget_chunk
(
cparms
,
n_dims
,
dims
);
}
if
(
rank_chunk
>
0
)
SizeVect
.
resize
(
n_dims
);
}
else
H5Sget_simple_extent_dims
(
fspace
,
NULL
,
dsdims
);
CV_Error
(
Error
::
StsInternal
,
"Unknown dimension flag."
);
// fill with size data
vector
<
int
>
SizeVect
(
n_dims
);
for
(
int
d
=
0
;
d
<
n_dims
;
d
++
)
SizeVect
[
d
]
=
(
int
)
dsdims
[
d
];
for
(
size_t
d
=
0
;
d
<
SizeVect
.
size
();
d
++
)
SizeVect
[
d
]
=
(
int
)
dims
[
d
];
H5Dclose
(
dsdata
);
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