This is a realsense library which can be used to access realsense cameras (D435 and D435i) and use it with opencv
-
Clone the repository:
git clone https://github.com/ayushkumar8340/Realsense-CPP.git
-
Building instructions:
In this project we are using a docker environment for setting up things. The code is on local machine and we create a docker environment to run the code. The current directory is mounted live onto the docker environment so we can make changes and build the code in real-time.
cd Realsense-CPP/ sudo chmod +x build_docker.sh sudo chmod +x run_docker.sh ./buid_docker.sh ./run_docker.sh realsense mkdir build cd build cmake .. make -j4
- This is a demo for getting real-time camera feed and showing it on the screen using opencv window.
./demo/realsense_cam_feed
- This demo is for getting the depth of a particular point in the image frame.
./demo/realsense_depth
- Adding the library to your code.
- Copy the Realsense-CPP folder to the target project folder.
- In the CMakeLists.txt of your project add this line:
add_subdirectory(Realsense-CPP)
- The name of the library is realsense_lib. To link to your code add the following line to your CMakeLists.txt:
target_link_library(<your-executable-name> PUBLIC realsense_lib)
- Build the project
- APIs / Usage instructions:
- Include "realsense.h"
- Make an object of Realsense class.
- InputDevConfig is a structure which holds all the configurations for the camera. It has a function setDefault() which sets the default value for the variables.
- Setup the Realsense class by calling setupInputDevice() which initializes all the required sensors.
- To enable IMU of the camera change the #define D435i to false in realsense.h
- In while loop run startStreaming().
- Call function like getColourFrame(), getDepthFrame() and getIMUData() to get various data from the camera.
- Various Data types are defined for colour frame , depth frame and imu frame check the frames.h file for more info