C/C++
Xvisio SDK Documentation Home Page

demo-api


1 Overview

The demo_api sample program provides the use of numeric characters to select the execution function to demonstrate the basic functions of the Xvisio device and the corresponding SDK API, as well as the sample code corresponding to the execution function.

2 Build and Run

2.1 Linux/Ubuntu

2.1.1 Cmake Build
  1. First, you need to install the Xvisio SDK on the Linux/Ubuntu host and can refer to SDK Installation Guide
  2. Start the terminal and navigate to the demo-api installation path "/usr/share/xvsdk/demo-api" , or copy "/usr/share/xvsdk/demo-api" to the working directory and navigate to the "demo-api" directory.
    cp -r /usr/share/xvsdk/demo-api <path_to_work>
    cp -r /usr/share/xvsdk/pipe_srv <path_to_work>
    cd <path_to_work>/demo-api
  3. Generating Makefiles with Cmake
    mkdir build
    cd build
    cmake ..
  4. Build
    make
    A successful build will generate an executable binary named 'demo-api'.
2.1.2 RUN
  1. Connect the xvisio device and the Ubunut host with a USB cable.

  2. To view the USB device status, open a terminal anywhere and type:
    lsusb
    Observe the terminal output usb status information where VID:PID is "040e:f408", and the USB device whose device name is "MCCI XVisio vSLAM" is the Xvisio device.
    Confirm that the current device enumeration is USB3.0 or USB2.0 by the USB Bus number of the Xvisio device and the corresponding BUS HUB type.
    Please ensure proper enumeration of Xvisio device
    The above description is shown in the following figure:
    image

  3. Start terminal and navigate to the "<path_to_work>/demo-api/build/" directory and execute:
    ./demo-api
    Before doing this step, you need to make sure that the program has been successfully built and 'demo-api' has been generated.

  4. Start another terminal in the same location and execute:
    ./pipe_srv
    pipe_srv and demo-api must be started in the same directory.
    After the startup is successful, the terminal will output the function menu print, as follows:
    pipe server recv has already exist
    pipe server send has already exist
    wait for client connect....
    pipe server get send handle: 3
    pipe server get recv handle: 4
    ready handle: send:3,recv:4


    Demo
    ------------------------------
    1 : Init SDK and get IMU
    2 : Stop get IMU, start slam, get 6dof
    ....
    0 : exit program
    ------------------------------
    enter select:

  5. Menu function
    Type the corresponding numeric character on the terminal of pipe-srv and press Enter to execute the corresponding function, and observe the output of the demo-api terminal.
    Function Menu Description

2.2 Windows10/11

2.2.1 Build
  1. First, you need to install the Xvisio SDK on the Windows host, you can refer to SDK Installation Guide
  2. After the SDK is installed successfully and then go to the demo-api sample directory in the installation directory, for example: C:\Program Files\xvsdk\samples\demo-api .
  3. visual studio compile
  1. Cmake generates sln file
  • Start the windows powershell tool and navigate to the demo-api directory in the installation directory.
  • Execute the corresponding build project command according to the current visual studio version:
    Version cmake command
    VS2019 64 bits cmake -G "Visual Studio 16 2019" -A x64
    VS2019 32 bits cmake -G "Visual Studio 16 2019" -A Win32
    VS2017 64 bits cmake -G "Visual Studio 15 2017" -A x64
    VS2017 32 bits cmake -G "Visual Studio 15 2017" -A Win32
  • The demo-api.sln file will be generated in the dmeo-api directory
  • Open demo-api.sln with visual studio
  • Build (generate) the demo-api project in the solution. If the build is successful, demo-api.exe will be generated in the corresponding directory.
2.2.2 RUN
  1. Connect the xvisio device and the Windows host with a USB cable.
  2. Use USB to connect the Xvisio device to the PC. If the Xvisio device is connected normally, there are usually 3 devices enumerated. You can view the device status through the system's device manager:
    image
    Please check "VSC interface" device status, camera device "XVisio vSLAM" status, "USB Composite Device" status. If the status is abnormal, please check whether the USB cable, Xvisio device firmware is normal, and whether the Windows host USB status meets the requirements, ** or please contact Xvisio FAE personnel for support**.
  3. Start the windows powershell tool and navigate to the bin directory under the installation directory, enter the program name and press Enter:
    ./demo-api.exe
    image
  4. After the startup is successful, the powershell window will output the function menu print.
  5. Menu function
    Type the corresponding numeric character on the powershell and press Enter to execute the corresponding function, and observe the output of the powershell.
    Function Menu Description

