ubuntu14.04利用opencv‘获取realsense图像
2017-04-06 15:02
387 查看
CMakeLists.txt
主程序:
其中CMakeLists是根據例子中的改的,所以需要把example.hpp和第三方頭文件文件夾都要拷過來。
cmake_minimum_required(VERSION 2.8.3) project(RealsenseExamples) include(CheckCXXCompilerFlag) CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) if(COMPILER_SUPPORTS_CXX11) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") elseif(COMPILER_SUPPORTS_CXX0X) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") else() message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") endif() find_package(OpenCV REQUIRED) find_package(OpenGL REQUIRED) set(DEPENDENCIES realsense ${OPENGL_LIBRARIES}) if(WIN32) add_subdirectory(third_party/glfw) list(APPEND DEPENDENCIES glfw3) else() # Find glfw header find_path(GLFW_INCLUDE_DIR NAMES GLFW/glfw3.h PATHS /usr/X11R6/include /usr/include/X11 /opt/graphics/OpenGL/include /opt/graphics/OpenGL/contrib/libglfw /usr/local/include /usr/include/GL /usr/include ) # Find glfw library find_library(GLFW_LIBRARIES NAMES glfw glfw3 PATHS /usr/lib64 /usr/lib /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE} /usr/local/lib64 /usr/local/lib /usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE} /usr/X11R6/lib ) list(APPEND DEPENDENCIES m ${GLFW_LIBRARIES} ${LIBUSB1_LIBRARIES}) include_directories(${GLFW_INCLUDE_DIR}) endif() add_executable(realsense_example realsense_example.cpp) target_link_libraries(realsense_example ${DEPENDENCIES}) target_link_libraries( realsense_example ${OpenCV_LIBS} )
主程序:
#include <librealsense/rs.hpp> #include "example.hpp" #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc.hpp> #include <sstream> #include <iostream> #include <iomanip> #include <thread> using namespace cv; using namespace std; struct rgb_pixel { uint8_t r,g,b; }; int main() { rs::log_to_console(rs::log_severity::warn); rs::context ctx; if(ctx.get_device_count() == 0) throw std::runtime_error("No device detected. Is it plugged in?"); rs::device & dev = *ctx.get_device(0); dev.enable_stream(rs::stream::color, 640, 480, rs::format::rgb8, 60); dev.enable_stream(rs::stream::depth, 640, 480, rs::format::z16, 60); dev.enable_stream(rs::stream::infrared, 640, 480, rs::format::y8, 60); dev.start(); while(1) { dev.wait_for_frames(); uchar* pRgb = (uchar*)dev.get_frame_data(rs::stream::color); uint16_t *depthImage = (uint16_t *) dev.get_frame_data(rs::stream::depth); Mat rgb_show; Mat rgb(480, 640, CV_8UC3, pRgb); cvtColor(rgb, rgb_show, CV_BGR2RGB); imshow("RGBImage",rgb_show); Mat depth(480,640,CV_16UC1, depthImage); imshow("Depthimage",depth*15); uchar* pFra = (uchar*)dev.get_frame_data(rs::stream::infrared); Mat fra_img(480, 640, CV_8UC1, pFra); imshow("FraImage",fra_img); waitKey(10); } }
其中CMakeLists是根據例子中的改的,所以需要把example.hpp和第三方頭文件文件夾都要拷過來。
相关文章推荐
- ubuntu 14.04 +Kinect+ openNI+ openCV+ Sensorkinect 配置 +获取深度图像及相关问题
- RealSense SDK 开发笔记 (三)获取R200的图像(OpenCV Mat)
- Intel Realsense Camera F200 获取图像并保存为CV_16UC1的PNG图片
- Intel RealSense学习之图像及图像深度数据获取
- 利用opencv从本地获取图像,并进行图像缩放,彩色图转灰度图
- Ubuntu14.04优麒麟版安装SR300 Intel RealSense驱动程序
- Ubuntu16.04下opencv获取realsense sr300的图像数据
- [转]ubuntu 14.04 下利用apt-get方式安装opencv
- ubuntu 14.04 下利用apt-get方式安装opencv
- 利用opencv获取鼠标左键点击位置图像的像素值
- opencv利用鼠标获取图像的像素值
- RealSense 开发(一):深度图像获取
- ubuntu14.04安装Realsense驱动
- 利用realsense官方SDK进行rgb图像和深度数据采集
- Opencv获取图像上的像素值(Ubuntu版)
- 利用opencv,在图像中获取鼠标按下时坐标和灰度值
- ubuntu14.04 利用ros usb_cam包驱动摄像头后显示图像上下颠倒的解决方法
- 图像处理(一)Ubuntu14.04安装opencv-2.4.10
- ubuntu 14.04 下利用apt-get方式安装opencv
- 从RealSense中提取完整的深度和彩色图像,并存在opencv中的Mat里