Skip to content

Commit 6b1483e

Browse files
committed
Merge pull request #480 from cbalint13:hdf
2 parents 5409d5a + 99b299a commit 6b1483e

File tree

2 files changed

+170
-41
lines changed

2 files changed

+170
-41
lines changed

modules/hdf/include/opencv2/hdf/hdf5.hpp

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,19 @@ class CV_EXPORTS_W HDF5
115115

116116
/* @overload */
117117
CV_WRAP virtual void dscreate( const int rows, const int cols, const int type,
118-
String dslabel, const int compresslevel = HDF5::H5_NONE,
119-
const vector<int>& dims_chunks = vector<int>() ) const = 0;
118+
String dslabel ) const = 0;
119+
/* @overload */
120+
CV_WRAP virtual void dscreate( const int rows, const int cols, const int type,
121+
String dslabel, const int compresslevel ) const = 0;
122+
/* @overload */
123+
CV_WRAP virtual void dscreate( const int rows, const int cols, const int type,
124+
String dslabel, const int compresslevel, const vector<int>& dims_chunks ) const = 0;
120125
/** @brief Create and allocate storage for two dimensional single or multi channel dataset.
121126
@param rows declare amount of rows
122127
@param cols declare amount of cols
123128
@param type type to be used
124129
@param dslabel specify the hdf5 dataset label, any existing dataset with the same label will be overwritten.
125-
@param compresslevel specify the compression level 0-9 to be used, by default H5_NONE means none at all.
130+
@param compresslevel specify the compression level 0-9 to be used, H5_NONE is default and means no compression.
126131
@param dims_chunks each array member specify chunking sizes to be used for block i/o,
127132
by default NULL means none at all.
128133
@@ -181,17 +186,24 @@ class CV_EXPORTS_W HDF5
181186
Multiple datasets inside single hdf5 file is allowed.
182187
*/
183188
CV_WRAP virtual void dscreate( const int rows, const int cols, const int type,
184-
String dslabel, const int compresslevel = HDF5::H5_NONE, const int* dims_chunks = NULL ) const = 0;
189+
String dslabel, const int compresslevel, const int* dims_chunks ) const = 0;
185190

186191
/* @overload */
187-
CV_WRAP virtual void dscreate( const vector<int>& sizes, const int type, String dslabel,
188-
const int compresslevel = HDF5::H5_NONE, const vector<int>& dims_chunks = vector<int>() ) const = 0;
192+
CV_WRAP virtual void dscreate( const int n_dims, const int* sizes, const int type,
193+
String dslabel ) const = 0;
194+
/* @overload */
195+
CV_WRAP virtual void dscreate( const int n_dims, const int* sizes, const int type,
196+
String dslabel, const int compresslevel ) const = 0;
197+
/* @overload */
198+
CV_WRAP virtual void dscreate( const vector<int>& sizes, const int type,
199+
String dslabel, const int compresslevel = HDF5::H5_NONE,
200+
const vector<int>& dims_chunks = vector<int>() ) const = 0;
189201
/** @brief Create and allocate storage for n-dimensional dataset, single or mutichannel type.
190202
@param n_dims declare number of dimensions
191203
@param sizes array containing sizes for each dimensions
192204
@param type type to be used
193205
@param dslabel specify the hdf5 dataset label, any existing dataset with the same label will be overwritten.
194-
@param compresslevel specify the compression level 0-9 to be used, by default H5_NONE means none at all.
206+
@param compresslevel specify the compression level 0-9 to be used, H5_NONE is default and means no compression.
195207
@param dims_chunks each array member specify chunking sizes to be used for block i/o,
196208
by default NULL means none at all.
197209
@note If the dataset already exists an exception will be thrown. Existence of the dataset can be checked
@@ -254,7 +266,7 @@ class CV_EXPORTS_W HDF5
254266
@endcode
255267
*/
256268
CV_WRAP virtual void dscreate( const int n_dims, const int* sizes, const int type,
257-
String dslabel, const int compresslevel = HDF5::H5_NONE, const int* dims_chunks = NULL ) const = 0;
269+
String dslabel, const int compresslevel, const int* dims_chunks ) const = 0;
258270

259271
/** @brief Fetch dataset sizes
260272
@param dslabel specify the hdf5 dataset label to be measured.
@@ -281,9 +293,14 @@ class CV_EXPORTS_W HDF5
281293
*/
282294
CV_WRAP virtual int dsgettype( String dslabel ) const = 0;
283295