2.3 Android

Notice:

  1. The demo-api demo can only be run on android devices with root SDK installed. Therefore, the introduction in this section is only for the root version of the Android SDK.
  2. This article selects the linux platform as the NDK compilation platform as an example to introduce.
2.3.1 Build
  1. Install NDK
  • Download
    It can be downloaded from this link NDK, the r21e version is recommended, please select the NDK package suitable for your linux or windows development platform and download it. This article selects the linux platform as an example.
  • Decompress
    unzip android-ndk-r21e-linux-x86_64.zip
  • Set environment variables
    sudo gedit ~/.bashrc
    add at the end of the file.
    export ANDROID_NDK_ROOT=/path_from_yours/android-ndk-r21e/
    export NDK=${ANDROID_NDK_ROOT}
    export PATH=${PATH}:$NDK
    Where "/path_from_yours/android-ndk-r21e/" is replaced with the absolute path of NDK decompression.
    sourc ~/.bashrc
  • Check the settings
    ndk-build -v
    The version information is correct and no errors are reported.
  1. Download SDK
  • Get the latest installation package,Please select the compressed package in the download directory: xvsdk_3.2.x-xxxxxxxx_android.zip .
  • Unzip xvsdk_3.2.x-xxxxxxxx_android.zip, and enter the unzipped folder.
  1. compile
    cd android/jni/
    ndk-build
    The example programs of all links in "Android.mk" will be compiled.
    The compilation is successful and no error is reported. The arm64-v8a in the android/libs/ directory will generate a executable binary file.
2.3.2 RUN
  1. First, you need to install the Xvisio SDK on the android host, you can refer to "Introduction to the installation of Android SDK (root version)" in SDK installation guide.
  2. ADB connects the android device to the host, ensure that the adb environment is normal, ensure that the Android device has the remount permission, and ensure the existence of the push directory. The example directory here is "/data/test/" .
  3. push sdk
    Start terminal and navigate to the android/libs/ directory inside the sdk unzipped folder, execute:
    adb root
    adb remount
    If remount fails can do:
    adb disable-verity
    adb reboot
    adb root
    adb remount
    If it still fails, please contact the Android device vendor for support
    arm64 example:
    adb push arm64-v8a /data/test/
    arm32 example:
    adb push armeavi-v7a /data/test/
  4. Run demo-api:
  • Start a terminal and execute:
    adb shell
    cd /data/test/arm64-v8a/
    LD_LIBRARY_PATH=./ ./demo-api
  • Start another terminal and run pipe_srv:
    adb shell
    cd /data/test/arm64-v8a/
    LD_LIBRARY_PATH=./ ./pipe_srv
  • pipe_srv and demo-api must be started in the same directory.
    After the startup is successful, the terminal will output the function menu print, as follows:
    pipe server recv has already exist
    pipe server send has already exist
    wait for client connect....
    pipe server get send handle: 3
    pipe server get recv handle: 4
    ready handle: send:3,recv:4


    Demo
    ------------------------------
    1 : Init SDK and get IMU
    2 : Stop get IMU, start slam, get 6dof
    ....
    0 : exit program
    ------------------------------
    enter select:
  1. Menu function
    Type the corresponding numeric character on the terminal of pipe-srv and press Enter to execute the corresponding function, and observe the output of the demo-api terminal.
    Function Menu Description

3 Code introduction

3.1 Path

Platform Path
Windows The samples\demo-api directory in the installation directory, for example: C:\Program Files\xvsdk\samples\demo-api\
Linux/Ubuntu /usr/share/xvsdk/demo-api/
Android examples/demo-api/ in the unzipped folder of Android SDK

3.2 File

