OpenCV无法从Kinect检测人脸
OpenCV not detecting faces from Kinect
我正试着用下面的代码检测kinect的人脸。OpenCV的detectMultiScale()在我使用电脑的相机时可以正确地检测人脸,但它似乎不能与kinect的图像一起工作。
Device device;
VideoFrameRef colorFrame;
VideoStream ColorStream;
Mat colorImage, grayScaleFrame;
colorStream.create(device, SENSOR_COLOR );
colorStream.start();
while (1){
colorStream.readFrame(&colorFrame);
const RGB888Pixel *imageBuffer = (const RGB888Pixel*)colorFrame.getData();
colorImage.create(colorFrame.getHeight(), colorFrame.getWidth(), CV_8UC3);
memcpy(colorImage.data, imageBuffer, 3 * colorFrame.getHeight() * colorFrame.getWidth() * sizeof(uint8_t));
//face detection
blur(colorImage, colorImage, Size(2, 2), Point(-1, -1), BORDER_DEFAULT);
cvtColor(colorImage, grayScaleFrame, CV_BGR2GRAY);
equalizeHist(grayScaleFrame, grayScaleFrame);
classifier.detectMultiScale(grayScaleFrame, faces, 1.1, 3, CV_HAAR_FIND_BIGGEST_OBJECT|CV_HAAR_SCALE_IMAGE, Size(30, 30) );
}
知道为什么会这样吗?
谢谢!
请确保您按照以下步骤与Kinect/OpenNI(1.5.4.0+)抓取帧:
cv::Mat rgb_image, depth_map;
cv::VideoCapture device.open(CV_CAP_OPENNI);
//set RGB-Depth mapping
device.set(CV_CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION, 1.0);
while(1)
{
device.grab();
device.retrieve(rgb_image, CV_CAP_OPENNI_BGR_IMAGE);
device.retrieve(depth_map, CV_CAP_OPENNI_DEPTH_MAP);
}
相关文章:
- 使用CMake检测支持的C++标准
- 当套接字连接断开时检测C/C++Unix
- C/C++预处理器是否可以检测一些编译器选项
- WMI检测进程创建事件-c++
- 基于树莓pi的tensorflow lite量化ssd目标检测
- 下面是我为检测链接列表中的循环而制作的代码
- 落砂模拟碰撞检测C++和SFML
- 我可以检测和更改 gcc/g++ 中结构的当前数据对齐设置吗?
- 为什么C++编译器没有检测到正确声明的类?
- 检测win32服务创建和删除的最佳方法
- 正在LLVM中检测整数比较条件
- 如何在鼠标挂钩过程中检测拖动
- 位移操作和位掩码未检测到重复字符
- 检测 COFF 对象文件中C++内联符号
- 无法在Windows中初始化Kinect(检测到0个传感器)
- 如何检测程序运行时 Kinect 何时断开连接/拔出
- 使用 Kinect SDK 进行简单的 blob 检测
- 使用 Kinect [Algo] 检测跳跃手势
- 使用2个Kinect进行检测
- OpenCV无法从Kinect检测人脸