【问题标题】:OpenNI + OpenCV + QtOpenNI + OpenCV + Qt
【发布时间】:2011-03-03 02:39:43
【问题描述】:

我正在尝试使用 Kinect (OpenNI) 制作应用程序,使用 GUI 处理图像 (OpenCV)。

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

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

使用 OpenNI 和 OpenCV,我看到了使用 for 循环从 Kinect 传感器(图像、深度)中提取数据的示例,但我不知道如何使这种拉动路由变得简单。我的意思是,类似于 OpenCV 帧查询。

这个想法被嵌入到 QWidget 中,从 Kinect 捕获的图像。 QWidget 将(目前)有 2 个按钮“Start Kinect”和“Quit”......在“绘画”部分下方显示捕获的数据。

有什么想法吗?

【问题讨论】:

    标签: qt opencv kinect openni


    【解决方案1】:

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

    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();
    

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

    // 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));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多