基于摄像头
// libfacedec.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include "stdafx.h"
#include <opencv.hpp>//加载OPENCV库所需的头文件
#include <facedetect-dll.h>//加载libfacedetection库所需的头文件
#include <stdio.h>
#include <windows.h>
#include <fstream>
#include <time.h>
using namespace std;
using namespace cv;
//提示音文件库
#pragma comment(lib, "winmm.lib")
//定义一个缓冲区,大小为:0x20000
#define DETECT_BUFFER_SIZE 0x20000
int _tmain(int argc, _TCHAR* argv[])
{
Mat src;
int scale = 2;
int * pResults = NULL;
// 向系统申请分配指定size个字节的内存空间
unsigned char * pBuffer = (unsigned char *)malloc(DETECT_BUFFER_SIZE);
if (!pBuffer)
{
fprintf(stderr, "Can not alloc buffer.\n");
return -1;
}
VideoCapture cap(0);//加载USB摄像头
if (!cap.isOpened())
{
cout << "Please check your USB camera's interface num." << endl;
return -1;
}
while (true)
{
cap