C++ (Linux Platform)

Linux SDK supports AArch64, ARMv7hf, RaspberryPi, i686 and x86-64 hardware platforms, and provides corresponding library files for developers to compile programs. Linux SDK does not provide executable applications, the developers can generate executable applications by compiling sample programs.

The following is an example of setting up the development environment for Percipio depth camera on Linux platform, using Ubuntu 18.04:

  1. Download Camport3 SDK

  2. Install USB Driver

  3. Install Dependencies

  4. Set USB Camera Access Permissions

  5. Compile Sample Programs

  6. Run Sample Programs

Download Camport3 SDK

Choose any of the following methods to download Camport3 SDK:

  • Access https://github.com/percipioxyz/ using a browser and download the Camport3 SDK.

  • Use the git command to obtain a local copy: Open the terminal, switch to the directory where the SDK should be stored, and enter the git clone command to clone the remote repository.

    git clone https://github.com/percipioxyz/camport3.git
    

The directory structure of Camport3 SDK is shown in the following figure:

Camport3 SDK Directory Structure

Camport3 SDK Directory Structure

Doc Directory

It stores the SDK API reference documentation. The documentation is generated by Doxygen and includes descriptive information about classes, structures and interfaces.

SDK API Reference Documentation

SDK API Reference Documentation

include Directory

It stores the header files used to call dynamic libraries:

  • TYImageProc.h: the header file for the image post-processing function interfaces.

  • TYCoordinateMapper.h: the header file for mapping of image space transformation.

  • TYApi.h: the header file for configuring the depth camera and obtaining image data. Users can develop their own applications based on these APIs.

lib/linux Directory

It stores library files which support the Linux operating system and are compatible with AArch64, ARMv7hf, RaspberryPi, i686 and x86-64 hardware platforms.

lib/win Directory

It stores library files which support the Windows operating system and are compatible with x64 and x86 hardware platforms.

sample Directory

It contains two subfolders, sample_v1 and sample_v2, both of which include sample programs provided for users to refer to when programming. For more details about the sample programs, please refer to Sample Program Descriptions.

Note

The sample programs in sample_v2 add convenient camera control interfaces on the basis of sample_v1 and provide the option of whether to depend on OpenCV or not.

Install USB Driver

Whether you are using a USB camera or a network camera, installing the USB driver is necessary for compiling and running the Camport SDK.

sudo apt-get install libusb-1.0-0-dev

Install Dependencies

Install CMake

Install CMake (V2.8.0) 1. Install Cmake by inputting the following command in the terminal:

sudo apt-get install cmake
  1. Check if the installation is successful by checking the version information.

    cmake --version
    

Install OpenCV (Optional)

sudo apt-get install libopencv-dev

Note

  1. Camport SDK requires users to install OpenCV 2.4.8 or higher versions.

  2. If the target application does not use OpenCV for image display or other image processing calculations, there is no need to install OpenCV.

Set USB Camera Access Permissions

According to the permission management mechanism of Linux system, by default, root permission is required to access the Percipio USB depth camera. Non-root users can create a udev rule to modify the device permissions.

The setup steps are as follows:

  1. Direct to directory “etc/udev/rules.d”, create a rule file with the extension .rules (such as 88-tyusb.rules).

    Note

    The beginning of the rule file name must be a number (0 ~ 99), the larger the number, the higher the priority.

    sudo nano /etc/udev/rules.d/88-tyusb.rules
    
  2. Add the following rules in the rule file. The example below is to add the USB device to the tofu user group.

    SUBSYSTEM== "usb",ATTRS{idProduct}=="1003",ATTRS{idVendor}=="04b4",GROUP="tofu",MODE="0666"
    
  3. After restarting the PC, access permission to the USB depth camera will be granted.

Compile Sample Programs

Enter the “camport3” directory and execute the following command to compile the sample programs.

sudo cp lib/linux/lib_x64/libtycam.so* /usr/lib/
cd sample
mkdir build
cd build
cmake ..
make

If you only need to compile the example programs in “sample_v2”, then add the following parameters for cmake:

cmake .. -DBUILD_SAMPLES=off

If the example program in “sample_v2” does not depend on OpenCV, then add the following parameters for cmake:

cmake .. -DBUILD_SAMPLES=off -DBUILD_SAMPLE_V2_WITH_OPENCV=off

The compiled executable files will be generated in the “camport3/sample/build/bin” directory.

Run Sample Programs

After connecting to the computer, the depth camera will initiate system initialization. Once the power indicator on the camera begins blinking at a frequency of 1Hz, you can run the following command with root privileges to receive and view real-time depth maps.

sudo ./SimpleView_FetchFrame