本文整理汇总了C++中OutputArray::isMat方法的典型用法代码示例。如果您正苦于以下问题:C++ OutputArray::isMat方法的具体用法?C++ OutputArray::isMat怎么用?C++ OutputArray::isMat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OutputArray
的用法示例。
在下文中一共展示了OutputArray::isMat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeFeatures
//static
void QualityBRISQUE::computeFeatures(InputArray img, OutputArray features)
{
CV_Assert(features.needed());
CV_Assert(img.isMat());
CV_Assert(!img.getMat().empty());
auto mat = mat_convert(img.getMat());
const auto vals = ComputeBrisqueFeature(mat);
cv::Mat valmat( cv::Size( (int)vals.size(), 1 ), CV_32FC1, (void*)vals.data()); // create row vector, type depends on brisque_calc_element_type
if (features.isUMat())
valmat.copyTo(features.getUMatRef());
else if (features.isMat())
// how to move data instead?
// if calling this:
// features.getMatRef() = valmat;
// then shared data is erased when valmat is released, corrupting the data in the outputarray for the caller
valmat.copyTo(features.getMatRef());
else
CV_Error(cv::Error::StsNotImplemented, "Unsupported output type");
}
示例2: GetCVtype
void HDF5Impl::dsread( OutputArray Array, const String& dslabel,
const int* dims_offset, const int* dims_counts ) const
{
// only Mat support
CV_Assert( Array.isMat() );
hid_t h5type;
// open the HDF5 dataset
hid_t dsdata = H5Dopen( m_h5_file_id, dslabel.c_str(), H5P_DEFAULT );
// get data type
hid_t dstype = H5Dget_type( dsdata );
int channs = 1;
if ( H5Tget_class( dstype ) == H5T_ARRAY )
{
// fetch channs
hsize_t ardims[1];
H5Tget_array_dims( dstype, ardims );
channs = (int) ardims[0];
// fetch depth
hid_t tsuper = H5Tget_super( dstype );
h5type = H5Tget_native_type( tsuper, H5T_DIR_ASCEND );
H5Tclose( tsuper );
} else
h5type = H5Tget_native_type( dstype, H5T_DIR_ASCEND );
int dType = GetCVtype( h5type );
// get file space
hid_t fspace = H5Dget_space( dsdata );
// fetch rank
int n_dims = H5Sget_simple_extent_ndims( fspace );
// fetch dims
hsize_t *dsdims = new hsize_t[n_dims];
H5Sget_simple_extent_dims( fspace, dsdims, NULL );
// set amount by custom offset
if ( dims_offset != NULL )
{
for ( int d = 0; d < n_dims; d++ )
dsdims[d] -= dims_offset[d];
}
// set custom amount of data
if ( dims_counts != NULL )
{
for ( int d = 0; d < n_dims; d++ )
dsdims[d] = dims_counts[d];
}
// get memory write window
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;
mxdims[d] = (int) dsdims[d];
}
// allocate persistent Mat
Array.create( n_dims, mxdims, CV_MAKETYPE(dType, channs) );
// get blank data space
hid_t dspace = H5Screate_simple( n_dims, dsdims, NULL );
// get matrix write window
H5Sselect_hyperslab( dspace, H5S_SELECT_SET,
foffset, NULL, dsdims, NULL );
// set custom offsets
if ( dims_offset != NULL )
{
for ( int d = 0; d < n_dims; d++ )
foffset[d] = dims_offset[d];
}
// get a file read window
H5Sselect_hyperslab( fspace, H5S_SELECT_SET,
foffset, NULL, dsdims, NULL );
// read from DS
Mat matrix = Array.getMat();
H5Dread( dsdata, dstype, dspace, fspace, H5P_DEFAULT, matrix.data );
delete [] dsdims;
delete [] mxdims;
delete [] foffset;
H5Tclose (h5type );
H5Tclose( dstype );
H5Sclose( dspace );
H5Sclose( fspace );
H5Dclose( dsdata );
}