English|中文
You can deploy this application on the Atlas 200 DK to collect camera data in real time and predict facial information in the video.
The applications in the current version branch adapt to DDK&RunTime 1.32.0.0 and later.
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.
You can use either of the following methods:
-
Quick deployment: visit https://github.com/Atlas200dk/faster-deploy.
- The quick deployment script can be used to deploy multiple samples rapidly. Select the face detection deployment sample.
- The quick deployment script automatically completes code download, model conversion, and environment variable configuration. To learn about the detailed deployment process, go to 2. Common deployment.
-
Common deployment: visit https://github.com/Atlas200dk/sample-README/tree/master/sample-facedetection.
- In this deployment mode, you need to manually download code, convert models, and configure environment variables.
-
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-facedetection project, as shown in Figure 1.
-
Configure project information in the src/param_configure.conf file.
For details, see Figure 2.
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 (_).
- 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.
-
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 Executing the deploy script.
Figure 3 Running the deploy.sh script
- 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.
-
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 4.
Figure 4 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. -
Start Presenter Server.
Open the Terminal window of Mind Studio. Under the code storage path, run the following command to start the Presenter Server program of the face detection application on the server, as shown in Figure 5:
bash run_present_server.sh
Figure 5 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 6.
Figure 7 shows that the Presenter Server service has been started successfully.
Figure 7 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 6 and the default port number is 7007. The following figure indicates that Presenter Server has been started successfully.
The following figure shows the IP address used by Presenter Server and Mind Studio to communicate with the Atlas 200 DK.
In the preceding 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 the face detection application.
On the toolbar of Mind Studio, click Run and choose Run > Run 'sample-facedetection'. As shown in Figure 10, the executable application is running on the developer board.
-
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 the following figure.
Figure 11 Presenter Server page
- For the face detection 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.
-
Run the deploy.sh script to adjust configuration parameters and download and compile the third-party library. Open the Terminal tab page 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 the figure.
- During the first deployment, if no third-party library is used, the system automatically downloads and compiles the third-party library, which may take a long time. The third-party library can be directly used for the subsequent compilation.
- During deployment, select the IP address of the host that communicates with the developer board. Generally, the IP address is the IP address 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 Atlas DK to complete the deployment.
-
Click the link (such as video in the preceding figure) in the View Name column to view the result. The confidence of the detected human face is marked.
-
Stopping the face detection application
The face detection application is running continually after being executed. To stop it, perform the following operation:
Click the stop button shown in Figure 12 to stop the face detection application.
Figure 12 Stopping face detection
Figure 13 shows that the face detection application has been 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 face detection 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 face detection application:
ps -ef | grep presenter | grep face_detection
ascend@ascend-HP-ProDesk-600-G4-PCI-MT:~/sample-facedetection$ ps -ef | grep presenter | grep face_detection ascend 7701 1615 0 14:21 pts/8 00:00:00 python3 presenterserver/presenter_server.py --app face_detection
In the preceding information, 7701 indicates the process ID of the Presenter Server service for the face detection application.
To stop the service, run the following command:
kill -9 7701