Move C structures wrappers from core.hpp to core_c.h
Also move RTTIImpl class to the only usage
This commit is contained in:
@@ -1301,6 +1301,58 @@ void HOGDescriptor::detectMultiScale(const Mat& img, std::vector<Rect>& foundLoc
|
||||
padding, scale0, finalThreshold, useMeanshiftGrouping);
|
||||
}
|
||||
|
||||
template<typename _ClsName> struct RTTIImpl
|
||||
{
|
||||
public:
|
||||
static int isInstance(const void* ptr)
|
||||
{
|
||||
static _ClsName dummy;
|
||||
static void* dummyp = &dummy;
|
||||
union
|
||||
{
|
||||
const void* p;
|
||||
const void** pp;
|
||||
} a, b;
|
||||
a.p = dummyp;
|
||||
b.p = ptr;
|
||||
return *a.pp == *b.pp;
|
||||
}
|
||||
static void release(void** dbptr)
|
||||
{
|
||||
if(dbptr && *dbptr)
|
||||
{
|
||||
delete (_ClsName*)*dbptr;
|
||||
*dbptr = 0;
|
||||
}
|
||||
}
|
||||
static void* read(CvFileStorage* fs, CvFileNode* n)
|
||||
{
|
||||
FileNode fn(fs, n);
|
||||
_ClsName* obj = new _ClsName;
|
||||
if(obj->read(fn))
|
||||
return obj;
|
||||
delete obj;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void write(CvFileStorage* _fs, const char* name, const void* ptr, CvAttrList)
|
||||
{
|
||||
if(ptr && _fs)
|
||||
{
|
||||
FileStorage fs(_fs);
|
||||
fs.fs.addref();
|
||||
((const _ClsName*)ptr)->write(fs, String(name));
|
||||
}
|
||||
}
|
||||
|
||||
static void* clone(const void* ptr)
|
||||
{
|
||||
if(!ptr)
|
||||
return 0;
|
||||
return new _ClsName(*(const _ClsName*)ptr);
|
||||
}
|
||||
};
|
||||
|
||||
typedef RTTIImpl<HOGDescriptor> HOGRTTI;
|
||||
|
||||
CvType hog_type( CV_TYPE_NAME_HOG_DESCRIPTOR, HOGRTTI::isInstance,
|
||||
|
Reference in New Issue
Block a user