English|中文
The Ascend camera application collects data through the camera on the Atlas 200 DK developer board, convert the data into JPG by using the digital vision pre-processing (DVPP) module, and save the video streams as files or remote output.
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 ascendcamera.
- 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-ascendcamera.
- In this deployment mode, you need to manually download code, convert models, and configure environment variables.
-
Open the project.
Go to MindStudio-ubuntu/bin under the installation package decompression directory (for example, $HOME/MindStudio-ubuntu/bin) as the Mind Studio installation user and run the following command to start Mind Studio:
./MindStudio.sh
After the startup is successful, open the sample-ascendcamera project, as shown in the following figure.
-
Configure project information in the src/param_configure.conf file.
Figure 2 Configuration file path
The default configurations of the configuration file are as follows:
remote_host=192.168.1.2
- remote_host: IP address of the Atlas 200 DK developer board
- 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 Figure 3.
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 path, run the following command to start the Presenter Server program of the Ascend camera 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 (only Google Chrome is supported). The IP address is that typed in Figure 6 and the default port number is 7003. 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.
- 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 Ascend camera application.
On the toolbar of Mind Studio, click Run and choose Run > Run 'sample-ascendcamera'. As shown in Figure 10, the application is running on the developer board.
NOTE:
You can ignore the error information reported during the execution because the IDE cannot transfer parameters for an executable application. In the preceding steps, the executable application and dependent library files are deployed to the developer board. You need to log in to the developer board in SSH mode and manually execute the files in the corresponding directory. For details, see the following steps.
-
Log in to the developer board as the HwHiAiUser user in SSH mode on Ubuntu Server where Mind Studio is located.
ssh HwHiAiUser@192.168.1.2
For the Atlas 200 DK, the default value of host_ip is 192.168.1.2 (USB connection mode) or 192.168.0.2 (NIC connection mode).
For the AI acceleration cloud server, host_ip indicates the IP address of the server where Mind Studio is located.
-
Go to the path of the executable file of the Ascend camera application and run the following command:
cd ~/HIAI_PROJECTS/workspace_mind_studio/sample-ascendcamera_5b4f8b24/out
-
Run workspace_mind_studio_sample-ascendcamera to save the media information offline.
Obtain an image from the camera and save it as a .jpg file. If a file with the same name already exists, overwrite it.
./workspace_mind_studio_sample-ascendcamera -i -c 1 -o /localDirectory/filename.jpg --overwrite
-
-i: indicates that a JPG image is obtained.
-
-c: indicates the channel to which a camera belongs to. This parameter can be set to 0 or 1. The value 0 corresponds to Camera1, and the value 1 corresponds to Camera2. If this parameter is not set, the default value 0 is used.
For details, see "Viewing the Channel to Which a Camera Belongs" in Atlas 200 DK User Guide.
-
-o: indicates the file storage location. localDirectory is the name of a local folder. filename.jpg is the name of a saved image, which can be user-defined.
NOTE:
The HwHiAiUser user must have the read and write permissions on the path. -
--overwrite: Overwrites the existing file with the same name.
For other parameters, run the ./ workspace_mind_studio_sample-ascendcamera command or the ./ workspace_mind_studio_sample_ascendcamera --help command. For details, see the help information.
-
-
Log in to the developer board as the HwHiAiUser user in SSH mode on Ubuntu Server where Mind Studio is located.
ssh HwHiAiUser@192.168.1.2
-
Go to the path of the executable file of the Ascend camera application and run the following command:
cd ~/HIAI_PROJECTS/workspace_mind_studio/sample-ascendcamera_5b4f8b24/out
-
Run the following command to transmit the video captured by the camera to Presenter Server:
./workspace_mind_studio_sample-ascendcamera -v -c 1 -t 60 --fps 20 -w 704 -h 576 -s 192.168.1.233:7002/presenter_view_app_name
-
-v: indicates that the video of the camera is obtained and displayed on the Presenter Server.
-
-c: indicates the channel to which a camera belongs to. This parameter can be set to 0 or 1. The value 0 corresponds to Camera1, and the value 1 corresponds to Camera2. If this parameter is not set, the default value 0 is used.
For details, see "Viewing the Channel to Which a Camera Belongs" in Atlas 200 DK User Guide.
-
-t: indicates that a video file lasting 60 seconds is obtained. If this parameter is not specified, the video file is obtained until the application exits.
-
--fps: indicates the frame rate of a saved video. The value range is 1–20. The default video frame rate is 10 fps.
-
-w: indicates the width of a saved video.
-
-h: indicates the height of a saved video.
-
The value 192.168.1.223 after -s refers to the IP address of port 7002 of Presenter Server, as shown in the information displayed after Presenter Server is started. It is also the IP address for communicating with the Atlas 200 DK developer board. 7002 is the default port number of Presenter Server for the Ascend camera application.
-
presenter_view_app_name: indicates the value of View Name on the Presenter Server page, which must be unique. The value consists of 3 to 20 characters and supports only uppercase letters, lowercase letters, digits, and underscores (_).
For other parameters, run the ./workspace_mind_studio_sample-ascendcamera command or the ./workspace_mind_studio_sample-ascendcamera --help command. For details, see the help information.
- The Presenter Server of the Ascend camera application 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.
-
The Presenter Server service is always in running state after being started. To stop the Presenter Server service of the Ascend camera 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 Ascend camera application:
ps -ef | grep presenter | grep display
ascend@ascend-HP-ProDesk-600-G4-PCI-MT:~/sample-ascendcamera$ ps -ef | grep presenter | grep display
ascend 5758 20313 0 14:28 pts/24?? 00:00:00 python3 presenterserver/presenter_server.py --app display
In the preceding information, 5758 indicates the process ID of the Presenter Server service corresponding to the Ascend camera application.
To stop the service, run the following command:
kill -9 5758