forked from IntelRealSense/librealsense
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
166 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# minimum required cmake version: 3.1.0 | ||
cmake_minimum_required(VERSION 3.1.0) | ||
|
||
project(RealsenseCVExamples) | ||
|
||
# Save the command line compile commands in the build output | ||
set(CMAKE_EXPORT_COMPILE_COMMANDS 1) | ||
# View the makefile commands during build | ||
#set(CMAKE_VERBOSE_MAKEFILE on) | ||
|
||
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") | ||
endif() | ||
|
||
find_package(OpenCV REQUIRED) | ||
if(NOT OPENCV_FOUND) | ||
message(FATAL_ERROR "\n\n OpenCV package is missing!\n\n") | ||
endif() | ||
|
||
set(DEPENDENCIES realsense2 ${OpenCV_LIBS}) | ||
|
||
add_subdirectory(imshow) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# minimum required cmake version: 3.1.0 | ||
cmake_minimum_required(VERSION 3.1.0) | ||
|
||
project(RealSenseImShowExample) | ||
|
||
# Save the command line compile commands in the build output | ||
set(CMAKE_EXPORT_COMPILE_COMMANDS 1) | ||
|
||
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_C_FLAGS "${CMAKE_C_FLAGS} -std=c11") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") | ||
elseif(COMPILER_SUPPORTS_CXX0X) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") | ||
endif() | ||
|
||
if(BUILD_CV_EXAMPLES) | ||
add_executable(rs-imshow rs-imshow.cpp) | ||
target_link_libraries(rs-imshow ${DEPENDENCIES}) | ||
set_target_properties (rs-imshow PROPERTIES | ||
FOLDER "Examples/CV" | ||
) | ||
|
||
install( | ||
TARGETS | ||
|
||
rs-imshow | ||
|
||
RUNTIME DESTINATION | ||
${CMAKE_INSTALL_PREFIX}/bin | ||
) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// License: Apache 2.0. See LICENSE file in root directory. | ||
// Copyright(c) 2017 Intel Corporation. All Rights Reserved. | ||
|
||
#include <librealsense2/rs.hpp> // Include RealSense Cross Platform API | ||
#include <opencv2/opencv.hpp> // Include OpenCV API | ||
|
||
// Capture Example demonstrates how to | ||
// capture depth and color video streams and render them to the screen | ||
int main(int argc, char * argv[]) try | ||
{ | ||
// Declare depth colorizer for pretty visualization of depth data | ||
rs2::colorizer color_map; | ||
|
||
// Declare RealSense pipeline, encapsulating the actual device and sensors | ||
rs2::pipeline pipe; | ||
// Start streaming with default recommended configuration | ||
pipe.start(); | ||
|
||
using namespace cv; | ||
const auto window_name = "Display Image"; | ||
namedWindow(window_name, WINDOW_AUTOSIZE); | ||
|
||
while (waitKey(1) < 0 && cvGetWindowHandle(window_name)) | ||
{ | ||
rs2::frameset data = pipe.wait_for_frames(); // Wait for next set of frames from the camera | ||
|
||
rs2::frame depth = color_map(data.get_depth_frame()); // Find and colorize the depth data | ||
|
||
// Query frame size (width and height) | ||
auto w = depth.as<rs2::video_frame>().get_width(); | ||
auto h = depth.as<rs2::video_frame>().get_height(); | ||
|
||
// Create OpenCV matrix of size (w,h) from the colorized depth data | ||
Mat image(Size(w, h), CV_8UC3, (void*)depth.get_data(), Mat::AUTO_STEP); | ||
|
||
// Update the window with new data | ||
imshow(window_name, image); | ||
} | ||
|
||
return EXIT_SUCCESS; | ||
} | ||
catch (const rs2::error & e) | ||
{ | ||
std::cerr << "RealSense error calling " << e.get_failed_function() << "(" << e.get_failed_args() << "):\n " << e.what() << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
catch (const std::exception& e) | ||
{ | ||
std::cerr << e.what() << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# OpenCV Samples for Intel® RealSense™ cameras | ||
**Code Examples to start prototyping quickly:** These simple examples demonstrate how to easily use the SDK to include code snippets that access the camera into your applications. | ||
|
||
For a detailed explanations and API documentation see our [Documentation](../doc) section | ||
|
||
## List of Samples: | ||
1. [ImShow](./imshow) - Minimal OpenCV application for visualizing depth data | ||
|
||
## Getting Started: | ||
This page is certainly **not** a comprehensive guide to getting started with OpenCV and CMake, but it can help get on the right track. | ||
|
||
### Windows | ||
1. Download and install `CMake` from [cmake.org/download](https://cmake.org/download/) | ||
2. Clone or download OpenCV sources from [github.com/opencv/opencv](https://github.com/opencv/opencv) into a local directory (`C:/git/opencv-master`) | ||
3. Run `cmake-gui`, input source code and binaries locations: | ||
|
||
![1](res/1.PNG) | ||
|
||
4. Click `Configure` | ||
> When working behind a firewall, you might want to consider unchecking `WITH_FFMPEG` and `WITH_IPP` to avoid additional downloads | ||
5. Uncheck `BUILD_SHARED_LIBS`: | ||
|
||
![2](res/2.PNG) | ||
|
||
6. Click `Generate` | ||
7. Click `Open Project` to open Visual Studio | ||
8. Press `Ctrl+Shift+B` to build solution | ||
9. Clone or download librealsense sources from [github.com/IntelRealSense/librealsense](https://github.com/IntelRealSense/librealsense) into a local directory (`C:/git/librealsense`) | ||
10. Run `cmake-gui` and fill source code and binaries locations and press `Configure` | ||
11. Make sure you check the `BUILD_CV_EXAMPLES` flag and click `Configure` again: | ||
|
||
![3](res/3.PNG) | ||
|
||
12. Specify CMake binaries folder for OpenCV as `OpenCV_DIR` (`c:/git/opencv-master`) | ||
|
||
![4](res/4.PNG) | ||
|
||
13. Click `Generate` and `Open Project` | ||
14. Locate CV solution-folder under Examples | ||
|
||
![5](res/5.PNG) | ||
|
||
15. Right-click on one of the examples to `Set as StartUp Project` | ||
16. Press `F5` to compile and run the example: | ||
|
||
![6](res/6.PNG) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.