296+
/* @overload */
297+
CV_WRAP virtual void dswrite( InputArray Array, String dslabel ) const = 0;
298+
/* @overload */
299+
CV_WRAP virtual void dswrite( InputArray Array, String dslabel,
300+
const int* dims_offset ) const = 0;
284301
/* @overload */
285302
CV_WRAP virtual void dswrite( InputArray Array, String dslabel,
286-
const vector<int>& dims_offset = vector<int>(),
303+
const vector<int>& dims_offset,
287304
const vector<int>& dims_counts = vector<int>() ) const = 0;
288305
/** @brief Write or overwrite a Mat object into specified dataset of hdf5 file.
289306
@param Array specify Mat data array to be written.
@@ -348,11 +365,16 @@ class CV_EXPORTS_W HDF5
348365
@endcode
349366
*/
350367
CV_WRAP virtual void dswrite( InputArray Array, String dslabel,
351-
const int* dims_offset = NULL, const int* dims_counts = NULL ) const = 0;
368+
const int* dims_offset, const int* dims_counts ) const = 0;
352369

353370
/* @overload */
354-
CV_WRAP virtual void dsinsert( InputArray Array, String dslabel,
355-
const vector<int>& dims_offset = vector<int>(),
371+
CV_WRAP virtual void dsinsert( InputArray Array, String dslabel ) const = 0;
372+
/* @overload */
373+
CV_WRAP virtual void dsinsert( InputArray Array,
374+
String dslabel, const int* dims_offset ) const = 0;
375+
/* @overload */
376+
CV_WRAP virtual void dsinsert( InputArray Array,
377+
String dslabel, const vector<int>& dims_offset,
356378
const vector<int>& dims_counts = vector<int>() ) const = 0;
357379
/** @brief Insert or overwrite a Mat object into specified dataset and autoexpand dataset size if **unlimited** property allows.
358380
@param Array specify Mat data array to be written.
@@ -402,12 +424,17 @@ class CV_EXPORTS_W HDF5
402424
@endcode
403425
*/
404426
CV_WRAP virtual void dsinsert( InputArray Array, String dslabel,
405-
const int* dims_offset = NULL, const int* dims_counts = NULL ) const = 0;
427+
const int* dims_offset, const int* dims_counts ) const = 0;
406428

407429

430+
/* @overload */
431+
CV_WRAP virtual void dsread( OutputArray Array, String dslabel ) const = 0;
432+
/* @overload */
433+
CV_WRAP virtual void dsread( OutputArray Array,
434+
String dslabel, const int* dims_offset ) const = 0;
408435
/* @overload */
409436
CV_WRAP virtual void dsread( OutputArray Array, String dslabel,
410-
const vector<int>& dims_offset = vector<int>(),
437+
const vector<int>& dims_offset,
411438
const vector<int>& dims_counts = vector<int>() ) const = 0;
412439
/** @brief Read specific dataset from hdf5 file into Mat object.
413440
@param Array Mat container where data reads will be returned.
@@ -449,7 +476,7 @@ class CV_EXPORTS_W HDF5
449476
@endcode
450477
*/
451478
CV_WRAP virtual void dsread( OutputArray Array, String dslabel,
452-
const int* dims_offset = NULL, const int* dims_counts = NULL ) const = 0;
479+
const int* dims_offset, const int* dims_counts ) const = 0;
453480

454481
/** @brief Fetch keypoint dataset size
455482
@param kplabel specify the hdf5 dataset label to be measured.
@@ -468,9 +495,9 @@ class CV_EXPORTS_W HDF5
468495
/** @brief Create and allocate special storage for cv::KeyPoint dataset.
469496
@param size declare fixed number of KeyPoints
470497
@param kplabel specify the hdf5 dataset label, any existing dataset with the same label will be overwritten.
471-
@param compresslevel specify the compression level 0-9 to be used, by default H5_NONE means none at all.
498+
@param compresslevel specify the compression level 0-9 to be used, H5_NONE is default and means no compression.
472499
@param chunks each array member specify chunking sizes to be used for block i/o,
473-
by default H5_NONE means none at all.
500+
H5_NONE is default and means no compression.
474501
@note If the dataset already exists an exception will be thrown. Existence of the dataset can be checked
475502
using hlexists().
476503

modules/hdf/src/hdf5.cpp

Lines changed: 126 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -75,52 +75,81 @@ class HDF5Impl : public HDF5
7575
// get sizes of dataset
7676
virtual vector<int> dsgetsize( String dslabel, int dims_flag = H5_GETDIMS ) const;
7777

78-
// get data type of dataset
78+
/* get data type of dataset */
7979
virtual int dsgettype( String dslabel ) const;
8080

