mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 00:03:03 +04:00
clean up c-api
This commit is contained in:
@@ -3299,11 +3299,6 @@ private:
|
||||
int* lut_;
|
||||
};
|
||||
|
||||
CV_IMPL void cvEqualizeHist( const CvArr* srcarr, CvArr* dstarr )
|
||||
{
|
||||
cv::equalizeHist(cv::cvarrToMat(srcarr), cv::cvarrToMat(dstarr));
|
||||
}
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
namespace cv {
|
||||
@@ -3451,158 +3446,4 @@ void cv::equalizeHist( InputArray _src, OutputArray _dst )
|
||||
lutBody(heightRange);
|
||||
}
|
||||
|
||||
#if 0
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/* Implementation of RTTI and Generic Functions for CvHistogram */
|
||||
#define CV_TYPE_NAME_HIST "opencv-hist"
|
||||
|
||||
static int icvIsHist( const void * ptr )
|
||||
{
|
||||
return CV_IS_HIST( ((CvHistogram*)ptr) );
|
||||
}
|
||||
|
||||
static CvHistogram * icvCloneHist( const CvHistogram * src )
|
||||
{
|
||||
CvHistogram * dst=NULL;
|
||||
cvCopyHist(src, &dst);
|
||||
return dst;
|
||||
}
|
||||
|
||||
static void *icvReadHist( CvFileStorage * fs, CvFileNode * node )
|
||||
{
|
||||
CvHistogram * h = 0;
|
||||
int type = 0;
|
||||
int is_uniform = 0;
|
||||
int have_ranges = 0;
|
||||
|
||||
h = (CvHistogram *)cvAlloc( sizeof(CvHistogram) );
|
||||
|
||||
type = cvReadIntByName( fs, node, "type", 0 );
|
||||
is_uniform = cvReadIntByName( fs, node, "is_uniform", 0 );
|
||||
have_ranges = cvReadIntByName( fs, node, "have_ranges", 0 );
|
||||
h->type = CV_HIST_MAGIC_VAL | type |
|
||||
(is_uniform ? CV_HIST_UNIFORM_FLAG : 0) |
|
||||
(have_ranges ? CV_HIST_RANGES_FLAG : 0);
|
||||
|
||||
if(type == CV_HIST_ARRAY)
|
||||
{
|
||||
// read histogram bins
|
||||
CvMatND* mat = (CvMatND*)cvReadByName( fs, node, "mat" );
|
||||
int i, sizes[CV_MAX_DIM];
|
||||
|
||||
if(!CV_IS_MATND(mat))
|
||||
CV_Error( CV_StsError, "Expected CvMatND");
|
||||
|
||||
for(i=0; i<mat->dims; i++)
|
||||
sizes[i] = mat->dim[i].size;
|
||||
|
||||
cvInitMatNDHeader( &(h->mat), mat->dims, sizes, mat->type, mat->data.ptr );
|
||||
h->bins = &(h->mat);
|
||||
|
||||
// take ownership of refcount pointer as well
|
||||
h->mat.refcount = mat->refcount;
|
||||
|
||||
// increase refcount so freeing temp header doesn't free data
|
||||
cvIncRefData( mat );
|
||||
|
||||
// free temporary header
|
||||
cvReleaseMatND( &mat );
|
||||
}
|
||||
else
|
||||
{
|
||||
h->bins = cvReadByName( fs, node, "bins" );
|
||||
if(!CV_IS_SPARSE_MAT(h->bins)){
|
||||
CV_Error( CV_StsError, "Unknown Histogram type");
|
||||
}
|
||||
}
|
||||
|
||||
// read thresholds
|
||||
if(have_ranges)
|
||||
{
|
||||
int i, dims, size[CV_MAX_DIM], total = 0;
|
||||
CvSeqReader reader;
|
||||
CvFileNode * thresh_node;
|
||||
|
||||
dims = cvGetDims( h->bins, size );
|
||||
for( i = 0; i < dims; i++ )
|
||||
total += size[i]+1;
|
||||
|
||||
thresh_node = cvGetFileNodeByName( fs, node, "thresh" );
|
||||
if(!thresh_node)
|
||||
CV_Error( CV_StsError, "'thresh' node is missing");
|
||||
cvStartReadRawData( fs, thresh_node, &reader );
|
||||
|
||||
if(is_uniform)
|
||||
{
|
||||
for(i=0; i<dims; i++)
|
||||
cvReadRawDataSlice( fs, &reader, 2, h->thresh[i], "f" );
|
||||
h->thresh2 = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
float* dim_ranges;
|
||||
h->thresh2 = (float**)cvAlloc(
|
||||
dims*sizeof(h->thresh2[0])+
|
||||
total*sizeof(h->thresh2[0][0]));
|
||||
dim_ranges = (float*)(h->thresh2 + dims);
|
||||
for(i=0; i < dims; i++)
|
||||
{
|
||||
h->thresh2[i] = dim_ranges;
|
||||
cvReadRawDataSlice( fs, &reader, size[i]+1, dim_ranges, "f" );
|
||||
dim_ranges += size[i] + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
static void icvWriteHist( CvFileStorage* fs, const char* name,
|
||||
const void* struct_ptr, CvAttrList /*attributes*/ )
|
||||
{
|
||||
const CvHistogram * hist = (const CvHistogram *) struct_ptr;
|
||||
int sizes[CV_MAX_DIM];
|
||||
int dims;
|
||||
int i;
|
||||
int is_uniform, have_ranges;
|
||||
|
||||
cvStartWriteStruct( fs, name, CV_NODE_MAP, CV_TYPE_NAME_HIST );
|
||||
|
||||
is_uniform = (CV_IS_UNIFORM_HIST(hist) ? 1 : 0);
|
||||
have_ranges = (hist->type & CV_HIST_RANGES_FLAG ? 1 : 0);
|
||||
|
||||
cvWriteInt( fs, "type", (hist->type & 1) );
|
||||
cvWriteInt( fs, "is_uniform", is_uniform );
|
||||
cvWriteInt( fs, "have_ranges", have_ranges );
|
||||
if(!CV_IS_SPARSE_HIST(hist))
|
||||
cvWrite( fs, "mat", &(hist->mat) );
|
||||
else
|
||||
cvWrite( fs, "bins", hist->bins );
|
||||
|
||||
// write thresholds
|
||||
if(have_ranges){
|
||||
dims = cvGetDims( hist->bins, sizes );
|
||||
cvStartWriteStruct( fs, "thresh", CV_NODE_SEQ + CV_NODE_FLOW );
|
||||
if(is_uniform){
|
||||
for(i=0; i<dims; i++){
|
||||
cvWriteRawData( fs, hist->thresh[i], 2, "f" );
|
||||
}
|
||||
}
|
||||
else{
|
||||
for(i=0; i<dims; i++){
|
||||
cvWriteRawData( fs, hist->thresh2[i], sizes[i]+1, "f" );
|
||||
}
|
||||
}
|
||||
cvEndWriteStruct( fs );
|
||||
}
|
||||
|
||||
cvEndWriteStruct( fs );
|
||||
}
|
||||
|
||||
|
||||
CvType hist_type( CV_TYPE_NAME_HIST, icvIsHist, (CvReleaseFunc)cvReleaseHist,
|
||||
icvReadHist, icvWriteHist, (CvCloneFunc)icvCloneHist );
|
||||
#endif
|
||||
|
||||
/* End of file. */
|
||||
|
||||
Reference in New Issue
Block a user