Skip to content

Atlas200dk/sample-headposeestimation

Repository files navigation

English|中文

Head Pose Estimation

This application can run on the Atlas 200 DK to collect camera data in real time and predict head pose information in the video.

The applications in the current version branch adapt to DDK&RunTime 1.32.0.0 and later.

Prerequisites

Before deploying this sample, ensure that:

  • Mind Studio has been installed.
  • The Atlas 200 DK developer board has been connected to Mind Studio, the cross compiler has been installed, the SD card has been prepared, and basic information has been configured.

Deployment

You can use either of the following methods:

  1. Quick deployment: visit https://github.com/Atlas200dk/faster-deploy.

    NOTE:

    • The quick deployment script can be used to deploy multiple samples rapidly. Select headposeestimation.
    • The quick deployment script automatically completes code download, model conversion, and environment variable configuration. To learn about the detailed deployment process, select the common deployment mode. Go to 2. Common deployment.
  2. Common deployment: visit https://github.com/Atlas200dk/sample-README/tree/master/sample-headposeestimation.

    NOTE:

    • In this deployment mode, you need to manually download code, convert models, and configure environment variables. After that, you will have a better understanding of the process.

Build

  1. Open the project.

    Go to the directory that stores the decompressed installation package as the Mind Studio installation user in CLI mode, for example, $HOME/MindStudio-ubuntu/bin. Run the following command to start Mind Studio:

    ./MindStudio.sh

    Open the sample-headposeestimation project.

  2. Configure project information in the src/param_configure.conf file.

    For details, see Figure 1.

    Figure 1 Configuration file

    The default configurations of the configuration file are as follows:

    remote_host=192.168.1.2
    data_source=Channel-1
    presenter_view_app_name=video
    
    • remote_host: IP address of the Atlas 200 DK developer board
    • data_source: camera channel. The value can be Channel-1 or Channel-2. For details, see "Viewing the Channel to Which a Camera Belongs" in Atlas 200 DK User Guide.
    • presenter_view_app_name: value of View Name on the Presenter Server page, which must be unique. The value consists of at least one character and supports only uppercase letters, lowercase letters, digits, and underscores (_).

    NOTE:

    • All the three parameters must be set. Otherwise, the build fails.
    • Do not use double quotation marks ("") during parameter settings.
    • Modify the default configurations as required.
  3. Run the deploy.sh script to adjust configuration parameters and download and compile the third-party library. Open the Terminal window of Mind Studio. By default, the home directory of the code is used. Run the deploy.sh script in the background to deploy the environment, as shown in Figure 2.

    Figure 2 Running the deploy.sh script

    NOTE:

    • During the first deployment, if no third-party library is used, the system automatically downloads and builds the third-party library, which may take a long time. The third-party library can be directly used for the subsequent build.
    • During deployment, select the IP address of the host that communicates with the developer board. Generally, the IP address is that configured for the virtual NIC. If the IP address is in the same network segment as the IP address of the developer board, it is automatically selected for deployment. If they are not in the same network segment, you need to manually type the IP address of the host that communicates with the developer board to complete the deployment.
  4. Start building. Open Mind Studio and choose Build > Build > Build-Configuration from the main menu. The build and run folders are generated in the directory, as shown in Figure 3.

    Figure 3 Build and files generated

    NOTICE:
    When you build a project for the first time, Build > Build is unavailable. You need to choose Build > Edit Build Configuration to set parameters before the build.

  5. Start Presenter Server.

    Open the Terminal tab page of Mind Studio. By default, under the code storage path, run the following command to start the Presenter Server program of the head pose estimation application on the server, as shown in Figure 4.

    bash run_present_server.sh

    Figure 4 Starting Presenter Server

    When the message Please choose one to show the presenter in browser(default: 127.0.0.1): is displayed, type the IP address (usually IP address for accessing Mind Studio) used for accessing the Presenter Server service in the browser.

    Select the IP address used by the browser to access the Presenter Server service in Current environment valid ip list, as shown in Figure 5.

    Figure 5 Project deployment

    Figure 6 shows that the Presenter Server service has been started successfully.

    Figure 6 Starting the Presenter Server process

    Use the URL shown in the preceding figure to log in to Presenter Server. The IP address is that typed in Figure 5 and the default port number is 7007. The following figure indicates that Presenter Server has been started successfully.

    Figure 7 Home page

    The following figure shows the IP address used by Presenter Server and Mind Studio to communicate with the Atlas 200 DK.

    Figure 8 IP address example

    In the figure:

    • The IP address of the Atlas 200 DK developer board is 192.168.1.2 (connected in USB mode).
    • The IP address used by Presenter Server to communicate with the Atlas 200 DK is in the same network segment as the IP address of the Atlas 200 DK on the UI Host server, for example, 192.168.1.223.
    • The following describes how to access the IP address (such as 10.10.0.1) of Presenter Server using a browser. Because Presenter Server and Mind Studio are deployed on the same server, you can access Mind Studio through the browser using the same IP address.

Run

  1. Run the head pose estimation program.

    On the toolbar of Mind Studio, click Run and choose Run > Run 'sample-headposeestimation'. As shown in Figure 9, the executable application is running on the developer board.

    Figure 9 Application running sample

  2. Use the URL displayed upon the start of the Presenter Server service to log in to Presenter Server.

    Wait for Presenter Agent to transmit data to the server. Click Refresh. When there is data, the icon in the Status column for the corresponding channel changes to green, as shown in Figure 10.

    Figure 10 Presenter Server page

    NOTE:

    • For the head pose estimation application, Presenter Server supports a maximum of 10 channels at the same time (each presenter_view_app_name parameter corresponds to a channel).
    • Due to hardware limitations, each channel supports a maximum frame rate of 20 fps. A lower frame rate is automatically used when the network bandwidth is low.
  3. Click the link (such as video in the preceding figure) in the View Name column to view the result. The confidence of the detected head pose is marked.

Follow-up Operations

  • Stopping the head pose estimation application

    The head pose estimation application is running continually after being executed. To stop it, perform the following operation:

    Click the stop button shown in Figure 11 to stop the head pose estimation application.

    Figure 11 Stopping the head pose estimation application

    Figure 12 shows that the head pose estimation application has been stopped.

    Figure 12 Head pose estimation stopped

  • Stopping the Presenter Server service

    The Presenter Server service is always in running state after being started. To stop the Presenter Server service of the head pose estimation application, perform the following operations:

    On the server with Mind Studio installed, run the following command as the Mind Studio installation user to check the process of the Presenter Server service corresponding to the head pose estimation application:

    ps -ef | grep presenter | grep headposeestimation

    ascend@ascend-HP-ProDesk-600-G4-PCI-MT:~/sample-headposeestimation$ ps -ef | grep presenter | grep headposeestimation 
     ascend    7701  1615  0 14:21 pts/8    00:00:00 python3 presenterserver/presenter_server.py --app Head_pose
    

    In the preceding information, 7701 indicates the process ID of the Presenter Server service for the head pose estimation application.

    To stop the service, run the following command:

    kill -9 7701