ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

c-无法使用Asus Xtion Pro Live从VideoCapture OpenCV捕获图像

2019-10-09 14:18:32  阅读:187  来源: 互联网

标签:openni c opencv primesense


我刚刚安装了带有OpenNI和Primesense Sensor的OpenCV 2.4.7,可以在以下构建信息中看到.

我在从VideoCapture对象获取图像时遇到问题.例如,如果我运行openni_capture示例,则会显示“无法获取图像”.但是我得到有关深度和RGB摄像机的信息,所以我认为我已经正确打开了VideoCapture对象,但是当它尝试捕获图像时,grab函数返回0.

我正在使用Asus Xtion Pro Live,并且OpenNI和Sensor可以正常运行,因为我可以运行诸如NiViewer之类的示例.

我希望对这个问题有所帮助.

谢谢!

General configuration for OpenCV 2.4.7 =====================================
  Version control:               unknown

  Platform:
    Host:                        Linux 3.5.0-47-generic x86_64
    CMake:                       2.8.9
    CMake generator:             Unix Makefiles
    CMake build tool:            /usr/bin/make
    Configuration:               Release

  C/C++:
    Built as dynamic libs?:      YES
    C++ Compiler:                /usr/bin/c++  (ver 4.7.2)
    C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -O3 -DNDEBUG  -DNDEBUG
    C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -g  -O0 -DDEBUG -D_DEBUG -ggdb3
    C Compiler:                  /usr/bin/gcc
    C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -O3 -DNDEBUG  -DNDEBUG
    C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -msse3 -ffunction-sections -g  -O0 -DDEBUG -D_DEBUG -ggdb3
    Linker flags (Release):      
    Linker flags (Debug):        
    Precompiled headers:         YES

  OpenCV modules:
    To be built:                 core flann imgproc highgui features2d calib3d ml video legacy objdetect photo gpu ocl nonfree contrib java python stitching superres ts videostab
    Disabled:                    world
    Disabled by dependency:      -
    Unavailable:                 androidcamera

  GUI: 
    QT:                          NO
    GTK+ 2.x:                    YES (ver 2.24.13)
    GThread :                    YES (ver 2.34.1)
    GtkGlExt:                    NO
    OpenGL support:              NO

  Media I/O: 
    ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.7)
    JPEG:                        libjpeg (ver 62)
    PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.2.49)
    TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 - 4.0.2)
    JPEG 2000:                   /usr/lib/x86_64-linux-gnu/libjasper.so (ver 1.900.1)
    OpenEXR:                     build (ver 1.7.1)

  Video I/O:
    DC1394 1.x:                  NO
    DC1394 2.x:                  YES (ver 2.2.0)
    FFMPEG:                      YES
      codec:                     YES (ver 53.35.0)
      format:                    YES (ver 53.21.1)
      util:                      YES (ver 51.22.2)
      swscale:                   YES (ver 2.1.0)
      gentoo-style:              YES
    GStreamer:                   
      base:                      YES (ver 0.10.36)
      app:                       YES (ver 0.10.36)
      video:                     YES (ver 0.10.36)
    OpenNI:                      YES (ver 1.5.7, build 10)
    OpenNI PrimeSensor Modules:  YES (/usr/lib/libXnCore.so)
    PvAPI:                       NO
    GigEVisionSDK:               NO
    UniCap:                      NO
    UniCap ucil:                 NO
    V4L/V4L2:                    Using libv4l (ver 0.8.8)
    XIMEA:                       NO
    Xine:                        NO

  Other third-party libraries:
    Use IPP:                     NO
    Use Eigen:                   YES (ver 3.0.93)
    Use TBB:                     NO
    Use OpenMP:                  NO
    Use GCD                      NO
    Use Concurrency              NO
    Use C=:                      NO
    Use Cuda:                    NO
    Use OpenCL:                  YES

  OpenCL:
    Version:                     dynamic
    Include path:                /home/xxx/imageproc/opencv-2.4.7/3rdparty/include/opencl/1.2
    Use AMD FFT:                 NO
    Use AMD BLAS:                NO

  Python:
    Interpreter:                 /usr/bin/python2 (ver 2.7.3)
    Libraries:                   /usr/lib/libpython2.7.so (ver 2.7.3)
    numpy:                       /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.6.2)
    packages path:               lib/python2.7/dist-packages

  Java:
    ant:                         /usr/bin/ant (ver 1.8.2)
    JNI:                         /usr/lib/jvm/java-6-openjdk/include /usr/lib/jvm/java-6-openjdk/include /usr/lib/jvm/java-6-openjdk/include
    Java tests:                  YES

  Documentation:
    Build Documentation:         NO
    Sphinx:                      NO
    PdfLaTeX compiler:           /usr/bin/pdflatex

  Tests and samples:
    Tests:                       YES
    Performance tests:           YES
    C/C++ Examples:              YES

  Install path:                  /usr/local

  cvconfig.h is in:              /home/xxx/imageproc/opencv-2.4.7/release

我实例化了视频捕获,并尝试捕获图像,如下所示:

VideoCapture capture;

capture.open(CV_CAP_OPENNI);

if ( !capture.isOpened() )
{
    cout << "Error opening capture" << endl;
    return -1;
}


if( !capture.grab() )
{
    cout << "Can not grab image" << endl;
}

解决方法:

根据您的代码,我的猜测是将使用kinect openni驱动程序而不是华硕openni驱动程序

这个怎么样:

VideoCapture capture;

capture.open(CV_CAP_OPENNI_ASUS);

if ( !capture.isOpened() )
{
    cout << "Error opening capture" << endl;
    return -1;
}


if( !capture.grab() )
{
    cout << "Can not grab image" << endl;
}

过去我曾经在opencv上使用过两个asus xtion pro传感器,可以看到我的测试code here.

另外,这些是highui types header中的值,并带有注释:

CV_CAP_OPENNI   =900,   // OpenNI (for Kinect)
CV_CAP_OPENNI_ASUS =910,   // OpenNI (for Asus Xtion)

标签:openni,c,opencv,primesense
来源: https://codeday.me/bug/20191009/1879683.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有