一.代码声明
下面的代码是博主参考了Intel realsense官方SDK和官方例程后写的一段较为简单的代码,实现了简单的多人脸实时检测及跟踪功能。官方的人脸检测例程功能较多,但代码量很大,阅读起来也较困难,所以博主写了一段较为精简的人脸检测代码。
二.具体代码
#include <pxcsensemanager.h>
#include <pxcsession.h>
#include "util_render.h"
#include <iostream>
#include <string>
#include <stdio.h>
#include <opencv2\opencv.hpp>
#include <windows.h>
#define WIDTH 640
#define HEIGHT 480
using namespace cv;
using namespace std;
void DrawRectangle(Mat &img, Rect box)
{
rectangle(img, box, Scalar(255, 255, 0),2);
}
int main(int argc, char** argv)
{
PXCSenseManager *psm = 0;
psm = PXCSenseManager::CreateInstance();
if (!psm)
{
wprintf_s(L"Unabel to create the PXCSenseManager\n");
return 1;
}
//使能人脸跟踪
psm->EnableFace();
// 初始化管道
psm->Init();
//得到一个人脸模块的实例
PXCFaceModule *faceModule = psm->QueryFace();
if (faceModule == NULL)
{
wp

本文提供了博主根据Intel Realsense SDK和官方例程编写的简化版多人脸检测及跟踪代码,简化了官方例程的复杂性。在研究过程中,博主发现Realsense SDK参考资料有限,对比Kinect,虽然Realsense功能强大且体积小巧,但相关开发者资源较少。文章详细介绍了代码实现过程中的困惑和理解,强调了关键函数如ApplyChanges的作用,并指出正确的人脸模块使能和追踪配置时机。
最低0.47元/天 解锁文章
3872





