精华内容
下载资源
问答
  • 奥比中光 dabaipro.zip

    2021-09-01 09:46:06
    奥比中光 大白PRO 原厂资料 适合机器人开发 人工智能领域
  • 奥比中光外文官网下载的OPENNI资源,在Android环境下使用奥比中光摄像头的人
  • 奥比中光外文官网下载的OPENNI资源,在linux环境下的资源分享给刚接触奥比中光摄像头的人
  • 奥比中光(Astra S)双相机开发,深度相机轮流采集点云以及RGB图像
  • 奥比中光深度摄像头NiViewer.exe,可以查看深度视频、质心
  • 奥比中光英文官网下载的windows环境下64位电脑使用的SDK压缩包
  • 奥比中光深度相机ROS配置说明,实现RVIZ查看深度信息
  • 奥比中光外文官网下载的OPENNI资源分享给初学者,在window环境下的资源
  • 取自奥比中光境外网站。版本为2.3.0.43. Last updated: 2018-03-26 于2018年11月24日下载
  • Astra奥比中光相机驱动&SDK,导库

    千次阅读 2020-08-21 17:19:16
    Astra奥比中光相机驱动&SDK,导库 https://blog.csdn.net/qq_15204179/article/details/107706758 Astra奥比中光相机驱动&SDK Astra(orbbec奥比中光)乐视相机相关驱动,本教程针对Windows和Ubuntu14.04=...

                                                                Astra奥比中光相机驱动&SDK,导库

    https://blog.csdn.net/qq_15204179/article/details/107706758

    Astra奥比中光相机驱动&SDK

    Astra(orbbec奥比中光)乐视相机相关驱动,本教程针对WindowsUbuntu14.04=Ubuntu18.04系统版本

    官网链接:https://orbbec3d.com/develop/

    该深度相机是乐视与奥比中光合作的体感相机,对标微软Kinect,可用于三维重建,SLAM学习,也可以作为免驱UVC摄像头体感摄像头使用

     

    相机参数:

     

    Linux环境

    依赖环境

    sudo apt-get install build-essential freeglut3 freeglut3-dev
    sudo apt-get install libsfml-dev

    相机SDK&Samples

    • 执行环境安装
    tar -zxvf AstraSDK-v2.0.18-05cfa52534-20191108T074013Z-ubuntu1604.tar.gz
    cd AstraSDK-v2.0.18-05cfa52534-20191108T074013Z-Linux/install
    sudo sh ./install.sh

    输出结果包含以下两行,注意把倒数第二个路径里的install删掉:

    export ASTRA_SDK_INCLUDE=/home/ty/Lesson/GrabObject/astra/AstraSDK-v2.0.18-05cfa52534-20191108T074013Z-Linux/install/include export ASTRA_SDK_LIB=/home/ty/Lesson/GrabObject/astra/AstraSDK-v2.0.18-05cfa52534-20191108T074013Z-Linux/install/lib

    删掉install之后:

    export ASTRA_SDK_INCLUDE=/home/ty/Lesson/GrabObject/astra/AstraSDK-v2.0.18-05cfa52534-20191108T074013Z-Linux/include export ASTRA_SDK_LIB=/home/ty/Lesson/GrabObject/astra/AstraSDK-v2.0.18-05cfa52534-20191108T074013Z-Linux/lib

    将输出结果复制到~/.bashrc尾部

    gedit ~/.bashrc
    

    使之生效

    source ~/.bashrc
    

    amples目录中即是示例程序,需要依赖include和lib目录

    OpenNI相机测试工具

    安装OpenNI

    unzip OpenNI_2.3.0.55.zip
    cd OpenNI_2.3.0.55/Linux/OpenNI-Linux-x64-2.3.0.55
    chmod +x install.sh
    sudo ./install.sh
    • 重新拔插设备
    • 初始化OpenNI环境
    source OpenNIDevEnvironment
    

    编译运行

    cd Samples/SimpleViewer
    make
    cd Bin/x64-Release
    ./SimpleViewer

    -----------------------------------c++导库-----------------------------------------------

     

     

    FindAstra.cmake

    set(Astra_DIR ${PREBUILT_DIR}/astra)
    
    # 声明头文件h所在目录
    set(ASTRA_INCLUDE_DIRS ${Astra_DIR}/include)
    
    # 声明so库文件所在目录
    set(ASTRA_LINK_DIRS ${Astra_DIR}/lib)
    
    # libastra.so, libastra_core.so ...
    set(ASTRA_LIBRARIES astra;astra_core;astra_core_api;pthread)

    FindOpenCV.cmake

    
    # once done, this will define
    #OpenCV_FOUND        -  whether there is OpenCV in the prebuilt libraries
    #OpenCV_INCLUDE_DIRS -  include directories for OpenCV
    #OpenCV_LIBRARY_DIRS -  library directories for OpenCV
    #OpenCV_LIBRARIES    -  link this to use OpenCV
    
    set(OpenCV_DIR ~/3rdparty/OpenCV-3.4.9)
    
    unset(OpenCV_FOUND)
    
    MESSAGE(STATUS "OpenCV_DIR TEST  ${PREBUILT_DIR}")
    
    set(OpenCV_INCLUDE_DIRS "${OpenCV_DIR}/include" "${OpenCV_DIR}/include/opencv")
    set(OpenCV_LIB_COMPONENTS opencv_core;opencv_ml;opencv_calib3d;opencv_highgui;opencv_superres;opencv_photo;
            opencv_imgcodecs;opencv_features2d;opencv_viz;opencv_flann;opencv_shape;opencv_stitching;opencv_dnn;
            opencv_videostab;opencv_imgproc;opencv_objdetect;opencv_video;opencv_videoio;opencv_reg;opencv_aruco;
            opencv_dpm;opencv_xobjdetect;opencv_xfeatures2d;opencv_surface_matching;opencv_plot;opencv_hfs;
            opencv_tracking;opencv_rgbd;opencv_text;opencv_dnn_objdetect;opencv_face;opencv_optflow;opencv_bgsegm;
            opencv_bioinspired;opencv_ximgproc;opencv_saliency;opencv_freetype;opencv_stereo;opencv_img_hash;
            opencv_fuzzy;opencv_ccalib;opencv_line_descriptor;opencv_hdf;opencv_datasets;opencv_phase_unwrapping;
            opencv_xphoto;opencv_structured_light)
    
    find_path(OpenCV_INCLUDE_DIRS NAMES opencv.h HINTS ${OpenCV_DIR}/include NO_SYSTEM_ENVIRONMENT_PATH)
    
    set(OpenCV_LIBRARY_DIRS ${OpenCV_DIR}/lib)
    
    FOREACH(cvcomponent ${OpenCV_LIB_COMPONENTS})
      find_library(lib_${cvcomponent} NAMES ${cvcomponent} HINTS ${OpenCV_DIR}/lib NO_DEFAULT_PATH)
    
      set(OpenCV_LIBRARIES ${OpenCV_LIBRARIES};${lib_${cvcomponent}})
    ENDFOREACH()
    
    set(OpenCV_LIBS ${OpenCV_LIBRARIES})
    
    set(OpenCV_INCLUDE_DIRS ${OpenCV_INCLUDE_DIRS};${OpenCV_INCLUDE_DIRS}/opencv)
    
    if (OpenCV_INCLUDE_DIRS AND OpenCV_LIBRARIES)
      set(OpenCV_FOUND TRUE)
    endif (OpenCV_INCLUDE_DIRS AND OpenCV_LIBRARIES)
    
    if (OpenCV_FOUND)
      if (NOT OpenCV_FIND_QUIETLY)
        message(STATUS "Found OpenCV: ${OpenCV_LIBRARIES}")
      endif (NOT OpenCV_FIND_QUIETLY)
    else(OpenCV_FOUND)
      if (OpenCV_FIND_REQUIRED)
        message(FATAL_ERROR "Could not find the OpenCV library")
      endif ()
    endif (OpenCV_FOUND)
    

     FindSFML.cmake

    # This script locates the SFML library
    # ------------------------------------
    #
    # Usage
    # -----
    #
    # When you try to locate the SFML libraries, you must specify which modules you want to use (system, window, graphics, network, audio, main).
    # If none is given, the SFML_LIBRARIES variable will be empty and you'll end up linking to nothing.
    # example:
    #   find_package(SFML COMPONENTS graphics window system) // find the graphics, window and system modules
    #
    # You can enforce a specific version, either MAJOR.MINOR or only MAJOR.
    # If nothing is specified, the version won't be checked (i.e. any version will be accepted).
    # example:
    #   find_package(SFML COMPONENTS ...)     // no specific version required
    #   find_package(SFML 2 COMPONENTS ...)   // any 2.x version
    #   find_package(SFML 2.4 COMPONENTS ...) // version 2.4 or greater
    #
    # By default, the dynamic libraries of SFML will be found. To find the static ones instead,
    # you must set the SFML_STATIC_LIBRARIES variable to TRUE before calling find_package(SFML ...).
    # Since you have to link yourself all the SFML dependencies when you link it statically, the following
    # additional variables are defined: SFML_XXX_DEPENDENCIES and SFML_DEPENDENCIES (see their detailed
    # description below).
    # In case of static linking, the SFML_STATIC macro will also be defined by this script.
    # example:
    #   set(SFML_STATIC_LIBRARIES TRUE)
    #   find_package(SFML 2 COMPONENTS network system)
    #
    # On Mac OS X if SFML_STATIC_LIBRARIES is not set to TRUE then by default CMake will search for frameworks unless
    # CMAKE_FIND_FRAMEWORK is set to "NEVER" for example. Please refer to CMake documentation for more details.
    # Moreover, keep in mind that SFML frameworks are only available as release libraries unlike dylibs which
    # are available for both release and debug modes.
    #
    # If SFML is not installed in a standard path, you can use the SFML_ROOT CMake (or environment) variable
    # to tell CMake where SFML is.
    #
    # Output
    # ------
    #
    # This script defines the following variables:
    # - For each specified module XXX (system, window, graphics, network, audio, main):
    #   - SFML_XXX_LIBRARY_DEBUG:   the name of the debug library of the xxx module (set to SFML_XXX_LIBRARY_RELEASE is no debug version is found)
    #   - SFML_XXX_LIBRARY_RELEASE: the name of the release library of the xxx module (set to SFML_XXX_LIBRARY_DEBUG is no release version is found)
    #   - SFML_XXX_LIBRARY:         the name of the library to link to for the xxx module (includes both debug and optimized names if necessary)
    #   - SFML_XXX_FOUND:           true if either the debug or release library of the xxx module is found
    #   - SFML_XXX_DEPENDENCIES:    the list of libraries the module depends on, in case of static linking
    # - SFML_LIBRARIES:    the list of all libraries corresponding to the required modules
    # - SFML_FOUND:        true if all the required modules are found
    # - SFML_INCLUDE_DIR:  the path where SFML headers are located (the directory containing the SFML/Config.hpp file)
    # - SFML_DEPENDENCIES: the list of libraries SFML depends on, in case of static linking
    #
    # example:
    #   find_package(SFML 2 COMPONENTS system window graphics audio REQUIRED)
    #   include_directories(${SFML_INCLUDE_DIR})
    #   add_executable(myapp ...)
    #   target_link_libraries(myapp ${SFML_LIBRARIES})
    
    # define the SFML_STATIC macro if static build was chosen
    if(SFML_STATIC_LIBRARIES)
        add_definitions(-DSFML_STATIC)
    endif()
    
    # define the list of search paths for headers and libraries
    set(FIND_SFML_PATHS
        ${SFML_ROOT}
        $ENV{SFML_ROOT}
        ~/Library/Frameworks
        /Library/Frameworks
        /usr/local
        /usr
        /sw
        /opt/local
        /opt/csw
        /opt)
    
    # find the SFML include directory
    find_path(SFML_INCLUDE_DIR SFML/Config.hpp
              PATH_SUFFIXES include
              PATHS ${FIND_SFML_PATHS})
    
    # check the version number
    set(SFML_VERSION_OK TRUE)
    if(SFML_FIND_VERSION AND SFML_INCLUDE_DIR)
        # extract the major and minor version numbers from SFML/Config.hpp
        # we have to handle framework a little bit differently:
        if("${SFML_INCLUDE_DIR}" MATCHES "SFML.framework")
            set(SFML_CONFIG_HPP_INPUT "${SFML_INCLUDE_DIR}/Headers/Config.hpp")
        else()
            set(SFML_CONFIG_HPP_INPUT "${SFML_INCLUDE_DIR}/SFML/Config.hpp")
        endif()
        FILE(READ "${SFML_CONFIG_HPP_INPUT}" SFML_CONFIG_HPP_CONTENTS)
        STRING(REGEX MATCH ".*#define SFML_VERSION_MAJOR ([0-9]+).*#define SFML_VERSION_MINOR ([0-9]+).*#define SFML_VERSION_PATCH ([0-9]+).*" SFML_CONFIG_HPP_CONTENTS "${SFML_CONFIG_HPP_CONTENTS}")
        STRING(REGEX REPLACE ".*#define SFML_VERSION_MAJOR ([0-9]+).*" "\\1" SFML_VERSION_MAJOR "${SFML_CONFIG_HPP_CONTENTS}")
        STRING(REGEX REPLACE ".*#define SFML_VERSION_MINOR ([0-9]+).*" "\\1" SFML_VERSION_MINOR "${SFML_CONFIG_HPP_CONTENTS}")
        STRING(REGEX REPLACE ".*#define SFML_VERSION_PATCH ([0-9]+).*" "\\1" SFML_VERSION_PATCH "${SFML_CONFIG_HPP_CONTENTS}")
        math(EXPR SFML_REQUESTED_VERSION "${SFML_FIND_VERSION_MAJOR} * 10000 + ${SFML_FIND_VERSION_MINOR} * 100 + ${SFML_FIND_VERSION_PATCH}")
    
        # if we could extract them, compare with the requested version number
        if (SFML_VERSION_MAJOR)
            # transform version numbers to an integer
            math(EXPR SFML_VERSION "${SFML_VERSION_MAJOR} * 10000 + ${SFML_VERSION_MINOR} * 100 + ${SFML_VERSION_PATCH}")
    
            # compare them
            if(SFML_VERSION LESS SFML_REQUESTED_VERSION)
                set(SFML_VERSION_OK FALSE)
            endif()
        else()
            # SFML version is < 2.0
            if (SFML_REQUESTED_VERSION GREATER 10900)
                set(SFML_VERSION_OK FALSE)
                set(SFML_VERSION_MAJOR 1)
                set(SFML_VERSION_MINOR x)
                set(SFML_VERSION_PATCH x)
            endif()
        endif()
    endif()
    
    # find the requested modules
    set(SFML_FOUND TRUE) # will be set to false if one of the required modules is not found
    foreach(FIND_SFML_COMPONENT ${SFML_FIND_COMPONENTS})
        string(TOLOWER ${FIND_SFML_COMPONENT} FIND_SFML_COMPONENT_LOWER)
        string(TOUPPER ${FIND_SFML_COMPONENT} FIND_SFML_COMPONENT_UPPER)
        set(FIND_SFML_COMPONENT_NAME sfml-${FIND_SFML_COMPONENT_LOWER})
    
        # no suffix for sfml-main, it is always a static library
        if(FIND_SFML_COMPONENT_LOWER STREQUAL "main")
            # release library
            find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE
                         NAMES ${FIND_SFML_COMPONENT_NAME}
                         PATH_SUFFIXES lib64 lib
                         PATHS ${FIND_SFML_PATHS})
    
            # debug library
            find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG
                         NAMES ${FIND_SFML_COMPONENT_NAME}-d
                         PATH_SUFFIXES lib64 lib
                         PATHS ${FIND_SFML_PATHS})
        else()
            # static release library
            find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_RELEASE
                         NAMES ${FIND_SFML_COMPONENT_NAME}-s
                         PATH_SUFFIXES lib64 lib
                         PATHS ${FIND_SFML_PATHS})
    
            # static debug library
            find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_DEBUG
                         NAMES ${FIND_SFML_COMPONENT_NAME}-s-d
                         PATH_SUFFIXES lib64 lib
                         PATHS ${FIND_SFML_PATHS})
    
            # dynamic release library
            find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_RELEASE
                         NAMES ${FIND_SFML_COMPONENT_NAME}
                         PATH_SUFFIXES lib64 lib
                         PATHS ${FIND_SFML_PATHS})
    
            # dynamic debug library
            find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_DEBUG
                         NAMES ${FIND_SFML_COMPONENT_NAME}-d
                         PATH_SUFFIXES lib64 lib
                         PATHS ${FIND_SFML_PATHS})
    
            # choose the entries that fit the requested link type
            if(SFML_STATIC_LIBRARIES)
                if(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_RELEASE)
                    set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_RELEASE})
                endif()
                if(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_DEBUG)
                    set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_DEBUG})
                endif()
            else()
                if(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_RELEASE)
                    set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_RELEASE})
                endif()
                if(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_DEBUG)
                    set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_DEBUG})
                endif()
            endif()
        endif()
    
        if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG OR SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE)
            # library found
            set(SFML_${FIND_SFML_COMPONENT_UPPER}_FOUND TRUE)
            
            # if both are found, set SFML_XXX_LIBRARY to contain both
            if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG AND SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE)
                set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY debug     ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG}
                                                              optimized ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE})
            endif()
    
            # if only one debug/release variant is found, set the other to be equal to the found one
            if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG AND NOT SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE)
                # debug and not release
                set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG})
                set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY         ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG})
            endif()
            if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE AND NOT SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG)
                # release and not debug
                set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE})
                set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY       ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE})
            endif()
        else()
            # library not found
            set(SFML_FOUND FALSE)
            set(SFML_${FIND_SFML_COMPONENT_UPPER}_FOUND FALSE)
            set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY "")
            set(FIND_SFML_MISSING "${FIND_SFML_MISSING} SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY")
        endif()
    
        # mark as advanced
        MARK_AS_ADVANCED(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY
                         SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE
                         SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG
                         SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_RELEASE
                         SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_DEBUG
                         SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_RELEASE
                         SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_DEBUG)
    
        # add to the global list of libraries
        set(SFML_LIBRARIES ${SFML_LIBRARIES} "${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY}")
    endforeach()
    
    # in case of static linking, we must also define the list of all the dependencies of SFML libraries
    if(SFML_STATIC_LIBRARIES)
    
        # detect the OS
        if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
            set(FIND_SFML_OS_WINDOWS 1)
        elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
            set(FIND_SFML_OS_LINUX 1)
        elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
            set(FIND_SFML_OS_FREEBSD 1)
        elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
            set(FIND_SFML_OS_MACOSX 1)
        endif()
    
        # start with an empty list
        set(SFML_DEPENDENCIES)
        set(FIND_SFML_DEPENDENCIES_NOTFOUND)
    
        # macro that searches for a 3rd-party library
        macro(find_sfml_dependency output friendlyname)
            find_library(${output} NAMES ${ARGN} PATHS ${FIND_SFML_PATHS} PATH_SUFFIXES lib)
            if(${${output}} STREQUAL "${output}-NOTFOUND")
                unset(output)
                set(FIND_SFML_DEPENDENCIES_NOTFOUND "${FIND_SFML_DEPENDENCIES_NOTFOUND} ${friendlyname}")
            endif()
        endmacro()
    
        # sfml-system
        list(FIND SFML_FIND_COMPONENTS "system" FIND_SFML_SYSTEM_COMPONENT)
        if(NOT ${FIND_SFML_SYSTEM_COMPONENT} EQUAL -1)
    
            # update the list -- these are only system libraries, no need to find them
            if(FIND_SFML_OS_LINUX OR FIND_SFML_OS_FREEBSD OR FIND_SFML_OS_MACOSX)
                set(SFML_SYSTEM_DEPENDENCIES "pthread")
            endif()
            if(FIND_SFML_OS_LINUX)
                set(SFML_SYSTEM_DEPENDENCIES "rt")
            endif()
            if(FIND_SFML_OS_WINDOWS)
                set(SFML_SYSTEM_DEPENDENCIES "winmm")
            endif()
            set(SFML_DEPENDENCIES ${SFML_SYSTEM_DEPENDENCIES} ${SFML_DEPENDENCIES})
        endif()
    
        # sfml-network
        list(FIND SFML_FIND_COMPONENTS "network" FIND_SFML_NETWORK_COMPONENT)
        if(NOT ${FIND_SFML_NETWORK_COMPONENT} EQUAL -1)
    
            # update the list -- these are only system libraries, no need to find them
            if(FIND_SFML_OS_WINDOWS)
                set(SFML_NETWORK_DEPENDENCIES "ws2_32")
            endif()
            set(SFML_DEPENDENCIES ${SFML_NETWORK_DEPENDENCIES} ${SFML_DEPENDENCIES})
        endif()
    
        # sfml-window
        list(FIND SFML_FIND_COMPONENTS "window" FIND_SFML_WINDOW_COMPONENT)
        if(NOT ${FIND_SFML_WINDOW_COMPONENT} EQUAL -1)
    
            # find libraries
            if(FIND_SFML_OS_LINUX)
                find_sfml_dependency(X11_LIBRARY "X11" X11)
                find_sfml_dependency(XRANDR_LIBRARY "Xrandr" Xrandr)
                find_sfml_dependency(UDEV_LIBRARIES "UDev" udev)
            endif()
    
            # update the list
            if(FIND_SFML_OS_WINDOWS)
                set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "opengl32" "winmm" "gdi32")
            elseif(FIND_SFML_OS_LINUX OR FIND_SFML_OS_FREEBSD)
                set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "GL" ${X11_LIBRARY} ${XRANDR_LIBRARY})
                if(FIND_SFML_OS_FREEBSD)
                    set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "usbhid")
                else()
                    set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} ${UDEV_LIBRARIES})
                endif()
            elseif(FIND_SFML_OS_MACOSX)
                set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "-framework OpenGL -framework Foundation -framework AppKit -framework IOKit -framework Carbon")
            endif()
            set(SFML_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} ${SFML_DEPENDENCIES})
        endif()
    
        # sfml-graphics
        list(FIND SFML_FIND_COMPONENTS "graphics" FIND_SFML_GRAPHICS_COMPONENT)
        if(NOT ${FIND_SFML_GRAPHICS_COMPONENT} EQUAL -1)
        
            # find libraries
            find_sfml_dependency(FREETYPE_LIBRARY "FreeType" freetype)
            find_sfml_dependency(GLEW_LIBRARY "GLEW" glew GLEW glew32 glew32s glew64 glew64s)
            find_sfml_dependency(JPEG_LIBRARY "libjpeg" jpeg)
    
            # update the list
            set(SFML_GRAPHICS_DEPENDENCIES ${FREETYPE_LIBRARY} ${GLEW_LIBRARY} ${JPEG_LIBRARY})
            set(SFML_DEPENDENCIES ${SFML_GRAPHICS_DEPENDENCIES} ${SFML_DEPENDENCIES})
        endif()
    
        # sfml-audio
        list(FIND SFML_FIND_COMPONENTS "audio" FIND_SFML_AUDIO_COMPONENT)
        if(NOT ${FIND_SFML_AUDIO_COMPONENT} EQUAL -1)
    
            # find libraries
            find_sfml_dependency(OPENAL_LIBRARY "OpenAL" openal openal32)
            find_sfml_dependency(SNDFILE_LIBRARY "libsndfile" sndfile)
    
            # update the list
            set(SFML_AUDIO_DEPENDENCIES ${OPENAL_LIBRARY} ${SNDFILE_LIBRARY})
            set(SFML_DEPENDENCIES ${SFML_AUDIO_DEPENDENCIES} ${SFML_DEPENDENCIES})
        endif()
    
    endif()
    
    # handle errors
    if(NOT SFML_VERSION_OK)
        # SFML version not ok
        set(FIND_SFML_ERROR "SFML found but version too low (requested: ${SFML_FIND_VERSION}, found: ${SFML_VERSION_MAJOR}.${SFML_VERSION_MINOR}.${SFML_VERSION_PATCH})")
        set(SFML_FOUND FALSE)
    elseif(SFML_STATIC_LIBRARIES AND FIND_SFML_DEPENDENCIES_NOTFOUND)
        set(FIND_SFML_ERROR "SFML found but some of its dependencies are missing (${FIND_SFML_DEPENDENCIES_NOTFOUND})")
        set(SFML_FOUND FALSE)
    elseif(NOT SFML_FOUND)
        # include directory or library not found
        set(FIND_SFML_ERROR "Could NOT find SFML (missing: ${FIND_SFML_MISSING})")
    endif()
    if (NOT SFML_FOUND)
        if(SFML_FIND_REQUIRED)
            # fatal error
            message(FATAL_ERROR ${FIND_SFML_ERROR})
        elseif(NOT SFML_FIND_QUIETLY)
            # error but continue
            message("${FIND_SFML_ERROR}")
        endif()
    endif()
    
    # handle success
    if(SFML_FOUND)
        message(STATUS "Found SFML ${SFML_VERSION_MAJOR}.${SFML_VERSION_MINOR}.${SFML_VERSION_PATCH} in ${SFML_INCLUDE_DIR}")
    endif()
    

    /home/sk/CLionProjects/AstraExample/CMakeLists.txt

    cmake_minimum_required(VERSION 3.14)
    project(AstraExample)
    
    ## ------------------------------------------------------------------------ 1 配置输出目录,cmake查找目录,以及其他配置
    # 执行cmake版本号
    set(CMAKE_CXX_STANDARD 14)
    
    # 创建一个变量OUTPUT_DIRECTORY_ROOT,指向当前目录的build子目录
    set(OUTPUT_DIRECTORY_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/build)
    
    # 设置cmake输出的可执行程序目录为./build/bin, 依赖库so输出的目录为./build/lib
    SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${OUTPUT_DIRECTORY_ROOT}/bin")
    SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${OUTPUT_DIRECTORY_ROOT}/lib")
    SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${OUTPUT_DIRECTORY_ROOT}/lib")
    
    set(ASTRA_64 ON)
    set(ASTRA_UNIX TRUE)
    
    # 获取当前目录下的common子目录的绝对路径保存到SAMPLE_COMMON_DIR
    get_filename_component(SAMPLE_COMMON_DIR "./common" ABSOLUTE)
    # 根据自己的需要,定义一个路径,是当前源码的3rdparty子目录
    set(PREBUILT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty) # /home/ty/Lesson/PCL/day07/Code/AstraExample/3rdparty
    # 给原来的CMAKE查找路径追加一个新的路径
    set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
    
    ## ------------------------------------------------------------------------ 2 查找头文件和库文件目录
    #find_package
    #include_directories
    #link_directories
    
    # a.引入其他cmake
    find_package(Astra REQUIRED) # FindXXX.cmake XXXConfig.cmake
    find_package(SFML COMPONENTS graphics window system)
    find_package(OpenCV REQUIRED)
    
    # b.添加Astra的头文件依赖目录
    include_directories(${CMAKE_CURRENT_SOURCE_DIR}/common)
    include_directories(${ASTRA_INCLUDE_DIRS})
    include_directories(${SFML_INCLUDE_DIR})
    include_directories(${OpenCV_INCLUDE_DIRS})
    
    # c.添加so库的搜索目录 (如果so被安装到系统库/usr/local/lib, /usr/lib,此条可省略)
    link_directories(${ASTRA_LINK_DIRS})
    
    add_subdirectory(src/cpp-api)
    add_subdirectory(src/sfml)
    add_subdirectory(src/camera)
    
    # 添加可执行程序AstraExample
    add_executable(AstraExample main.cpp)
    

    相机标定 保存图片,实时计算内参文件

    /home/sk/CLionProjects/AstraExample/src/cpp-api/AstraCalibration.cpp  

    /**
     * @Author: PoplarTang
     * @CreateTime: 2019-12-16
     * @Description:
     * 相机标定
     */
    #include "AstraCamera.h"
    #include <opencv2/opencv.hpp>
    
    const int ACTION_ESC = 27;
    const int ACTION_SPACE = 32;
    
    int board_width = 6;
    int board_height = 9;
    Size board_sz = cv::Size(board_width, board_height);
    float square_size = 20;
    bool flipHorizontal = true;
    const TermCriteria &criteria = TermCriteria(TermCriteria::EPS + TermCriteria::COUNT, 30, 0.1);
    
    AstraCamera* astraCamera;
    
    int num_boards = 20;
    vector<vector<Point2f>> image_points;
    Size image_size;
    double lastTick;
    
    void handle_image_data(cv::Mat &image, cv::Mat &depth){
    
        image_size = image.size();
    
        if (flipHorizontal) {
            flip(image, image, 1);
        }
    
        Mat rgb;
        image.copyTo(rgb);
    
        vector<Point2f> corners;
        bool found = findChessboardCorners(rgb, board_sz, corners,
                CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE + CALIB_CB_FAST_CHECK);
    
        if (found) {
            Mat imageGray;
            cvtColor(rgb, imageGray, COLOR_BGR2GRAY);
            cornerSubPix(imageGray, corners, Size(11, 11), Size(-1, -1), criteria);
        }
    
        drawChessboardCorners(rgb, board_sz, corners, found);
    
    
        double duration = ((double)getTickCount() - lastTick) / getTickFrequency();
    
    
        int key = cv::waitKey(30) & 0xFF;
    
        if (key == ACTION_ESC || key == 'q') {
            astraCamera->release();
            cv::destroyAllWindows();
        } else if (key == ACTION_SPACE || duration > 2) {
    
            if (found) {
    
                std::cout << "------------------- 保存图片和关节" << std::endl;
                // 保存图片
                stringstream ss;
                ss << "./images/image_" << (int) image_points.size() << ".jpg";
                bool rst = imwrite(ss.str(), image, (vector<int>) {CV_IMWRITE_JPEG_QUALITY, 100});
    
                // 保存角点
                image_points.push_back(corners);
    
                // 闪屏
                bitwise_not(rgb, rgb);
    
                if (rst) {
                    printf("%s: %d/%d \n", "save角点", (int)image_points.size(), num_boards);
    
                    lastTick = static_cast<double>(getTickCount());
                }else {
                    printf("保存失败,请检查图片输出目录是否存在\n");
                }
            }else {
                std::cout << "未发现角点" << std::endl;
            }
    
            if (image_points.size() >= num_boards) {
                std::cout << "当前数量已足够: " << image_points.size()
                << " 按Ctrl+C停止采集并开始计算内参。" << std::endl;
            }
        }
    
        cv::imshow("rgb", rgb);
        cv::imshow("depth", depth / 4500);
    }
    
    
    void
    saveParams(const vector<vector<Point2f>> &image_points, const Size &image_size, const Size &board_sz, float square_size,
               double rms, const Mat &cameraMatrix, const Mat &distCoeffs) {// 时间、图片个数、图片尺寸、标定板宽高、标定板块尺寸、RMS
    // 标定参数、畸变参数
    
        // 获取当前时间
        time_t tm;
        time(&tm);
        struct tm *t2 = localtime(&tm);
        char buf[1024];
        strftime(buf, sizeof(buf), "%c", t2);
    
        // 写出数据
    //        String outputInCailFilePath = "./calibration_in_params.xml";
        String inCailFilePath = "./calibration_in_params.yml";
        FileStorage inCailFs(inCailFilePath, FileStorage::WRITE);
        inCailFs << "calibration_time" << buf;
        inCailFs << "frame_count" << (int) image_points.size();
        inCailFs << "image_width" << image_size.width;
        inCailFs << "image_height" << image_size.height;
        inCailFs << "board_width" << board_sz.width;
        inCailFs << "board_height" << board_sz.height;
        inCailFs << "square_size" << square_size;
        inCailFs << "rms" << rms;
    
        inCailFs << "cameraMatrix" << cameraMatrix;
        inCailFs << "distCoeffs" << distCoeffs; // distortion_coefficients
        inCailFs.release();
        cout << "标定结果已保存:" << inCailFilePath << endl;
    }
    
    /**
     * 执行标定并保存标定结果
     * @param square_size   格子尺寸
     * @param board_sz      格子尺寸Size
     * @param image_size    图片尺寸Size
     * @param image_points  图片角点集合
     * @param cameraMatrix  相机参数
     * @param distCoeffs    畸变参数
     */
    void
    runAndSave(float square_size, const Size &board_sz, const Size &image_size,
               const vector<vector<Point2f>> &image_points,
               Mat &cameraMatrix, Mat &distCoeffs) {
        vector<vector<Point3f>> object_points;
        vector<Point3f> objPoints;
        for (int i = 0; i < board_sz.height; ++i) {
            for (int j = 0; j < board_sz.width; ++j) {
                objPoints.emplace_back(float(j * square_size), float(i * square_size), 0);
            }
        }
        /*
         * [
         *      [0, 0], [1, 0], [2, 0], [3, 0],
         *      [0, 1], [1, 1], [2, 1], [3, 1],
         *      [0, 2], [1, 2], [2, 2], [3, 2],
         * ]
         */
        object_points.resize(image_points.size(), objPoints);
        vector<Mat> rvecs, tvecs;
    
        // 执行标定
        double rms = calibrateCamera(object_points, image_points, image_size, cameraMatrix, distCoeffs, rvecs, tvecs);
    
        // 均方根值(RMS 数据平方的平均值的平方根)
        printf("RMS error reported by calibrateCamera: %g\n", rms);
        // 检查标定结果误差
        bool ok = checkRange(cameraMatrix) && checkRange(distCoeffs);
    
        if (ok) {
            cout << "标定参数:" << endl;
            cout << cameraMatrix << endl;
    
            cout << "畸变参数:" << endl;
            cout << distCoeffs << endl;
    
            saveParams(image_points, image_size, board_sz, square_size, rms, cameraMatrix, distCoeffs);
    
        } else {
            std::cout << "标定结果有误,请重新标定!" << std::endl;
        }
    }
    
    
    //astraCamera->setListener([&](cv::Mat& rgb, cv::Mat& depth){
    //cv::imshow("rgb", rgb);
    //cv::imshow("depth", depth / 4500);
    //cv::waitKey(50);
    //});
    
    int main(int argc, char **argv) {
        astraCamera = new AstraCamera();
        astraCamera->setListener(&handle_image_data);
    
    //    std::cout << "------------------1" << std::endl;
        astraCamera->start();
    //    std::cout << "------------------2" << std::endl;
    
    
        Mat cameraMatrix = Mat::eye(3, 3, CV_64F);
        Mat distCoeffs = Mat::zeros(8, 1, CV_64F);
    
        runAndSave(square_size, board_sz, image_size, image_points, cameraMatrix, distCoeffs);
    
        return 0;
    }
    

    相机标定 通过保存的图片生成内参文件

    /home/sk/CLionProjects/AstraExample/src/cpp-api/CameraIntrinsicCalibrationFromFiles.cpp

    //
    // Created by ty on 19-10-17.
    //
    #include <iostream>
    #include <opencv2/opencv.hpp>
    
    using namespace std;
    using namespace cv;
    
    const int ACTION_ESC = 27;
    const int ACTION_SPACE = 32;
    
    static void print_help() {
        printf("通过棋盘格标定相机内参\n");
        printf("参数:CalibrationChessboard <board_width> <board_height> <square_size> [number_of_boards] "
               "[--delay=<delay>] [-s=<scale_factor>]\n");
        printf("例子:CalibrationChessboard 6 9 20 35 -d=500 -s=1.0 -f\n");
    }
    
    const TermCriteria &criteria = TermCriteria(TermCriteria::EPS + TermCriteria::COUNT, 30, 0.1);
    // 写出数据
    //        String outputInCailFilePath = "./calibration_in_params.xml";
    const cv::String outputInCailFilePath = "./calibration_in_params_hand_in_eye.yml";
    const cv::String src_path = "./images/image_*.jpg";
    
    void
    saveParams(const vector<vector<Point2f>> &image_points,
               const Size &image_size, const Size &board_sz, float square_size,
               double rms, const Mat &cameraMatrix, const Mat &distCoeffs) {// 时间、图片个数、图片尺寸、标定板宽高、标定板块尺寸、RMS
    // 标定参数、畸变参数
    
        // 获取当前时间
        time_t tm;
        time(&tm);
        struct tm *t2 = localtime(&tm);
        char buf[1024];
        strftime(buf, sizeof(buf), "%c", t2);
    
        FileStorage inCailFs(outputInCailFilePath, FileStorage::WRITE);
        inCailFs << "calibration_time" << buf;
        inCailFs << "frame_count" << (int) image_points.size();
        inCailFs << "image_width" << image_size.width;
        inCailFs << "image_height" << image_size.height;
        inCailFs << "board_width" << board_sz.width;
        inCailFs << "board_height" << board_sz.height;
        inCailFs << "square_size" << square_size;
        inCailFs << "rms" << rms;
    
        inCailFs << "cameraMatrix" << cameraMatrix;
        inCailFs << "distCoeffs" << distCoeffs; // distortion_coefficients
        inCailFs.release();
        cout << "标定结果已保存:" << outputInCailFilePath << endl;
    }
    
    /**
     * 执行标定并保存标定结果
     * @param square_size   格子尺寸
     * @param board_sz      格子尺寸Size
     * @param image_size    图片尺寸Size
     * @param image_points  图片角点集合
     * @param cameraMatrix  相机参数
     * @param distCoeffs    畸变参数
     */
    void
    runAndSave(float square_size, const Size &board_sz, const Size &image_size,
               const vector<vector<Point2f>> &image_points,
               Mat &cameraMatrix, Mat &distCoeffs) {
        vector<vector<Point3f>> object_points;
        vector<Point3f> objPoints;
        for (int i = 0; i < board_sz.height; ++i) {
            for (int j = 0; j < board_sz.width; ++j) {
                objPoints.emplace_back(float(j * square_size), float(i * square_size), 0);
            }
        }
        /*
         * [
         *      [0, 0], [1, 0], [2, 0], [3, 0],
         *      [0, 1], [1, 1], [2, 1], [3, 1],
         *      [0, 2], [1, 2], [2, 2], [3, 2],
         * ]
         */
        object_points.resize(image_points.size(), objPoints);
        vector<Mat> rvecs, tvecs;
    
        // 执行标定
        double rms = calibrateCamera(object_points, image_points, image_size,
                cameraMatrix, distCoeffs, rvecs, tvecs);
    
    //             , CV_CALIB_ZERO_TANGENT_DIST + CV_CALIB_FIX_K1 + CV_CALIB_FIX_K2 + CV_CALIB_FIX_K3
    //             , CV_CALIB_FIX_PRINCIPAL_POINT +
    
        // 均方根值(RMS 数据平方的平均值的平方根)
        printf("RMS error reported by calibrateCamera: %g\n", rms);
        // 检查标定结果误差
        bool ok = checkRange(cameraMatrix) && checkRange(distCoeffs);
    
        if (ok) {
            cout << "标定参数:" << endl;
            cout << cameraMatrix << endl;
    
            cout << "畸变参数:" << endl;
            cout << distCoeffs << endl;
    
            saveParams(image_points, image_size, board_sz, square_size, rms, cameraMatrix, distCoeffs);
    
        } else {
            std::cout << "标定结果有误,请重新标定!" << std::endl;
        }
    }
    
    
    int main(int argc, char **argv) {
        std::cout << cv::getVersionString() << std::endl;
    
    
        cv::Size board_sz = cv::Size(6, 9);
        const int square_size = 20;
        cv::Size image_size;
    
        vector<vector<Point3f>> objectPoints;
        vector<vector<Point2f>> cornerPoints;
    
        std::vector<String> filenames;
        cv::glob(src_path, filenames);//获取路径下所有文件名
        cout << "filenames.size:" << filenames.size() << endl;
    
        int index = 0;
        for (auto& imgName : filenames) {
            Mat image = imread(imgName, IMREAD_UNCHANGED);
    
            Mat imageGray;
    //        img.copyTo(image);
    
            image_size = image.size();
            std::cout << "name: " << imgName<< " imgSize: " << image_size << std::endl;
    
    //        imshow("img", image);
    
            // 查找标定板
            vector<Point2f> corners;
            bool found = findChessboardCorners(image, board_sz, corners,
                                               CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE + CALIB_CB_FAST_CHECK);
    
            if (found) {
                // 提高角点坐标的精确度
                cvtColor(image, imageGray, COLOR_BGR2GRAY);
                cornerSubPix(imageGray, corners, Size(11, 11), Size(-1, -1), criteria);
    
                cornerPoints.push_back(corners);
            }else {
                std::cout << "未发现角点: " << imgName << std::endl;
            }
    //        waitKey(0);
    
            index ++;
        }
    
    
    
        printf("角点收集完毕, 执行标定中... 图片尺寸 %d:%d\n", image_size.width, image_size.height);
    
        Mat cameraMatrix = Mat::eye(3, 3, CV_64F);
        Mat distCoeffs = Mat::zeros(8, 1, CV_64F);
    
        // 保存标定参数到文件
        runAndSave(square_size, board_sz, image_size, cornerPoints, cameraMatrix, distCoeffs);
    
    
    
        return 0;
    }

     

    获取颜色值

    /home/sk/CLionProjects/AstraExample/src/cpp-api/ColorReaderEventCPP

    // This file is part of the Orbbec Astra SDK [https://orbbec3d.com]
    // Copyright (c) 2015-2017 Orbbec 3D
    //
    // Licensed under the Apache License, Version 2.0 (the "License");
    // you may not use this file except in compliance with the License.
    // You may obtain a copy of the License at
    //
    // http://www.apache.org/licenses/LICENSE-2.0
    //
    // Unless required by applicable law or agreed to in writing, software
    // distributed under the License is distributed on an "AS IS" BASIS,
    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    // See the License for the specific language governing permissions and
    // limitations under the License.
    //
    // Be excellent to each other.
    #include <astra/astra.hpp>
    #include <cstdio>
    #include <iostream>
    #include <key_handler.h>
    
    class SampleFrameListener : public astra::FrameListener
    {
    private:
        using buffer_ptr = std::unique_ptr<astra::RgbPixel []>;
        buffer_ptr buffer_;
        unsigned int lastWidth_;
        unsigned int lastHeight_;
    
    public:
        virtual void on_frame_ready(astra::StreamReader& reader,
                                    astra::Frame& frame) override
        {
            const astra::ColorFrame colorFrame = frame.get<astra::ColorFrame>();
    
            if (colorFrame.is_valid())
            {
                print_color(colorFrame);
            }
        }
    
        void print_color(const astra::ColorFrame& colorFrame)
        {
            if (colorFrame.is_valid())
            {
                int width = colorFrame.width();
                int height = colorFrame.height();
                int frameIndex = colorFrame.frame_index();
    
                if (width != lastWidth_ || height != lastHeight_){
                    buffer_ = buffer_ptr(new astra::RgbPixel[colorFrame.length()]);
                    lastWidth_ = width;
                    lastHeight_ = height;
                }
                colorFrame.copy_to(buffer_.get());
    
                size_t index = ((width * (height / 2.0f)) + (width / 2.0f));
                astra::RgbPixel middle = buffer_[index];
    
                std::cout << "color frameIndex: " << frameIndex
                          << " r: " << static_cast<int>(middle.r)
                          << " g: " << static_cast<int>(middle.g)
                          << " b: " << static_cast<int>(middle.b)
                          << std::endl;
            }
        }
    };
    
    int main(int argc, char** argv)
    {
        astra::initialize();
    
        set_key_handler();
    
        astra::StreamSet streamSet;
        astra::StreamReader reader = streamSet.create_reader();
    
        SampleFrameListener listener;
    
        reader.stream<astra::ColorStream>().start();
    
        std::cout << "colorStream -- hFov: "
                  << reader.stream<astra::ColorStream>().hFov()
                  << " vFov: "
                  << reader.stream<astra::ColorStream>().vFov()
                  << std::endl;
    
        reader.add_listener(listener);
    
        do
        {
            astra_update();
        } while (shouldContinue);
    
        reader.remove_listener(listener);
    
        astra::terminate();
    }

     

    获取深度值

    /home/sk/CLionProjects/AstraExample/src/cpp-api/DepthReaderEventCPP

    // This file is part of the Orbbec Astra SDK [https://orbbec3d.com]
    // Copyright (c) 2015-2017 Orbbec 3D
    //
    // Licensed under the Apache License, Version 2.0 (the "License");
    // you may not use this file except in compliance with the License.
    // You may obtain a copy of the License at
    //
    // http://www.apache.org/licenses/LICENSE-2.0
    //
    // Unless required by applicable law or agreed to in writing, software
    // distributed under the License is distributed on an "AS IS" BASIS,
    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    // See the License for the specific language governing permissions and
    // limitations under the License.
    //
    // Be excellent to each other.
    #include <astra/astra.hpp>
    #include <cstdio>
    #include <chrono>
    #include <iostream>
    #include <iomanip>
    #include <key_handler.h>
    
    class SampleFrameListener : public astra::FrameListener
    {
    private:
        using buffer_ptr = std::unique_ptr<int16_t []>;
        buffer_ptr buffer_;
        unsigned int lastWidth_;
        unsigned int lastHeight_;
    
    public:
        virtual void on_frame_ready(astra::StreamReader& reader,
                                    astra::Frame& frame) override
        {
            const astra::DepthFrame depthFrame = frame.get<astra::DepthFrame>();
    
            if (depthFrame.is_valid())
            {
                auto depthStream = reader.stream<astra::DepthStream>();
                print_depth(depthFrame, depthStream.coordinateMapper());
                check_fps();
            }
        }
    
        void print_depth(const astra::DepthFrame& depthFrame,
                         const astra::CoordinateMapper& mapper)
        {
            if (depthFrame.is_valid())
            {
                int width = depthFrame.width();
                int height = depthFrame.height();
                int frameIndex = depthFrame.frame_index();
    
                //determine if buffer needs to be reallocated
                if (width != lastWidth_ || height != lastHeight_)
                {
                    buffer_ = buffer_ptr(new int16_t[depthFrame.length()]);
                    lastWidth_ = width;
                    lastHeight_ = height;
                }
                depthFrame.copy_to(buffer_.get());
    
                size_t index = ((width * (height / 2.0f)) + (width / 2.0f));
                short middle = buffer_[index];
    
                float worldX, worldY, worldZ;
                float depthX, depthY, depthZ;
                mapper.convert_depth_to_world(width / 2.0f, height / 2.0f, middle, worldX, worldY, worldZ);
                mapper.convert_world_to_depth(worldX, worldY, worldZ, depthX, depthY, depthZ);
    
                std::cout << "depth frameIndex: " << frameIndex
                          << " value: " << middle
                          << " wX: " << worldX
                          << " wY: " << worldY
                          << " wZ: " << worldZ
                          << " dX: " << depthX
                          << " dY: " << depthY
                          << " dZ: " << depthZ
                          << std::endl;
            }
        }
    
        void check_fps()
        {
            const float frameWeight = 0.5;
    
            auto newTimepoint = clock_type::now();
            float frameDuration = std::chrono::duration_cast<duration_type>(newTimepoint - lastTimepoint_).count();
    
            frameDuration_ = frameDuration * frameWeight + frameDuration_ * (1 - frameWeight);
            lastTimepoint_ = newTimepoint;
    
            double fps = 1.0 / frameDuration_;
    
            auto precision = std::cout.precision();
            std::cout << std::fixed
                      << std::setprecision(1)
                      << fps << " fps ("
                      << std::setprecision(2)
                      << frameDuration_ * 1000.0 << " ms)"
                      << std::setprecision(precision)
                      << std::endl;
        }
    
    private:
        using duration_type = std::chrono::duration<float>;
        float frameDuration_{ 0.0 };
    
        using clock_type = std::chrono::system_clock;
        std::chrono::time_point<clock_type> lastTimepoint_{clock_type::now()};
    };
    
    int main(int argc, char** argv)
    {
        astra::initialize();
    
        set_key_handler();
    
        astra::StreamSet streamSet;
        astra::StreamReader reader = streamSet.create_reader();
    
        SampleFrameListener listener;
    
        auto depthStream = reader.stream<astra::DepthStream>();
        depthStream.start();
    
        char serialnumber[256];
        depthStream.serial_number(serialnumber, 256);
    
        std::cout << "depthStream -- hFov: "
                  << reader.stream<astra::DepthStream>().hFov()
                  << " vFov: "
                  << reader.stream<astra::DepthStream>().vFov()
                  << " serial number: "
                  << serialnumber
                  << std::endl;
    
        const uint32_t chipId = depthStream.chip_id();
    
        switch (chipId)
        {
            case ASTRA_CHIP_ID_MX400:
                std::cout << "Chip ID: MX400" << std::endl;
                break;
            case ASTRA_CHIP_ID_MX6000:
                std::cout << "Chip ID: MX6000" << std::endl;
                break;
            case ASTRA_CHIP_ID_UNKNOWN:
            default:
                std::cout << "Chip ID: Unknown" << std::endl;
                break;
        }
    
    	const astra_usb_info_t usbinfo = depthStream.usb_info();
    
    	std::cout << "usbInfo ---pid:" << usbinfo.pid<<" vid: "<< usbinfo.vid<< std::endl;
    
    
        reader.add_listener(listener);
    
        do
        {
            astra_update();
        } while (shouldContinue);
    
        reader.remove_listener(listener);
    
        astra::terminate();
    }
    

    ----------------------------------------------------------------------------------------------------------------------------------------------------------

    Astra奥比中光相机获取深度图及彩色图

    /home/sk/CLionProjects/AstraExample/src/camera/AstraCamera.cpp

    //
    // Created by ty on 20-7-2.
    //
    
    #include "AstraCamera.h"
    #include <key_handler.h>
    
    AstraCamera::AstraCamera() {
    
    }
    function<void(cv::Mat &, cv::Mat &)> astra_data_callback;
    
    class SampleFrameListener : public astra::FrameListener {
    private:
        using buffer_ptr = std::unique_ptr<astra::RgbPixel[]>;
        using buffer_depth_ptr = std::unique_ptr<int16_t[]>;
        buffer_ptr buffer_;
        buffer_depth_ptr buffer_depth_;
        int lastWidth_{};
        int lastHeight_{};
        int lastWidth_depth_{};
        int lastHeight_depth_{};
    
    public:
    
        void on_frame_ready(astra::StreamReader &reader,
                            astra::Frame &frame) override {
            shared_ptr<cv::Mat> img = nullptr, depth = nullptr;
    
            const astra::ColorFrame colorFrame = frame.get<astra::ColorFrame>();
            get_color(colorFrame, img);
    
            const astra::DepthFrame depthFrame = frame.get<astra::DepthFrame>();
            auto depthStream = reader.stream<astra::DepthStream>();
            get_depth(depthFrame, depthStream.coordinateMapper(), depth);
    
            astra_data_callback(*img, *depth);
        }
    
        void get_color(const astra::ColorFrame &colorFrame, shared_ptr<cv::Mat> &img) {
    
            if (colorFrame.is_valid()) {
                int width = colorFrame.width();
                int height = colorFrame.height();
                // cout << "宽度:" << width << "---高度:" << height << endl;
    
                if (width != lastWidth_ || height != lastHeight_) {
                    buffer_ = buffer_ptr(new astra::RgbPixel[colorFrame.length()]);
                    lastWidth_ = width;
                    lastHeight_ = height;
                }
                colorFrame.copy_to(buffer_.get());
    
    //            int frameIndex = colorFrame.frame_index();
    //            size_t index = ((width * (height / 2.0f)) + (width / 2.0f));
    //            cout << "index为:" << index << endl;
    //            astra::RgbPixel middle = buffer_[index];
    
    //            std::cout << "color frameIndex: " << frameIndex
    //                      << " r: " << static_cast<int>(middle.r)
    //                      << " g: " << static_cast<int>(middle.g)
    //                      << " b: " << static_cast<int>(middle.b)
    //                      << " width: " << width << " height: " << height << std::endl;
    
                // 将buffer_ptr 中astra::RgbPixel[]数据类型转成Mat
    //            shared_ptr<cv::Mat> img = new shared_ptr<cv::Mat>(new cv::Mat(height, width, CV_8UC3, cv::Scalar::all(0)));
                img = std::make_shared<cv::Mat>(height, width, CV_8UC3, cv::Scalar::all(0));
                for (int i = 0; i < height; ++i) {
                    for (int j = 0; j < width; ++j) {
                        img->at<cv::Vec3b>(i, j)[0] = buffer_[i * width + j].b;
                        img->at<cv::Vec3b>(i, j)[1] = buffer_[i * width + j].g;
                        img->at<cv::Vec3b>(i, j)[2] = buffer_[i * width + j].r;
                    }
                }
    
            }
        }
    
        void get_depth(const astra::DepthFrame &depthFrame,
                       const astra::CoordinateMapper &mapper, shared_ptr<cv::Mat> &depthMat) {
            if (depthFrame.is_valid()) {
                int width = depthFrame.width();
                int height = depthFrame.height();
                int frameIndex = depthFrame.frame_index();
    
                //determine if buffer needs to be reallocated
                if (width != lastWidth_depth_ || height != lastHeight_depth_) {
                    buffer_depth_ = buffer_depth_ptr(new int16_t[depthFrame.length()]);
                    lastWidth_depth_ = width;
                    lastHeight_depth_ = height;
    
                }
                depthFrame.copy_to(buffer_depth_.get());
    
    //            float x = width / 2.0f + 10;
    //            float y = height / 2.0f + 10;
    //            size_t index = width * y + x;
    //            short middle = buffer_depth_[index];
    
    //            float worldX, worldY, worldZ;
    //            float depthX, depthY, depthZ;
    //            mapper.convert_depth_to_world(x, y, middle, worldX, worldY, worldZ);
    //            mapper.convert_depth_to_world(0, 0, middle, worldX, worldY, worldZ);
    //            mapper.convert_world_to_depth(worldX, worldY, worldZ, depthX, depthY, depthZ);
    
    
                // buffer_depth_ptr 中astra::int16_t[]数据类型转成Mat
                depthMat = std::make_shared<cv::Mat>(height, width, CV_32FC1, cv::Scalar::all(0));
                for (int i = 0; i < height; ++i) {
                    for (int j = 0; j < width; ++j) {
                        short depth = buffer_depth_[i * width + j];
                        if (fpclassify(depth) == FP_INFINITE || fpclassify(depth) == NAN) {
                            depth = 0;
                        }
                        depthMat->at<float>(i, j) = depth;
                    }
                }
    
            }
        }
    };
    
    SampleFrameListener listener;
    astra::StreamReader reader;
    
    int AstraCamera::start(bool getColor, bool getDepth) {
    
    
        //初始化库
        astra::initialize();
    
        set_key_handler();
        astra::StreamSet streamSet;
        reader = streamSet.create_reader();
    
        if (getColor) {
            // 配置并启动Color数据流
            astra::ColorStream colorStream = reader.stream<astra::ColorStream>();
            astra::ImageStreamMode colorMode;
            colorMode.set_width(1280);
            colorMode.set_height(720);
            colorMode.set_pixel_format(astra_pixel_formats::ASTRA_PIXEL_FORMAT_RGB888);
            colorMode.set_fps(30);
            colorStream.set_mode(colorMode);
            colorStream.start();
            std::cout << "colorStream -- hFov: " << colorStream.hFov() << " vFov: " << colorStream.vFov() << std::endl;
        }
    
    
        if (getDepth) {
            // 配置并启动Depth数据流
            auto depthStream = reader.stream<astra::DepthStream>();
            astra::ImageStreamMode depthMode;
            depthMode.set_width(640);
            depthMode.set_height(480);
            depthMode.set_pixel_format(astra_pixel_formats::ASTRA_PIXEL_FORMAT_DEPTH_MM);
            depthMode.set_fps(30);
            depthStream.set_mode(depthMode);
            depthStream.start();
    
            char serialnumber[256];
            depthStream.serial_number(serialnumber, 256);
    
            const astra_conversion_cache_t &data = depthStream.depth_to_world_data();
    
            //16082610454
            // conversion_data.xz: 1.12213 conversion_data.yz: 0.8416 conversion_data.hX: 320 conversion_data.hY: 240 - ty
            std::cout << "depthStream --"
                         " hFov: " << depthStream.hFov() << " vFov: " << depthStream.vFov() <<
                      " serial number: " << serialnumber <<
                      " serial number[0]: " << serialnumber[0] <<
                      " conversion_data.xz: " << data.xzFactor <<
                      " conversion_data.yz: " << data.yzFactor <<
                      " conversion_data.hX: " << data.halfResX <<
                      " conversion_data.hY: " << data.halfResY <<
                      std::endl;
    
        }
    
    
        //监听摄像头画面
        reader.add_listener(listener);
    
        // 循环更新数据
        do {
            astra_update();
        } while (shouldContinue);
    
        // 移除数据监听
        reader.remove_listener(listener);
        astra::terminate();
        return 0;
    }
    
    void AstraCamera::setListener(function<void(cv::Mat &, cv::Mat &)> lis) {
        astra_data_callback = lis;
    }
    
    void AstraCamera::release() {
        shouldContinue = false;
    }
    
    AstraCamera::~AstraCamera() {
        shouldContinue = false;
    }
    

    /home/sk/CLionProjects/AstraExample/src/camera/AstraCamera.h

    //
    // Created by ty on 20-7-2.
    //
    
    #ifndef CALIBRATIONHANDEYE_ASTRACAMERA_H
    #define CALIBRATIONHANDEYE_ASTRACAMERA_H
    
    #include <astra/astra.hpp>
    #include <cstdio>
    
    #include <iostream>
    #include <opencv2/core/core.hpp>
    #include <opencv2/highgui/highgui.hpp>
    #include <sstream>
    #include <cstdlib>
    
    using namespace std;
    using namespace cv;
    
    class AstraCamera {
    
    public:
        AstraCamera();
    
        virtual ~AstraCamera();
    
    public:
    
        virtual int start(bool getColor = true, bool getDepth = true);
    
        void setListener(function<void(cv::Mat&, cv::Mat&)>);
    
        virtual void release();
    
    };
    
    #endif //CALIBRATIONHANDEYE_ASTRACAMERA_H
    

    /home/sk/CLionProjects/AstraExample/src/camera/AstraMain.cpp

    
    #include "AstraCamera.h"
    
    const int ACTION_ESC = 27;
    const int ACTION_SPACE = 32;
    
    AstraCamera* astraCamera;
    
    void handle_image_data(cv::Mat &rgb, cv::Mat &depth){
        cv::imshow("rgb", rgb);
        cv::imshow("depth", depth / 4500);
    
        int key = cv::waitKey(30) & 0xFF;
    
        if (key == ACTION_ESC || key == 'q') {
            astraCamera->release();
            cv::destroyAllWindows();
    
        } else if (key == ACTION_SPACE) {
            std::cout << "------------------- 保存图片和关节" << std::endl;
        }
    }
    
    //astraCamera->setListener([&](cv::Mat& rgb, cv::Mat& depth){
    //cv::imshow("rgb", rgb);
    //cv::imshow("depth", depth / 4500);
    //cv::waitKey(50);
    //});
    
    int main(int argc, char **argv) {
        astraCamera = new AstraCamera();
        astraCamera->setListener(&handle_image_data);
        astraCamera->start();
        return 0;
    }
    

    /home/sk/CLionProjects/AstraExample/src/camera/CMakeLists.txt

    set(ASTRA_CAMERA_SOURCES AstraCamera.cpp AstraCamera.h)
    
    add_library(astra_camera ${ASTRA_CAMERA_SOURCES} )
    target_link_libraries(astra_camera ${ASTRA_LIBRARIES})
    
    add_executable(AstraMain AstraMain.cpp )
    target_link_libraries(AstraMain ${ASTRA_LIBRARIES} ${OpenCV_LIBS} astra_camera)
    

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    展开全文
  • 奥比中光3D体感摄像头 windows平台下的sdk和开发手册 ,深圳奥比中光科技有限公司。 支持win32 和 x64
  • 软件介绍: 奥比中光 orbbec astra 摄像头在windows系统下的驱动安装程序SensorDriver_V4.3.0.4.exe。Manual Installation Guide使用手册,及orbbec-sensor-driver-4.3.0.4-whql版驱动。
  • 说明书 奥比中光 RGBD传感器摄像头 大白 ORBBEC DaBai Datasheet _v1.4
  • Orbbec Astra Pro 设备调试 Demo使用奥比中光Astra Pro捕获深度图与彩色图代码 使用奥比中光Astra Pro捕获深度图与彩色图代码 #include <astra/astra.hpp> #include <opencv2/opencv.hpp> int main(int...

    使用奥比中光Astra Pro捕获深度图与彩色图代码

    #include <astra/astra.hpp>
    #include <opencv2/opencv.hpp>
    
    int main(int argc, char** argv)
    {
    	//初始化Astra SDK
    	astra::initialize();
    	astra::StreamSet streamset;
    	astra::StreamReader reader = streamset.create_reader();
    
    	//获取深度流
    	auto depthStream = reader.stream<astra::DepthStream>();
    
    	//配置深度流分辨率、格式和帧率
    	astra::ImageStreamMode depthMode;
    	depthMode.set_width(640);
    	depthMode.set_height(480);
    	depthMode.set_pixel_format(astra_pixel_formats::ASTRA_PIXEL_FORMAT_DEPTH_MM);
    	depthMode.set_fps(30);
    
    	//设置深度流模式并打开深度流
    	depthStream.set_mode(depthMode);
    	depthStream.start();
    
    	//获取彩色流
    	auto colorStream = reader.stream<astra::ColorStream>();
    
    	//配置彩色流的分辨率、格式和帧率
    	astra::ImageStreamMode colorMode;
    	colorMode.set_width(640);
    	colorMode.set_height(480);
    	colorMode.set_pixel_format(astra_pixel_formats::ASTRA_PIXEL_FORMAT_RGB888);
    	colorMode.set_fps(30);
    
    	//设置彩色流模式并打开彩色流
    
    	colorStream.set_mode(colorMode);
    	colorStream.start();
    
    	while (true)
    	{
    		//更新数据流
    		astra_update();
    		if (!reader.has_new_frame())
    		{
    			continue;
    		}
    		//获取最后一帧
    		auto frame = reader.get_latest_frame(100);
    
    		//获取深度帧数据
    		auto depthFrame = frame.get<astra::DepthFrame>();
    		auto depth = depthFrame.data();
    
    		//获取深度帧的宽高
    		auto depthWidth = depthFrame.width();
    		auto depthHeight = depthFrame.height();
    
    		//处理并渲染深度帧数据
    		if (depthFrame.is_valid())
    		{
    			cv::Mat rawMat(depthHeight, depthWidth, CV_16UC1, (void*)depth);
    			cv::Mat depthMat;
    			rawMat.convertTo(depthMat, CV_8UC1);
    
    			cv::imshow("Depth Viewer", depthMat);
    		}
    
    		//获取彩色帧数据
    		auto colorFrame = frame.get<astra::ColorFrame>();
    		auto color = colorFrame.data();
    
    		//获取彩色帧的宽高
    		auto colorWidth = colorFrame.width();
    		auto colorHeight = colorFrame.height();
    
    		//处理并渲染彩色帧数据
    		if (colorFrame.is_valid())
    		{
    			cv::Mat rawMat(colorHeight, colorWidth, CV_8UC3, (void*)color);
    			cv::Mat colorMat;
    			cv::cvtColor(rawMat, colorMat, cv::COLOR_BGR2RGB);
    			cv::imshow("Color Viewer", colorMat);
    		}
    
    		//按ESC退出
    		int key = cv::waitKey(100);
    		if (key == 27)
    			break;
    	}
    	//释放Astra SDK资源
    	astra::terminate();
    }
    

    在这里插入图片描述

    展开全文
  • 奥比中光网络深度摄像头——人脸活体检测

    千次阅读 热门讨论 2018-08-09 17:40:52
    最近一直在研发一个新的项目:基于深度摄像头的人脸活体识别,采用的是奥比中光的Astra Pro相机。 基于奥比中光的官方SDK进行开发 得到如下文件 1.第一步,在彩色图中添加OpenCV人脸检测代码,得到人脸框的位置...

            最近一直在研发一个新的项目:基于深度摄像头的人脸活体识别,采用的是奥比中光的Astra Pro相机。

    基于奥比中光官方SDK进行开发

    得到如下文件

    1.第一步,在彩色图中添加OpenCV人脸检测代码,得到人脸框的位置坐标

    2.第二步,根据人脸框的位置坐标对应到深度图中,标识出来(深度图和彩色图的大小一样,但是他们并没有对齐,这里只做效果)

    3.第三步,计算深度图中标识出来的人脸框中所有像素点的均值和标准差,真人的深度图像素标准查明显大于照片中的像素标准差,可以自己设置一个阈值。

    彩色图OpenCV人脸检测代码片段如下:

    //更新彩色流
    void update_color(astra::Frame& frame)
    {
    	const astra::ColorFrame colorFrame = frame.get<astra::ColorFrame>();
    	if (!colorFrame.is_valid())
    	{
    		clear_view(colorView_);
    		colorView_.texture_.update(&colorView_.buffer_[0]);			
    		return;
    	}
    	const int colorWidth = colorFrame.width();
    	const int colorHeight = colorFrame.height();
    	init_texture(colorWidth, colorHeight, colorView_);
    	if (isPaused_) { return; }
    	const astra::RgbPixel* color = colorFrame.data();
    	uint8_t* buffer = &colorView_.buffer_[0];
    
    	{
    		const astra::RgbPixel* colorT = color;
    		cv::Mat frame_copy(colorHeight, colorWidth, CV_8UC3);//定义Mat
    
    		for (int j = 0; j<colorHeight; j++)
    		{
    			for (int i = 0; i<colorWidth; i++)
    			{
    				frame_copy.at<cv::Vec3b>(j, i)[0] = colorT->b;//image.at<cv::Vec3b>(j, i)[0] / div * div + div / 2;
    				frame_copy.at<cv::Vec3b>(j, i)[1] = colorT->g;
    				frame_copy.at<cv::Vec3b>(j, i)[2] = colorT->r;
    				colorT++;
    			}
    		}
    		CascadeClassifier face_cascade;
    		face_cascade.load("C:\\myfiles\\opencv-3.2.0\\sources\\data\\haarcascades\\haarcascade_frontalface_alt2.xml");
    		std::vector<Rect> faces;
    		Rect roi1;
    		Mat frame_gray;
    		cvtColor(frame_copy, frame_gray, COLOR_BGR2GRAY);//转换为灰度图
    		equalizeHist(frame_gray, frame_gray);//直方图均衡化
    		face_cascade.detectMultiScale(frame_gray, faces, 1.1, 2, 0 | CV_HAAR_SCALE_IMAGE, Size(30, 30));//--人脸检测
    		
    		cv::Mat foo(colorHeight, colorWidth, CV_8UC3, (void*)color);
    		rois.clear();
    		for (size_t i = 0; i < faces.size(); i++)
    		{
    			Rect roi;
    			roi.x = faces[static_cast<int>(i)].x;
    			roi.y = faces[static_cast<int>(i)].y;
    			roi.width = faces[static_cast<int>(i)].width;
    			roi.height = faces[static_cast<int>(i)].height;
    			rois.push_back(roi);
    			cv::rectangle(foo, roi, cv::Scalar(255, 0, 0),3);//在彩色图中画出人脸
    		}
    		for (int i = 0; i < colorWidth * colorHeight; i++)
    		{
    			const int rgbaOffset = i * 4;
    			buffer[rgbaOffset] = color[i].r;
    			buffer[rgbaOffset + 1] = color[i].g;
    			buffer[rgbaOffset + 2] = color[i].b;
    			buffer[rgbaOffset + 3] = 255;
    		}
    	}	
    	colorView_.texture_.update(&colorView_.buffer_[0]);
    }

    深度图人脸框标识和计算均值标准差的代码片段如下:

    	//更新深度流
    	void update_depth(astra::Frame& frame)
    	{
    		const astra::PointFrame pointFrame = frame.get<astra::PointFrame>();//获取点云帧
    
    		if (!pointFrame.is_valid())
    		{
    			clear_view(depthView_);
    			depthView_.texture_.update(&depthView_.buffer_[0]);
    			return;
    		}
    		const int depthWidth = pointFrame.width();
    		const int depthHeight = pointFrame.height();
    		init_texture(depthWidth, depthHeight, depthView_);//数据纹理
    		if (isPaused_) { return; }
    		visualizer_.update(pointFrame);
    		astra::RgbPixel* vizBuffer = visualizer_.get_output();
    		uint8_t* buffer = &depthView_.buffer_[0];
    
    		cv::Mat fool(depthHeight, depthWidth, CV_8UC3, (void*)vizBuffer);
    		const astra::RgbPixel* colorT = vizBuffer;
    
    		for (int i = 0; i < rois.size(); i++)
    		{	
    			Mat out = fool(Rect(rois[i].x, rois[i].y, rois[i].width, rois[i].height));//将人脸位置截取出来
    			Mat means, stddev, covar;
    			meanStdDev(out, means, stddev);//计算src图片的均值和标准差
    			double stddev_sum = 0;
    			double stddev_avg = 0;
    			for (int row = 0; row < means.rows; row++)
    			{
    				stddev_sum = stddev_sum + stddev.at<double>(row);
    			}
    			stddev_avg = stddev_sum / means.rows;//计算平均标准差
    			stringstream ss,sss;
    			ss << "real_" << stddev_avg;
    			sss << "unreal_" << stddev_avg;
    			int font = cv::FONT_HERSHEY_COMPLEX;
    			if (stddev_avg > 60)
    			{
    				printf("真人!标准差 = %.3f\n", stddev_avg);
    				cv::rectangle(fool,rois[i], cv::Scalar(255, 0, 0),3);//在深度图中画出人脸
    				cv::putText(fool, ss.str(), cvPoint(rois[i].x, rois[i].y),font,1.5, cv::Scalar(255, 0, 0),2);
    			}
    			else
    			{
    				printf("假人!标准差 = %.3f\n", stddev_avg);
    				cv::rectangle(fool, rois[i], cv::Scalar(0, 255, 0),3);//在深度图中画出人脸
    				cv::putText(fool, sss.str(), cvPoint(rois[i].x, rois[i].y), font, 1.5, cv::Scalar(0, 255, 0),2);
    			}
    		}
    		
    		for (int i = 0; i < depthWidth * depthHeight; i++)
    		{
    			const int rgbaOffset = i * 4;//4通道
    			buffer[rgbaOffset] = vizBuffer[i].r;//第一个通道
    			buffer[rgbaOffset + 1] = vizBuffer[i].g;//第二个通道
    			buffer[rgbaOffset + 2] = vizBuffer[i].b;//第三个通道
    			buffer[rgbaOffset + 3] = 255;//第四个通道
    		}
    		depthView_.texture_.update(&depthView_.buffer_[0]);
    	}

    效果如下:

    展开全文
  • jetson nano 乐视奥比中光摄像头+ROS一、下载二、安装三、编译四、启动 一、下载 1.驱动下载 链接:https://pan.baidu.com/s/1tOzevIqRWEDjDo8EUPkNwA 提取码:7jyn 2.ros包下载 cd {catkin project}/src git clone...

    jetson nano 乐视奥比中光摄像头+ROS

    一、下载

    1.驱动下载
    链接:https://pan.baidu.com/s/1P9OYdXISNylkSph0zq0l6A 提取码:fi2r

    2.ros包下载

    cd {catkin project}/src
    git clone https://github.com/orbbec/ros_astra_camera.git
    

    二、安装

    1.安装依赖

    sudo apt-get install build-essential freeglut3 freeglut3-dev
    

    2.检查libudev.so.1

    #check udev version, Orbbec Driver need libudev.so.1, if can't find it, can make symbolic link from libudev.so.x.x,
    #which usually locate in /lib/aarch64-linux-gnu
    $ ldconfig -p | grep libudev.so.1
    $ cd /lib/aarch64-linux-gnu
    $ sudo ln -s libudev.so.x.x.x libudev.so.1
    

    3.安装驱动

    unzip OpenNI-Linux-Arm64-2.3.zip
    cd OpenNI-Linux-Arm64-2.3
    sudo chmod a+x install.sh
    sudo ./install.sh
    source OpenNIDevEnvironment
    

    三、编译

    1.修改、ros_astra_camera/launch/astrapro.launch的错误,否则显示不了rgb,将product改为0502

    <node pkg="astra_camera" type="camera_node" name="$(arg camera)_rgb">
          <!-- Parameters used to find the camera -->
          <param name="vendor" value="0x2bc5"/>
          <param name="product" value="0x0502"/>
    

    2.创建USB规则

    cd {catkin project}/src/ros_astra_camera/scripts/
    ./create_udev_rules
    reboot
    

    3.编译

    catkin_make
    

    四、启动

    特别注意:一定使用一根粗的高速USB线,否则rgb总是莫名其妙的死掉!!!!!
    1.启动摄像头

    roslaunch astra_camera astrapro.launch
    

    2.启动image和点云2

    在这里插入图片描述

    展开全文
  • 关于奥比中光OpenNI SDK的环境配置问题 第一次使用奥比中光的Astra pro摄像头,照着官网的视频配置,运行后没有成功,提示错误:main.obj ink 2019 _imp_xxxxx 无法解析的外部符号。几经周折后找到了解决方法。 先...
  • 乐视奥比中光使用 2019-7-26

    千次阅读 2019-07-26 19:14:01
    1.乐视奥比中光使用记录 1.1 首先安装依赖项 1 首先下载libuvc库,这个库是奥比中光使用rgb图像显示的依赖库 git clone https://github.com/ktossell/libuvc cd libuvc mkdir build cd build cmake .. make &&...
  • ubuntu安装运行奥比中光摄像头astra 1 ROS-Astra-SDK 获取方式 本文用的是ubuntu kinetic版本 $ sudo apt-get install ros-kinetic-astra-camera $ sudo apt-get install ros-kinetic-astra-launch **2 ROS-Astra-...
  • 奥比中光大白 RGBD相机 python opencv代码实现

    千次阅读 热门讨论 2019-11-22 17:45:10
    奥比中光 "大白",彩色图像UVC协议,深度用openni。(很烦) 我们的项目需要在python中使用,问了奥比中光的技术支持,说没有python版本的demo,就自己写了一个。 彩色: import cv2 import sys capture_width ...
  • 奥比中光深度摄像头实现follow

    千次阅读 2018-12-20 20:34:20
    Github地址:https://github.com/robotBing/skeleton_follow ... 奥比中光摄像头是有ros驱动的,最开始的点云颜色跟随就是直接调用奥比提供的astra_launch包,但是骨骼跟随自己需要做的工作就多得多了...
  • 使用奥比中光Orbbec Astra Pro在ROS下跑orb_slam2

    千次阅读 热门讨论 2020-03-14 15:30:06
    使用奥比中光Orbbec Astra Pro在ROS下跑orb_slam2一、奥比中光摄像头驱动1. Install ROS1) Create a ROS Workspace(if you don't have one)2) Create a .sh documentation2. Install dependences3. Pull the ...
  • 奥比中光摄像头(astra pro)在kinetic和melodic下同时显示深度图像和彩色图像(rgb)的方法 前言:乐视摄像头采用的是奥比中光astra pro,套了个外壳就原价899,但出事儿后这款摄像头卖不出去了。。。。现在咸鱼...
  • 近日,深圳时空引力科技有限公司与奥比中光科技集团股份有限公司签署了《智能家居项目合作协议》。钛灵AI算法市场提供大量视觉AI算法、智能场景解决方案,结合奥比中光从底层芯片到系统框架、上层应用支持的全栈式...
  • 奥比中光摄像头SDK

    2020-04-20 09:35:26
    包含Windows驱动的安装包;windows,linux,android平台的代码;支持点云和深度图。
  • 奥比中光深度感应器工作原理

    千次阅读 2017-03-09 14:24:26
    奥比中光深度感应器工作原理 Astra设备中3D深度感应模块所使用的技术称为光编码技术(Light Coding),这是一种 光学式技术。其本质就是产生一张红外激光编码图(IR Light Coding Image),透过红外线投影机打到...
  • Android 4.4中允许奥比中光3D传感摄像头USB设备访问修改如下:frameworks/base/services/java/com/android/server/usb/UsbSettingsManager.javapublic booleanhasPermission(UsbDevice device) {synchronized (mLock...
  • 奥比中光填补深度镜头市场空白的世界级梦想。 高科技行业的垄断已经是见怪不怪的一种现象了,其专利保护机制让核心技术不随意流入大众市场,这也是高科技行业高利润的主要缘由所在。今天所要涉及的...
  • 奥比中光摄像头(astra)在ubuntu下使用 参考:https://blog.csdn.net/qq_43433255/article/details/89332667 https://blog.csdn.net/zhangrelay/article/details/53515859
  • 9月1日,奥比中光与NVIDIA(英伟达)联合举办的第二届3D视觉创新应用竞赛正式启动,面向全球高校开发者发起竞赛报名“集结号”。竞赛时间为2021年9月至12月,携手知名高校,联合行业专业机构,奥比中光将与3D视觉开发学子们...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 807
精华内容 322
关键字:

奥比中光