|
发表于 2015-7-31 16:26:01
|
显示全部楼层
用DLL再封装一下,就能给delphi或者VB等工具调用了
#include <opencv.hpp>
#include "facedetect-dll.h"
#pragma comment(lib,"libfacedetect.lib")
using namespace cv;
extern "C" __declspec(dllexport) int * facedetectfrontal( char *picname,//input image, it must be gray (single-channel) image!
float scale, //scale factor for scan windows
int min_neighbors, //how many neighbors each candidate rectangle should have to retain it
int min_size, //Minimum possible face size. Faces smaller than that are ignored.
int max_size)
{
Mat gray = imread(picname, CV_LOAD_IMAGE_GRAYSCALE);
int * pResults = NULL;
if(!gray.empty())
pResults = facedetect_frontal((unsigned char*)(gray.ptr(0)), gray.cols, gray.rows, gray.step,
scale,min_neighbors,min_size,max_size);
//if(!gray.empty())
// pResults = facedetect_frontal((unsigned char*)(gray.ptr(0)), gray.cols, gray.rows, gray.step,
// 1.2f, 2,24,0);
return pResults;
}
extern "C" __declspec(dllexport) int * facedetectmultiview( char *picname,//input image, it must be gray (single-channel) image!
float scale, //scale factor for scan windows
int min_neighbors, //how many neighbors each candidate rectangle should have to retain it
int min_size, //Minimum possible face size. Faces smaller than that are ignored.
int max_size)
{
//return facedetect_multiview(gray_image_data,width,height,step,scale,min_neighbors,min_size,max_size);
Mat gray = imread(picname, CV_LOAD_IMAGE_GRAYSCALE);
int * pResults = NULL;
if(!gray.empty())
pResults = facedetect_multiview((unsigned char*)(gray.ptr(0)), gray.cols, gray.rows, gray.step,
scale, min_neighbors,min_size,max_size);
return pResults;
}
extern "C" __declspec(dllexport) int headcount(char *picname)
{
Mat gray = imread(picname, CV_LOAD_IMAGE_GRAYSCALE);
int * pResults = NULL;
if(!gray.empty())pResults = facedetect_frontal((unsigned char*)(gray.ptr(0)), gray.cols, gray.rows, gray.step,1.2f, 2,24,0);
int rt=pResults ? *pResults : 0;
//int rt=*pResults;
return rt;
} |
|