@@ -329,7 +329,7 @@ vector<int> HDF5Impl::dsgetsize( String dslabel, int dims_flag ) const
329329 int n_dims = H5Sget_simple_extent_ndims ( fspace );
330330
331331 // dims storage
332- hsize_t dims[n_dims];
332+ hsize_t * dims = new hsize_t [n_dims];
333333
334334 // output storage
335335 vector<int > SizeVect (0 );
@@ -367,6 +367,8 @@ vector<int> HDF5Impl::dsgetsize( String dslabel, int dims_flag ) const
367367 H5Dclose ( dsdata );
368368 H5Sclose ( fspace );
369369
370+ delete dims;
371+
370372 return SizeVect;
371373}
372374
@@ -386,7 +388,7 @@ int HDF5Impl::dsgettype( String dslabel ) const
386388 // fetch channs
387389 hsize_t ardims[1 ];
388390 H5Tget_array_dims ( dstype, ardims );
389- channs = ardims[0 ];
391+ channs = ( int ) ardims[0 ];
390392 // fetch depth
391393 hid_t tsuper = H5Tget_super ( dstype );
392394 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,
481483
482484 int channs = CV_MAT_CN ( type );
483485
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];
487489
488490 // dimension space
489491 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,
529531 // expand channs
530532 if ( channs > 1 )
531533 {
532- hsize_t adims[1 ] = { channs };
534+ hsize_t adims[1 ] = { ( hsize_t ) channs };
533535 dstype = H5Tarray_create ( dstype, 1 , adims );
534536 }
535537
@@ -540,6 +542,10 @@ void HDF5Impl::dscreate( const int n_dims, const int* sizes, const int type,
540542 if ( channs > 1 )
541543 H5Tclose ( dstype );
542544
545+ delete chunks;
546+ delete dsdims;
547+ delete maxdim;
548+
543549 H5Pclose ( dsdcpl );
544550 H5Sclose ( dspace );
545551}
@@ -554,7 +560,7 @@ void HDF5Impl::dsread( OutputArray Array, String dslabel ) const
554560void HDF5Impl::dsread ( OutputArray Array, String dslabel,
555561 const int * dims_offset ) const
556562{
557- dsread ( Array, dslabel, dims_offset );
563+ dsread ( Array, dslabel, dims_offset, NULL );
558564}
559565
560566// overload
@@ -585,7 +591,7 @@ void HDF5Impl::dsread( OutputArray Array, String dslabel,
585591 // fetch channs
586592 hsize_t ardims[1 ];
587593 H5Tget_array_dims ( dstype, ardims );
588- channs = ardims[0 ];
594+ channs = ( int ) ardims[0 ];
589595 // fetch depth
590596 hid_t tsuper = H5Tget_super ( dstype );
591597 h5type = H5Tget_native_type ( tsuper, H5T_DIR_ASCEND );
@@ -602,7 +608,7 @@ void HDF5Impl::dsread( OutputArray Array, String dslabel,
602608 int n_dims = H5Sget_simple_extent_ndims ( fspace );
603609
604610 // fetch dims
605- hsize_t dsdims[n_dims];
611+ hsize_t * dsdims = new hsize_t [n_dims];
606612 H5Sget_simple_extent_dims ( fspace, dsdims, NULL );
607613
608614 // set amount by custom offset
@@ -620,8 +626,8 @@ void HDF5Impl::dsread( OutputArray Array, String dslabel,
620626 }
621627
622628 // 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];
625631 for ( int d = 0 ; d < n_dims; d++ )
626632 {
627633 foffset[d] = 0 ;
@@ -653,6 +659,10 @@ void HDF5Impl::dsread( OutputArray Array, String dslabel,
653659 Mat matrix = Array.getMat ();
654660 H5Dread ( dsdata, dstype, dspace, fspace, H5P_DEFAULT, matrix.data );
655661
662+ delete dsdims;
663+ delete mxdims;
664+ delete foffset;
665+
656666 H5Tclose ( dstype );
657667 H5Sclose ( dspace );
658668 H5Sclose ( fspace );
@@ -692,9 +702,9 @@ void HDF5Impl::dswrite( InputArray Array, String dslabel,
692702 int n_dims = matrix.dims ;
693703 int channs = matrix.channels ();
694704
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];
698708 // replicate Mat dimensions
699709 for ( int d = 0 ; d < n_dims; d++ )
700710 {
@@ -738,7 +748,7 @@ void HDF5Impl::dswrite( InputArray Array, String dslabel,
738748 // expand channs
739749 if ( matrix.channels () > 1 )
740750 {
741- hsize_t adims[1 ] = { channs };
751+ hsize_t adims[1 ] = { ( hsize_t ) channs };
742752 dstype = H5Tarray_create ( dstype, 1 , adims );
743753 }
744754
@@ -749,6 +759,10 @@ void HDF5Impl::dswrite( InputArray Array, String dslabel,
749759 if ( matrix.channels () > 1 )
750760 H5Tclose ( dstype );
751761
762+ delete dsizes;
763+ delete dsdims;
764+ delete offset;
765+
752766 H5Sclose ( dspace );
753767 H5Sclose ( fspace );
754768 H5Dclose ( dsdata );
@@ -793,8 +807,8 @@ void HDF5Impl::dsinsert( InputArray Array, String dslabel,
793807 int n_dims = matrix.dims ;
794808 int channs = matrix.channels ();
795809
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];
798812 // replicate Mat dimensions
799813 for ( int d = 0 ; d < n_dims; d++ )
800814 {
@@ -828,14 +842,14 @@ void HDF5Impl::dsinsert( InputArray Array, String dslabel,
828842 // get actual file space and dims
829843 hid_t fspace = H5Dget_space ( dsdata );
830844 int f_dims = H5Sget_simple_extent_ndims ( fspace );
831- hsize_t fsdims[f_dims];
845+ hsize_t * fsdims = new hsize_t [f_dims];
832846 H5Sget_simple_extent_dims ( fspace, fsdims, NULL );
833847 H5Sclose ( fspace );
834848
835849 CV_Assert ( f_dims == n_dims );
836850
837851 // compute new extents
838- hsize_t nwdims[n_dims];
852+ hsize_t * nwdims = new hsize_t [n_dims];
839853 for ( int d = 0 ; d < n_dims; d++ )
840854 {
841855 // init
@@ -869,7 +883,7 @@ void HDF5Impl::dsinsert( InputArray Array, String dslabel,
869883 // expand channs
870884 if ( matrix.channels () > 1 )
871885 {
872- hsize_t adims[1 ] = { channs };
886+ hsize_t adims[1 ] = { ( hsize_t ) channs };
873887 dstype = H5Tarray_create ( dstype, 1 , adims );
874888 }
875889
@@ -880,6 +894,11 @@ void HDF5Impl::dsinsert( InputArray Array, String dslabel,
880894 if ( matrix.channels () > 1 )
881895 H5Tclose ( dstype );
882896
897+ delete dsdims;
898+ delete offset;
899+ delete fsdims;
900+ delete nwdims;
901+
883902 H5Sclose ( dspace );
884903 H5Sclose ( fspace );
885904 H5Dclose ( dsdata );
@@ -976,16 +995,18 @@ void HDF5Impl::kpwrite( const vector<KeyPoint> keypoints, String kplabel,
976995{
977996 CV_Assert ( keypoints.size () > 0 );
978997
998+ int dskdims[1 ];
979999 hsize_t dsddims[1 ];
9801000 hsize_t doffset[1 ];
9811001
9821002 // replicate vector dimension
9831003 doffset[0 ] = 0 ;
9841004 dsddims[0 ] = keypoints.size ();
1005+ dskdims[0 ] = (int )keypoints.size ();
9851006
9861007 // pre-create dataset if needed
9871008 if ( hlexists ( kplabel ) == false )
988- kpcreate ( dsddims [0 ], kplabel );
1009+ kpcreate ( dskdims [0 ], kplabel );
9891010
9901011 // set custom amount of data
9911012 if ( counts != H5_NONE )
@@ -1058,7 +1079,7 @@ void HDF5Impl::kpinsert( const vector<KeyPoint> keypoints, String kplabel,
10581079 // get actual file space and dims
10591080 hid_t fspace = H5Dget_space ( dsdata );
10601081 int f_dims = H5Sget_simple_extent_ndims ( fspace );
1061- hsize_t fsdims[f_dims];
1082+ hsize_t * fsdims = new hsize_t [f_dims];
10621083 H5Sget_simple_extent_dims ( fspace, fsdims, NULL );
10631084 H5Sclose ( fspace );
10641085
@@ -1101,6 +1122,8 @@ void HDF5Impl::kpinsert( const vector<KeyPoint> keypoints, String kplabel,
11011122 // write into dataset
11021123 H5Dwrite ( dsdata, mmtype, dspace, fspace, H5P_DEFAULT, &keypoints[0 ] );
11031124
1125+ delete fsdims;
1126+
11041127 H5Tclose ( mmtype );
11051128 H5Sclose ( dspace );
11061129 H5Sclose ( fspace );
0 commit comments