How to learn all the functionalities I can program to my own project?
I bought one D435IF and one D435F and it will be arrived soon. Meanwhile, I
m trying to learn what I can do and how to code with all these API and syntax with the sample codes, but I seem to not understand them throughly and I don't think these examples can guide me to what i want to achieve. May anyone provide me with the links to all these API documentation or any tutorial to get started?
I am using Windows 11, visual studio 2022 and C++. I am a learner developer and this is my first project. Ultimately, I need to use the depth camera to while-loop scan any obstacle within 200mm (20 pixels in consecutive are considered an obstacle) and output a message "obstacle found".
-
An easy way to get started with RealSense C++ application development in Visual Studio is to use the three props property sheet files provided by the RealSense SDK. Information about doing so can be found at the link below.
https://support.intelrealsense.com/hc/en-us/community/posts/4412175411859/comments/4412182682387
-
If you mean the three property sheet files, they simply contain linkages to the library files of librealsense, OpenCV and glfw / imgui graphics in order to set them up in a RealSense Visual Studio project and do not need to be studied. The files can be opened in the Windows notepad app if you wish to look at their contents.
For example, below are the contents of the librealsense prop file.
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros">
<librealsenseSDK>$(ProgramFiles)\Intel RealSense SDK 2.0</librealsenseSDK>
</PropertyGroup>
<PropertyGroup />
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>$(librealsenseSDK)\include;
$(librealsenseSDK)\third-party\;
%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>$(librealsenseSDK)\lib\$(PlatformShortName);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>realsense2.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>xcopy /y "$(librealsenseSDK)\bin\$(PlatformShortName)\realsense2.dll" "$(OutDir)"</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>Copy Intel RealSense SDK 2.0 shared module next to the application</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<BuildMacro Include="librealsenseSDK">
<Value>$(librealsenseSDK)</Value>
</BuildMacro>
</ItemGroup>
</Project> -
So where should I look for the API I need to, like get the depth of a pixel from the camera, crop and scan a certain part only from a 1280x720px? I want to go through all the API i can call from librealsense2, Imgui, opencv and know how each work. Since I'm quite new to being a dev, I don't really know where to look for this documentation.
-
A good place to start is the API How-To page that contains code snippets for different kinds of functions. Use the code sections headed librealsense2.
https://dev.intelrealsense.com/docs/api-how-to
The Examples page also contains a wide range of example programs that you can view the cpp source code of.
https://github.com/IntelRealSense/librealsense/tree/master/examples
Some OpenCV RealSense example programs can be found here:
https://github.com/IntelRealSense/librealsense/tree/master/wrappers/opencv
The majority of RealSense users will not need to get into Imgui programming, but if you are interested then there is a discussion at the link below about Imgui drawing commands in librealsense.
You can crop the distance using a Threshold Filter to set a minimum and maximum distance for depth rendering. Depth values outside of that min-max range will be excluded from the depth image. An example of C++ scripting for doing so is below.
https://github.com/IntelRealSense/librealsense/issues/7771
If you want to crop XY (horizontal and vertical) instead of forward Z-distance then that is more complicated. Doing it via the definition of a bounding box is described here:
https://github.com/IntelRealSense/librealsense/issues/2016
If you wish to get the depth of a specific pixel coordinate instead of the entire image then you can use an API instruction called rs2_project_color_pixel_to_depth_pixel to convert an XY color pixel to an XYZ depth pixel.
https://github.com/IntelRealSense/librealsense/issues/6239#issuecomment-614261704
Please sign in to leave a comment.
Comments
6 comments