81-
// overload dscreate()
82-
virtual void dscreate( const int rows, const int cols, const int type,
83-
String dslabel, const int compresslevel = H5_NONE,
84-
const vector<int>& dims_chunks = vector<int>() ) const;
81+
// overload dscreate() #1
82+
virtual void dscreate( const int rows, const int cols, const int type, String dslabel ) const;
8583

86-
// create two dimensional single or mutichannel dataset
87-
virtual void dscreate( const int rows, const int cols, const int type,
88-
String dslabel, const int compresslevel = H5_NONE, const int* dims_chunks = NULL ) const;
84+
// overload dscreate() #2
85+
virtual void dscreate( const int rows, const int cols, const int type, String dslabel,
86+
const int compresslevel ) const;
8987

90-
// overload dscreate()
88+
// overload dscreate() #3
89+
virtual void dscreate( const int rows, const int cols, const int type, String dslabel,
90+
const int compresslevel, const vector<int>& dims_chunks ) const;
91+
92+
/* create two dimensional single or mutichannel dataset */
93+
virtual void dscreate( const int rows, const int cols, const int type, String dslabel,
94+
const int compresslevel, const int* dims_chunks ) const;
95+
96+
// overload dscreate() #1
97+
virtual void dscreate( const int n_dims, const int* sizes, const int type,
98+
String dslabel ) const;
99+
100+
// overload dscreate() #2
101+
virtual void dscreate( const int n_dims, const int* sizes, const int type,
102+
String dslabel, const int compresslevel ) const;
103+
104+
// overload dscreate() #3
91105
virtual void dscreate( const vector<int>& sizes, const int type, String dslabel,
92106
const int compresslevel = H5_NONE, const vector<int>& dims_chunks = vector<int>() ) const;
93107

94-
// create n-dimensional single or mutichannel dataset
108+
/* create n-dimensional single or mutichannel dataset */
95109
virtual void dscreate( const int n_dims, const int* sizes, const int type,
96-
String dslabel, const int compresslevel = H5_NONE, const int* dims_chunks = NULL ) const;
110+
String dslabel, const int compresslevel, const int* dims_chunks ) const;
97111

98-
// overload dswrite()
99-
virtual void dswrite( InputArray Array, String dslabel,
100-
const vector<int>& dims_offset = vector<int>(),
112+
// overload dswrite() #1
113+
virtual void dswrite( InputArray Array, String dslabel ) const;
114+
115+
// overload dswrite() #2
116+
virtual void dswrite( InputArray Array, String dslabel, const int* dims_offset ) const;
117+
118+
// overload dswrite() #3
119+
virtual void dswrite( InputArray Array, String dslabel, const vector<int>& dims_offset,
101120
const vector<int>& dims_counts = vector<int>() ) const;
102121

103-
// write into dataset
122+
/* write into dataset */
104123
virtual void dswrite( InputArray Array, String dslabel,
105-
const int* dims_offset = NULL, const int* dims_counts = NULL ) const;
124+
const int* dims_offset, const int* dims_counts ) const;
125+
126+
// overload dsinsert() #1
127+
virtual void dsinsert( InputArray Array, String dslabel ) const;
106128

107-
// overload dsinsert()
129+
// overload dsinsert() #2
130+
virtual void dsinsert( InputArray Array, String dslabel, const int* dims_offset ) const;
131+
132+
// overload dsinsert() #3
108133
virtual void dsinsert( InputArray Array, String dslabel,
109-
const vector<int>& dims_offset = vector<int>(),
110-
const vector<int>& dims_counts = vector<int>() ) const;
134+
const vector<int>& dims_offset, const vector<int>& dims_counts = vector<int>() ) const;
111135

112-
// append / merge into dataset
136+
/* append / merge into dataset */
113137
virtual void dsinsert( InputArray Array, String dslabel,
114138
const int* dims_offset = NULL, const int* dims_counts = NULL ) const;
115139

116-
// overload dsread()
140+
// overload dsread() #1
141+
virtual void dsread( OutputArray Array, String dslabel ) const;
142+
143+
// overload dsread() #2
144+
virtual void dsread( OutputArray Array, String dslabel, const int* dims_offset ) const;
145+
146+
// overload dsread() #3
117147
virtual void dsread( OutputArray Array, String dslabel,
118-
const vector<int>& dims_offset = vector<int>(),
119-
const vector<int>& dims_counts = vector<int>() ) const;
148+
const vector<int>& dims_offset, const vector<int>& dims_counts = vector<int>() ) const;
120149

