@@ -329,7 +329,7 @@ vector<int> HDF5Impl::dsgetsize( String dslabel, int dims_flag ) const
329
329
int n_dims = H5Sget_simple_extent_ndims ( fspace );
330
330
331
331
// dims storage
332
- hsize_t dims[n_dims];
332
+ hsize_t * dims = new hsize_t [n_dims];
333
333
334
334
// output storage
335
335
vector<int > SizeVect (0 );
@@ -367,6 +367,8 @@ vector<int> HDF5Impl::dsgetsize( String dslabel, int dims_flag ) const
367
367
H5Dclose ( dsdata );
368
368
H5Sclose ( fspace );
369
369
370
+ delete dims;
371
+
370
372
return SizeVect;
371
373
}
372
374
@@ -386,7 +388,7 @@ int HDF5Impl::dsgettype( String dslabel ) const
386
388
// fetch channs
387
389
hsize_t ardims[1 ];
388
390
H5Tget_array_dims ( dstype, ardims );
389
- channs = ardims[0 ];
391
+ channs = ( int ) ardims[0 ];
390
392
// fetch depth
391
393
hid_t tsuper = H5Tget_super ( dstype );
392
394
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,
481
483
482
484
int channs = CV_MAT_CN ( type );
483
485
484
- hsize_t chunks[n_dims];
485
- hsize_t dsdims[n_dims];
486
- hsize_t maxdim[n_dims];
486
+ hsize_t * chunks = new hsize_t [n_dims];
487
+ hsize_t * dsdims = new hsize_t [n_dims];
488
+ hsize_t * maxdim = new hsize_t [n_dims];
487
489
488
490
// dimension space
489
491
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,
529
531
// expand channs
530
532
if ( channs > 1 )
531
533
{
532
- hsize_t adims[1 ] = { channs };
534
+ hsize_t adims[1 ] = { ( hsize_t ) channs };
533
535
dstype = H5Tarray_create ( dstype, 1 , adims );
534
536
}
535
537
@@ -540,6 +542,10 @@ void HDF5Impl::dscreate( const int n_dims, const int* sizes, const int type,
540
542
if ( channs > 1 )
541
543
H5Tclose ( dstype );
542
544
545
+ delete chunks;
546
+ delete dsdims;
547
+ delete maxdim;
548
+
543
549
H5Pclose ( dsdcpl );
544
550
H5Sclose ( dspace );
545
551
}
@@ -554,7 +560,7 @@ void HDF5Impl::dsread( OutputArray Array, String dslabel ) const
554
560
void HDF5Impl::dsread ( OutputArray Array, String dslabel,
555
561
const int * dims_offset ) const
556
562
{
557
- dsread ( Array, dslabel, dims_offset );
563
+ dsread ( Array, dslabel, dims_offset, NULL );
558
564
}
559
565
560
566
// overload
@@ -585,7 +591,7 @@ void HDF5Impl::dsread( OutputArray Array, String dslabel,
585
591
// fetch channs
586
592
hsize_t ardims[1 ];
587
593
H5Tget_array_dims ( dstype, ardims );
588
- channs = ardims[0 ];
594
+ channs = ( int ) ardims[0 ];
589
595
// fetch depth
590
596
hid_t tsuper = H5Tget_super ( dstype );
591
597
h5type = H5Tget_native_type ( tsuper, H5T_DIR_ASCEND );
@@ -602,7 +608,7 @@ void HDF5Impl::dsread( OutputArray Array, String dslabel,
602
608
int n_dims = H5Sget_simple_extent_ndims ( fspace );
603
609
604
610
// fetch dims
605
- hsize_t dsdims[n_dims];
611
+ hsize_t * dsdims = new hsize_t [n_dims];
606
612
H5Sget_simple_extent_dims ( fspace, dsdims, NULL );
607
613
608
614
// set amount by custom offset
@@ -620,8 +626,8 @@ void HDF5Impl::dsread( OutputArray Array, String dslabel,
620
626
}
621
627
622
628
// get memory write window
623
- int mxdims[n_dims];
624
- hsize_t foffset[n_dims];
629
+ int * mxdims = new int [n_dims];
630
+ hsize_t * foffset = new hsize_t [n_dims];
625
631
for ( int d = 0 ; d < n_dims; d++ )
626
632
{
627
633
foffset[d] = 0 ;
@@ -653,6 +659,10 @@ void HDF5Impl::dsread( OutputArray Array, String dslabel,
653
659
Mat matrix = Array.getMat ();
654
660
H5Dread ( dsdata, dstype, dspace, fspace, H5P_DEFAULT, matrix.data );
655
661
662
+ delete dsdims;
663
+ delete mxdims;
664
+ delete foffset;
665
+
656
666
H5Tclose ( dstype );
657
667
H5Sclose ( dspace );
658
668
H5Sclose ( fspace );
@@ -692,9 +702,9 @@ void HDF5Impl::dswrite( InputArray Array, String dslabel,
692
702
int n_dims = matrix.dims ;
693
703
int channs = matrix.channels ();
694
704
695
- int dsizes[n_dims];
696
- hsize_t dsdims[n_dims];
697
- hsize_t offset[n_dims];
705
+ int * dsizes = new int [n_dims];
706
+ hsize_t * dsdims = new hsize_t [n_dims];
707
+ hsize_t * offset = new hsize_t [n_dims];
698
708
// replicate Mat dimensions
699
709
for ( int d = 0 ; d < n_dims; d++ )
700
710
{
@@ -738,7 +748,7 @@ void HDF5Impl::dswrite( InputArray Array, String dslabel,
738
748
// expand channs
739
749
if ( matrix.channels () > 1 )
740
750
{
741
- hsize_t adims[1 ] = { channs };
751
+ hsize_t adims[1 ] = { ( hsize_t ) channs };
742
752
dstype = H5Tarray_create ( dstype, 1 , adims );
743
753
}
744
754
@@ -749,6 +759,10 @@ void HDF5Impl::dswrite( InputArray Array, String dslabel,
749
759
if ( matrix.channels () > 1 )
750
760
H5Tclose ( dstype );
751
761
762
+ delete dsizes;
763
+ delete dsdims;
764
+ delete offset;
765
+
752
766
H5Sclose ( dspace );
753
767
H5Sclose ( fspace );
754
768
H5Dclose ( dsdata );
@@ -793,8 +807,8 @@ void HDF5Impl::dsinsert( InputArray Array, String dslabel,
793
807
int n_dims = matrix.dims ;
794
808
int channs = matrix.channels ();
795
809
796
- hsize_t dsdims[n_dims];
797
- hsize_t offset[n_dims];
810
+ hsize_t * dsdims = new hsize_t [n_dims];
811
+ hsize_t * offset = new hsize_t [n_dims];
798
812
// replicate Mat dimensions
799
813
for ( int d = 0 ; d < n_dims; d++ )
800
814
{
@@ -828,14 +842,14 @@ void HDF5Impl::dsinsert( InputArray Array, String dslabel,
828
842
// get actual file space and dims
829
843
hid_t fspace = H5Dget_space ( dsdata );
830
844
int f_dims = H5Sget_simple_extent_ndims ( fspace );
831
- hsize_t fsdims[f_dims];
845
+ hsize_t * fsdims = new hsize_t [f_dims];
832
846
H5Sget_simple_extent_dims ( fspace, fsdims, NULL );
833
847
H5Sclose ( fspace );
834
848
835
849
CV_Assert ( f_dims == n_dims );
836
850
837
851
// compute new extents
838
- hsize_t nwdims[n_dims];
852
+ hsize_t * nwdims = new hsize_t [n_dims];
839
853
for ( int d = 0 ; d < n_dims; d++ )
840
854
{
841
855
// init
@@ -869,7 +883,7 @@ void HDF5Impl::dsinsert( InputArray Array, String dslabel,
869
883
// expand channs
870
884
if ( matrix.channels () > 1 )
871
885
{
872
- hsize_t adims[1 ] = { channs };
886
+ hsize_t adims[1 ] = { ( hsize_t ) channs };
873
887
dstype = H5Tarray_create ( dstype, 1 , adims );
874
888
}
875
889
@@ -880,6 +894,11 @@ void HDF5Impl::dsinsert( InputArray Array, String dslabel,
880
894
if ( matrix.channels () > 1 )
881
895
H5Tclose ( dstype );
882
896
897
+ delete dsdims;
898
+ delete offset;
899
+ delete fsdims;
900
+ delete nwdims;
901
+
883
902
H5Sclose ( dspace );
884
903
H5Sclose ( fspace );
885
904
H5Dclose ( dsdata );
@@ -976,16 +995,18 @@ void HDF5Impl::kpwrite( const vector<KeyPoint> keypoints, String kplabel,
976
995
{
977
996
CV_Assert ( keypoints.size () > 0 );
978
997
998
+ int dskdims[1 ];
979
999
hsize_t dsddims[1 ];
980
1000
hsize_t doffset[1 ];
981
1001
982
1002
// replicate vector dimension
983
1003
doffset[0 ] = 0 ;
984
1004
dsddims[0 ] = keypoints.size ();
1005
+ dskdims[0 ] = (int )keypoints.size ();
985
1006
986
1007
// pre-create dataset if needed
987
1008
if ( hlexists ( kplabel ) == false )
988
- kpcreate ( dsddims [0 ], kplabel );
1009
+ kpcreate ( dskdims [0 ], kplabel );
989
1010
990
1011
// set custom amount of data
991
1012
if ( counts != H5_NONE )
@@ -1058,7 +1079,7 @@ void HDF5Impl::kpinsert( const vector<KeyPoint> keypoints, String kplabel,
1058
1079
// get actual file space and dims
1059
1080
hid_t fspace = H5Dget_space ( dsdata );
1060
1081
int f_dims = H5Sget_simple_extent_ndims ( fspace );
1061
- hsize_t fsdims[f_dims];
1082
+ hsize_t * fsdims = new hsize_t [f_dims];
1062
1083
H5Sget_simple_extent_dims ( fspace, fsdims, NULL );
1063
1084
H5Sclose ( fspace );
1064
1085
@@ -1101,6 +1122,8 @@ void HDF5Impl::kpinsert( const vector<KeyPoint> keypoints, String kplabel,
1101
1122
// write into dataset
1102
1123
H5Dwrite ( dsdata, mmtype, dspace, fspace, H5P_DEFAULT, &keypoints[0 ] );
1103
1124
1125
+ delete fsdims;
1126
+
1104
1127
H5Tclose ( mmtype );
1105
1128
H5Sclose ( dspace );
1106
1129
H5Sclose ( fspace );
0 commit comments