本文整理汇总了C++中cv::CascadeClassifier::read方法的典型用法代码示例。如果您正苦于以下问题:C++ CascadeClassifier::read方法的具体用法?C++ CascadeClassifier::read怎么用?C++ CascadeClassifier::read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cv::CascadeClassifier
的用法示例。
在下文中一共展示了CascadeClassifier::read方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadCascade
//FLASH: load face detection cascades xml files from flash bytearrays
//must use clib.supplyFile method before calling this method from flash
static AS3_Val loadCascade(void* self, AS3_Val args)
{
//parse parameters
char * cascadeType;
char * cascadeFileName;
AS3_ArrayValue(args,"StrType, StrType", &cascadeType, &cascadeFileName);
FILE * file;
long fileSize;
char * fileBuffer;
file = fopen(cascadeFileName, "rb");
//Get file size
fseek (file, 0, SEEK_END);
fileSize = ftell(file);
rewind(file);
//Allocate buffer
fileBuffer = (char*) malloc(sizeof(char)*fileSize);
//Read file into buffer
fread(fileBuffer, 1, fileSize, file);
fprintf(stderr, "[OPENCV] loadCascades: %s : %s", cascadeType, cascadeFileName);
//CV CascadeClassifier instance init
/*cv::FileStorage cascadeFileStorage;
cascadeFileStorage.open (cascadeFileName, cv::FileStorage::READ);
fprintf(stderr, "[OPENCV] loadCascades: cascade files empty : %d", cascadeFileStorage.getFirstTopLevelNode().empty());
bool success = cascade.read (cascadeFileStorage.getFirstTopLevelNode());
fprintf(stderr, "[OPENCV] loadCascades: cascade files empty : %d", cascade.empty());
cascadeFileStorage.release ();*/
/*CvHaarClassifierCascade* cascadeClassifier = (CvHaarClassifierCascade*) cvLoad(cascadeFileName,0,0,0);
fprintf(stderr, "[OPENCV] loadCascades: cascade files loaded");*/
cv::FileNode cascadeFileNode;
cascadeFileNode.readRaw ("xml", reinterpret_cast<uchar*>(fileBuffer), fileSize);
bool success = cascade.read (cascadeFileNode);
fprintf(stderr, "[OPENCV] loadCascades: cascade files empty : %d", cascade.empty());
if (success) {
fprintf(stderr, "[OPENCV] loadCascades: cascade files loaded with success !");
} else {
fprintf(stderr, "[OPENCV] loadCascades: cascade files failed to load !");
}
//close file and free allocated buffer
fclose (file);
free (fileBuffer);
return 0;
}