121150
// read from dataset
122151
virtual void dsread( OutputArray Array, String dslabel,
123-
const int* dims_offset = NULL, const int* dims_counts = NULL ) const;
152+
const int* dims_offset, const int* dims_counts ) const;
124153

125154
/*
126155
* std::vector<cv::KeyPoint>
@@ -351,6 +380,28 @@ int HDF5Impl::dsgettype( String dslabel ) const
351380
return CV_MAKETYPE( cvtype, channs );
352381
}
353382

383+
// overload
384+
void HDF5Impl::dscreate( const int rows, const int cols, const int type,
385+
String dslabel ) const
386+
{
387+
// dataset dims
388+
int dsizes[2] = { rows, cols };
389+
390+
// create the two dim array
391+
dscreate( 2, dsizes, type, dslabel, HDF5::H5_NONE, NULL );
392+
}
393+
394+
// overload
395+
void HDF5Impl::dscreate( const int rows, const int cols, const int type,
396+
String dslabel, const int compresslevel ) const
397+
{
398+
// dataset dims
399+
int dsizes[2] = { rows, cols };
400+
401+
// create the two dim array
402+
dscreate( 2, dsizes, type, dslabel, compresslevel, NULL );
403+
}
404+
354405
// overload
355406
void HDF5Impl::dscreate( const int rows, const int cols, const int type,
356407
String dslabel, const int compresslevel,
@@ -370,6 +421,20 @@ void HDF5Impl::dscreate( const int rows, const int cols, const int type,
370421
dscreate( 2, dsizes, type, dslabel, compresslevel, dims_chunks );
371422
}
372423

424+
// overload
425+
void HDF5Impl::dscreate( const int n_dims, const int* sizes, const int type,
426+
String dslabel ) const
427+
{
428+
dscreate( n_dims, sizes, type, dslabel, H5_NONE, NULL );
429+
}
430+
431+
// overload
432+
void HDF5Impl::dscreate( const int n_dims, const int* sizes, const int type,
433+
String dslabel, const int compresslevel ) const
434+
{
435+
dscreate( n_dims, sizes, type, dslabel, compresslevel, NULL );
436+
}
437+
373438
// overload
374439
void HDF5Impl::dscreate( const vector<int>& sizes, const int type,
375440
String dslabel, const int compresslevel,
@@ -455,6 +520,19 @@ void HDF5Impl::dscreate( const int n_dims, const int* sizes, const int type,
455520
H5Sclose( dspace );
456521
}
457522

523+
// overload
524+
void HDF5Impl::dsread( OutputArray Array, String dslabel ) const
525+
{
526+
dsread( Array, dslabel, NULL, NULL );
527+
}
528+
529+
// overload
530+
void HDF5Impl::dsread( OutputArray Array, String dslabel,
531+
const int* dims_offset ) const
532+
{
533+
dsread( Array, dslabel, dims_offset );
534+
}
535+
458536
// overload
459537
void HDF5Impl::dsread( OutputArray Array, String dslabel,
460538
const vector<int>& dims_offset,
@@ -557,6 +635,17 @@ void HDF5Impl::dsread( OutputArray Array, String dslabel,
557635
H5Dclose( dsdata );
558636
}
559637

638+
// overload
639+
void HDF5Impl::dswrite( InputArray Array, String dslabel ) const
640+
{
641+
dswrite( Array, dslabel, NULL, NULL );
642+
}
643+
// overload
644+
void HDF5Impl::dswrite( InputArray Array, String dslabel,
645+
const int* dims_offset ) const
646+
{
647+
dswrite( Array, dslabel, dims_offset, NULL );
648+
}
560649
// overload
561650
void HDF5Impl::dswrite( InputArray Array, String dslabel,
562651
const vector<int>& dims_offset,
@@ -641,6 +730,19 @@ void HDF5Impl::dswrite( InputArray Array, String dslabel,
641730
H5Dclose( dsdata );
642731
}
643732

733+
// overload
734+
void HDF5Impl::dsinsert( InputArray Array, String dslabel ) const
735+
{
736+
dsinsert( Array, dslabel, NULL, NULL );
737+
}
738+
739+
// overload
740+
void HDF5Impl::dsinsert( InputArray Array, String dslabel,
741+
const int* dims_offset ) const
742+
{
743+
dsinsert( Array, dslabel, dims_offset, NULL );
744+
}
745+
644746
// overload
645747
void HDF5Impl::dsinsert( InputArray Array, String dslabel,
646748
const vector<int>& dims_offset,

0 commit comments

Comments
 (0)