This tutorial gives an example of building a visual tracking project using Guidance SDK step by step. It supports Windows and Linux.
A complete visual tracking project is already included in the demo folder. The user is encouraged to build and run the project first to get a feeling of how it would work. Then follow the instructions below to get the knowledge of how to build a Guidance SDK project from scratch.
Latest version of SDK is available on GitHub and then decompress it: Guidance SDK.
The content includes:
Create an empty project in VS2010 in directory “demo” named “guidance_track”.
Add an empty main.cpp to project first.
Copy the thread security related files DJI_utility.cpp and DJI_utility.h to the same directory as main.cpp, and add them in vs2010. DJI_utility.cpp and DJI_utility.h can be found both in SDK/demo and SDK/examples.
Now we need to configure DJI_guidance.h, DJI_guidance.lib and OpenCV related path. DJI_guidance.h is in include, DJI_guidance.lib is in lib. DJI_guidance.lib in lib/2010/x86 is going to be used here as we will run programs in Release | Win32 mode.
To simplify the configuration, we can copy the property sheets “use_opencv_release_vs2010_x86.props” “use_Guidance_vs2010_x86.props” in demo/sdk_tracking_camshift to the solution directory and add to the new project.
Attention: Make sure you have installed OpenCV, and set up the environment variable OPENCVROOT properly, which is used by the OpenCV property sheet.
Users can modify the property sheet to adapt to changes of the path of project. Here gives a look at the path of Include and Library of Guidance SDK.
Copy the DJI_guidance.dll from SDK/lib/2010/x86 to the bin folder of our project.
|
|
|
|
Help function prototype:
|
Since this tutorial gives a demo of camshift based tracking using depth image, users need to select object to track when the program starts with the window of “Guidance Tracking Demo”, and then the result will be shown.
|
|
Make sure the environment has been set up properly.
One can click the “Build” and then “Start Debugging” after connecting and starting the Guidance.
Download the SDK package to ~/Desktop/GuidanceSDK
.
Create a directory ~/Desktop/SDK/demo/guidance_track
, and copy DJI_utility.cpp, DJI_utility.h and main.cpp created under Windows to this directory.
mkdir ~/Desktop/GuidanceSDK/demo/guidance_track
cd ~/Desktop/SDK/demo/guidance_track
Suppose the operating system is Ubuntu14.04 32bit. Copy the libDJI_guidance.so from so/x86 to usr/local/lib. Notice that sudo
is necessary to copy these files to /usr/local/lib
:
|
Create a Makefile in the project directory. Make sure OpenCV has been installed.
|
Code of Makefile:
|
|
Draw the object box with mouse when program is running. One could see pictures as follows if everything goes well.
Type q
on keyboard will quit the program.