File Description
demo-api.cpp demo-api core file
fps_count.hpp The file that implements the class that calculates the frame rate
pipe_srv.h Pipeline function file (not supported on Windows)
CMakeLists.txt Cmake project file (not supported on Android)

3.3 Code Introduction

The main(....) function of the demo-api.cpp file is the entry function:

int main( int argc, char* argv[] ) try{....}

The meun_main[] array is the preset function menu:

static const char meun_main[] = { ....}

while loop to wait for input character command parsing,

while (cond) {

The Windows platform does not use pipes, by entering the character 'm' to stop an already running function and output the menu

#ifdef _WIN32
std::cin >> cCmd;
if (cCmd == "m")
{
if (device)
{
//stop all running items
if (device->display())
{
device->display()->close();
}
if (device->orientationStream())
{
//device->orientationStream()->stop();
device->orientationStream()->unregisterCallback(imuId);
} ....

on-Windows platforms wait for piped commands:

#else
cmd = requestCmdAllPlatform(meun_main, sizeof(meun_main));
#endif

Parse command:

switch (cmd) {
case 1:
{
....
}
break;
case 3:
case 22:
case 28:
case 36:
....

The menu function corresponding to the serial number is executed in each case, and the description of the menu function is shown in Section 4.

4 Function Menu Description

Serial Number Function Describe Remark Keywords
1 Init SDK and get IMU Initialize SDK and device and then start getting IMU data stream The first thing to do after starting the demo-api program is to check the SDK version, Xvisio device version and other initial information. INIT
2 Stop get IMU, start slam, get 6dof Stop getting the IMU and then start the SLAM process to get the 6dof data stream Use as a test to verify SLAM functionality SLAM
3 Stop slam, stop get 6dof, get IMU Stop getting 6dof and stop SLAM process and then restart get IMU stream Use as a test to verify SLAM functionality SLAM
4 Get eyetracking data, stop get IMU Stop getting the IMU and then start the Eye tracking process to get the eye tracking camera image stream Used as a test to verify ET (Eye Tracking) functionality ET (Eye Tracking)
5 Stop get eyetracking data, get IMU Stop the Eye tracking process and then restart to get the IMU data stream Used as a test to verify ET (Eye Tracking) functionality ET(Eye Tracking)
9 Stop get IMU, get rgb data Stop getting imu and start rgb process to get rgb data Used to test rgb data process RGB
10 Stop rgb, get IMU Stop getting rgb data and restart IMU process Used to test rgb data process RGB
11 Stop get IMU, get tof data Stop getting imu and start tof process to get tof data Used to test tof data process TOF
12 Stop tof, get IMU Stop getting tof data and restart IMU process Used to test tof data process TOF
13 Start tof plane detection, start slam, stop get IMU, get 6dof Stop getting imu and start tof plane detection process to get tof plane data, then start slam, get 6dof data Used to test tof plane detection data TOF plane detection
14 Stop tof plane detection, stop slam, get IMU Stop getting tof plane detection process and stop slam, restart getting imu data Used to test tof plane detection data TOF plane detection
15 Stop get IMU, switch to edge mode, get edge 6dof Stop getting imu and start slam with edge mode, get 6dof data Used to test edge mode slam data edge slam
16 Stop get edge 6dof, get IMU Stop getting edge mode slam data, restart getting imu Used to test edge mode slam data edge slam
17 Test display: open display,set brightness to 2,set brightness to 9 Open display setting, set brightness to 2, then set brightness to 9 Used to test display brightness setting display
18 Test display: close display Close display setting Used to test display brightness setting display
19 Stop get IMU, start slam, get 6dof Stop getting imu and start slam with mixed mode, get 6dof data Used to test mixed mode slam data SLAM
20 Save shared map Create shared map and save into bin file Used to test cslam mode cslam
21 Stop slam, start CSLAM using shared map, start slam Stop getting imu and start cslam mode with shared map file, start slam to get 6dof data Used to test cslam mode cslam
22 Stop slam, get IMU Stop getting slam data and restart getting imu Used to test slam slam
23 Start stereo plane detection, start slam, stop get IMU, get 6dof Stop getting imu and start fisheye plane detection process to get fisheye plane data, then start slam, get 6dof data Used to test fisheye plane detection data fisheye plane detection
24 Stop stereo plane detection, stop slam, get IMU Stop getting fisheye plane detection process and stop slam, restart getting imu data Used to test fisheye plane detection data fisheye plane detection
25 Stop get IMU, switch to EdgeFusionOnHost mode, get 6dof with callback Stop getting imu and start slam with miEdgeFusionOnHostxed mode, get 6dof data Used to test EdgeFusionOnHost mode slam data EdgeFusionOnHost slam
26 Stop get IMU, switch to EdgeFusionOnHost mode, get 6dof with get-pose Stop getting EdgeFusionOnHost mode slam data and restart getting imu Used to test EdgeFusionOnHost mode slam EdgeFusionOnHost slam
27 Stop get IMU, switch to EdgeFusionOnHost mode, get 6dof with get-pose Stop getting imu and start slam with miEdgeFusionOnHostxed mode, get 6dof data with get-pose method Used to test EdgeFusionOnHost mode slam data with get-pose method EdgeFusionOnHost get-pose
28 Stop get 6dof with get-pose, stop EdgeFusionOnHost slam, get IMU Stop getting EdgeFusionOnHost mode slam data and restart getting imu Used to test EdgeFusionOnHost mode slam data with get-pose method EdgeFusionOnHost get-pose
29 Call 3Dof get() Stop getting imu and get 3dof data with get method Used to test 3dof data with get method 3dof get
30 Stop call 3Dof get(), get IMU Stop getting 3dof data with get method and restart getting imu Used to test 3dof data with get method 3dof get
31 Call 3Dof getAt() Stop getting imu and get 3dof data with getAt method Used to test 3dof data with getAt method 3dof getAt
32 Stop call 3Dof getAt(), get IMU Stop getting imu and get 3dof data with getAt method Used to test 3dof data with getAt method 3dof getAt
33 Stop get IMU, switch to mixed mode, get 6dof with callback Stop getting imu and start slam with mixed mode, get 6dof data with callback method Used to test mixed mode slam data with callback method mixed slam callback
34 Stop get 6dof with callback, stop mix slam, get IMU Stop getting mixed mode slam data and restart getting imu Used to test mixed mode slam data with callback method mixed slam callback
35 Stop get IMU, switch to mixed mode, get 6dof with get-pos-at Stop getting imu and start slam with mixed mode, get 6dof data with get-pos-at method Used to test mixed mode slam data with get-pos-at method mixed slam get-pos-at
36 Stop get 6dof with get-pos-at, stop mix slam, get IMU Stop getting mixed mode slam data and restart getting imu Used to test mixed mode slam data with get-pos-at method mixed slam get-pos-at
37 Stop get IMU, read rgb calibration Stop getting imu and get rgb calibration data Used to test rgb calibration data RGB Calibration
38 Stop get IMU, set rgb resolution Stop getting imu and set rgb resolution Used to test rgb resolution setting RGB Resolution
39 Stop get rgb data, get IMU Stop getting rgb data and restart getting imu data Used to test rgb camera data RGB
40 Stop get IMU, set rbg format Stop getting imu and set rgb format Used to test rgb format seeting RGB format
41 Stop get IMU, set rbg exposure mode, white balance control, ISO level, EXP level Stop getting imu and set rgb exposure mode, white balance control ISO level and EXP level Used to test rgb camera setting RGB
42 Stop get IMU, set eyetracking exposure, gain Stop getting imu and set eyetracking exposure and gain data Used to test eyetracking setting ET
43 Stop get IMU, set eyetracking led control Stop getting imu and set eyetracking led control Used to test eyetracking led control setting ET
44 Stop get IMU, read fisheye calibration Stop getting imu and read fisheye calibration Used to test fisheye calibration fisheye calibration
45 Stop get IMU, read TOF calibration Stop getting imu and read TOF calibration Used to test TOF calibration TOF calibration
46 Stop get IMU, set TOF stream mode Stop getting imu and set TOF stream mode Used to test TOF stream mode setting TOF mode
47 Stop get IMU, set TOF distance mode Stop getting imu and set TOF distance mode Used to test TOF distance mode setting TOF Distance
48 Stop get IMU, set event data Stop getting imu and register event callback to get event data Used to test event callback data event
49 Stop get IMU, set CNN data Stop getting imu and register CNN callback to get CNN data Used to test CNN callback data CNN
50 Stop get IMU, get gesture stream data Stop getting imu and register gesture callback, get gesture stream data Used to test gesture stream data gesture
51 Stop get gesture stream data, get IMU Stop getting gesture stream and restart getting imu Used to test gesture stream data gesture
52 Stop get IMU, get dynamic gesture stream data Stop getting imu and register dynamic gesture callback, get dynamic gesture stream data Used to test dynamic gesture stream data dynamic gesture stream
53 Stop get dynamic gesture stream data, get IMU Stop getting dynamic gesture stream and restart getting imu Used to test dynamic gesture stream data dynamic gesture stream
54 Stop get IMU, get gesture keypoints Stop getting imu and register gesture keypoints callback, get gesture keypoints data Used to test gesture keypoints data gesture keypoints
55 Stop get gesture keypoints, get IMU Stop getting gesture keypoints and restart getting imu Used to test gesture keypoints data gesture keypoints
56 Stop get IMU, get gesture keypoints based on slam Stop getting imu and register gesture keypoints callback, get gesture keypoints data with slam Used to test gesture keypoints data with slam gesture slam keypoints
57 Stop get gesture keypoints based on slam, get IMU Stop getting gesture keypoints with slam and restart getting imu Used to test gesture keypoints data with slam gesture slam keypoints
58 Set gesture configuration file path Stop getting imu data and set gesture configuration file path Used to test gesture configuration file path setting gesture path
59 Get display calibration Stop getting imu and get display calibration data Used to test display calibration data display calibration
60 Camera on/off switch Configure fisheye, rgb and tof camera switch Used to test camera switch camera switch
61 Start april tag detection Stop getting imu and start april-tag detection, get april-tag data Used test april-tag data April-tag
62 Stop april tag detection, get IMU Stop getting april-tag detection and restart getting imu Used test april-tag data April-tag
63 Start surface callback Stop getting imu and start surface callback, get surface callback data Used to test surface data surface
64 Stop surface callback, get IMU Stop getting surface callback data and restart getting imu Used to test surface data surface
65 Start event callback Stop getting imu and start event callback, get event callback data Used to test event data event
66 Stop event callback, get IMU Stop getting event callback data and restart getting imu Used to test event data event
67 Stop get IMU, start SGBM Stop getting imu and start SGBM callback, get SGBM callback data Used to test SGBM data SGBM
68 Stop SGBM, get IMU Stop getting SGBM callback data and restart getting imu Used to test SGBM data SGBM
69 Stop get IMU, start get gaze data Stop getting imu and start gaze callback, get gaze callback data Used to test gaze data GAZE
77 Start get device status data Stop getting imu and start device status callback, get device status callback data Used to test device status data device status
78 Stop get device status data Stop getting device status callback data and restart getting imu Used to test device status data device status
79 Stop get IMU, switch the fisheye resolution to HIGH Stop getting imu and switch fisheye resolution to HIGH Used to test fisheye resolution setting fisheye resolution mode
80 Stop get IMU, switch the fisheye resolution to MEDIUM Stop getting imu and switch fisheye resolution to MEDIUM Used to test fisheye resolution setting fisheye resolution mode
81 Stop get fisheye data, get IMU Stop getting fisheye data and restart getting imu Used to test fisheye data fisheye
82 Start RGBD Stop getting imu and start RGBD callback, get RGBD callback data Used to test RGBD data RGBD
83 Stop RGBD, get IMU Stop getting RGBD callback data and restart getting imu Used to test RGBD data RGBD
84 Change FE framerate into 50Hz Stop getting imu and set fisheye framerate to 50Hz Used to test fisheye framerate setting fisheye framerate
85 Change FE framerate into 60Hz Stop getting imu and set fisheye framerate to 60Hz Used to test fisheye framerate setting fisheye framerate

C/C++
Xvisio SDK Documentation Home Page