首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >OpenNI + OpenCV + Qt

OpenNI + OpenCV + Qt
EN

Stack Overflow用户
提问于 2011-03-03 10:39:43
回答 1查看 2.7K关注 0票数 0

我正在尝试使用Kinect (OpenNI)制作一个应用程序,使用图形用户界面处理图像(OpenCV)。

我测试了de OpenNI+OpenCV和OpenCV+Qt

通常,当我们使用OpenCV+Qt时,我们可以制作一个QWidget来显示摄像机的内容(VideoCapture)。捕获帧并更新此查询,以将新帧发送到设备。

在OpenNI和OpenCV中,我看到了使用for cycle从Kinect传感器拉取数据(图像、深度)的例子,但我不知道如何让这个拉取路由变得简单。我的意思是,类似于OpenCV框架查询。

这个想法是将从Kinect捕获的图像嵌入到QWidget中。QWidget将有(目前)两个按钮“启动Kinect”和“退出”..and下方的绘画部分,以显示捕获的数据。

有什么想法吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-12-30 19:44:09

您可以尝试使用QTimer类以固定的时间间隔查询kinect。在我的应用程序中,我使用了以下代码。

代码语言:javascript
复制
void UpperBodyGestures::refreshUsingTimer()
{
    QTimer *timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(MainEventFunction()));
    timer->start(30);
}

void UpperBodyGestures::on_pushButton_Kinect_clicked()
{
    InitKinect();
    ui.pushButton_Kinect->setEnabled(false);
}


// modify the main function to call refreshUsingTimer function

    UpperBodyGestures w;
    w.show();
    w.refreshUsingTimer();
    return a.exec();

然后,您可以使用label小部件来查询框架。我在下面发布了一个示例代码:

代码语言:javascript
复制
// Query the depth data from Openni
const XnDepthPixel* pDepth = depthMD.Data();
// Convert it to opencv for manipulation etc
cv::Mat DepthBuf(480,640,CV_16UC1,(unsigned char*)g_Depth);
// Normalize Depth image to 0-255 range (cant remember max range number so assuming it as 10k)
DepthBuf = DepthBuf / 10000 *255; 
DepthBuf.convertTo(DepthBuf,CV_8UC1);
// Convert opencv image to a Qimage object 
QImage qimage((const unsigned char*)DepthBuf.data, DepthBuf.size().width, DepthBuf.size().height, DepthBuf.step, QImage::Format_RGB888);        
// Display the Qimage in the defined mylabel object
ui.myLabel->setPixmap(pixmap.fromImage(qimage,0).scaled(QSize(300,300), Qt::KeepAspectRatio, Qt::FastTransformation));
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5176069

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档