Video Analysis Environment Configuration

The video analysis and machine learning functions provided by SuperMap iDesktopX require a Python environment and scripts to execute. Due to the large disk space occupied by the environment package, the relevant environment is not included in the basic product package. If you need to use functions such as video analysis and machine learning, you need to download the extension package and perform simple environment configuration.

The recommended configuration for video analysis is as follows:

  • If the number of video channels used is more than 10, and each channel is detected every 5 seconds, the CPU has the greatest impact on performance. A server CPU is required. The recommended hardware configuration is as follows:
    • CPU: Two Intel(R) Xeon(R) Gold 5218 CPU @ 2.30GHz, 16 cores and 32 threads;
    • Memory: 32G;
    • Graphics card: RTX 2060;
    • Hard disk: Solid-state drive.
  • If the number of video channels used is less than 10, but each channel requires real-time analysis (detection and tracking), the graphics card has the greatest impact on performance, followed by the CPU, and finally the memory. The recommended hardware configuration is as follows:
    • CPU: One Intel(R) Xeon(R) Gold 5218 CPU @ 2.30GHz, 16 cores and 32 threads (if using PyTorch models, an i9 12900k can also suffice);
    • Memory: 128G (or 64G for Windows);
    • Graphics card: RTX 3090 or RTX 3090TI;
    • Hard disk: Solid-state drive, size depends on the size of saved videos.

The recommended graphics card configuration for machine learning is as follows:

  • NVIDIA graphics card;
  • Video memory ≥10G, minimum requirement is 6G. If using object extraction or SegmentAnything models for AI annotation, video memory must be greater than 8G;
  • Latest graphics card drivers.

Environment configuration process:

The steps for environment configuration are shown in the flowchart below. Steps ③, ④, and ⑤ in configuring the video analysis environment are not mandatory and can be configured as needed.

1. Configure the Extension Package

Obtain the Extension Package

Download the SuperMap iDesktopX Extension_AI for Windows extension package (hereinafter referred to as the extension package) corresponding to the version of the SuperMap iDesktopX product package (hereinafter referred to as the product package).

The download address is: https://pan.baidu.com/s/10Ec2T7HcHG0UAXR2D59UAw, extraction code: rdpd.

The extension package provides the following resources:

  • resources_ml: Machine learning resource package, containing sample data, model config files, and other resources;
  • support:
    • MiniConda: Runtime environment for AI analysis.
  • templates: Video effects resources.

Configure the Extension Package

Copy the resource_ml, support, and templates folders from the extension package to the root directory of the product package. The path of the product package must not contain Chinese characters.

2. Configure the Python Environment

  1. Open SuperMap iDesktopX, click the Start tab -> Browse group -> Python button, and the Python window will pop up below the map.
  2. Click the Python Environment Manager button on the left toolbar of the Python window to open the Python Environment Manager dialog.
  3. Click the Add Exist Environment button to open the Add Exist Environment dialog.
  4. In the Python path, select product package root directory/support/MiniConda/conda/python.exe, and the Conda path will be automatically recognized.
  5. Click the OK button in the Add Exist Environment dialog. After loading the Python environment, click the OK button in the Python Environment Manager dialog.
  6. A prompt dialog will appear: "The Python environment has been switched. Do you want to restart the Python process immediately?" Click Yes to complete the Python environment configuration.

3. Configure the Video Analysis Environment

Configure the Video Analysis Model

  1. Download the video analysis model corresponding to the product package version. The download address is: https://pan.baidu.com/s/1WZYDn6RJGsu05Gj-5vZZzQ?pwd=n4kd, extraction code: n4kd.
  2. Copy the downloaded video-detection folder to the product package root directory/support folder.

Configure the Video Analysis Code

  1. Download the video analysis code resource package corresponding to the product package version from https://gitee.com/SuperMapDesktop/deep-sort-yolov4.
  2. Copy the contents of the downloaded video analysis code resource package deep-sort-yolov4-x (x is the version identifier, e.g., if selecting the 11.2.0 branch, the package name is "deep-sort-yolov4-11.2.0") folder to the product package/support/video-detection/deep-sort-yolov4 folder.

High-Performance Video Analysis Environment

To improve the detection performance of video analysis, it is recommended to configure the Redis environment. Ensure Redis is started before using high-performance detection. The Redis environment configuration is as follows:

  1. Download Redis and extract it.
  2. Double-click to start redis-server.exe in the Redis product package directory.
  3. Open the iDesktopX product package/configuration/Desktop.Parameter.xml file and change HighPerformanceDetection="false" to HighPerformanceDetection="true".
  4. Start SuperMap iDesktopX.

Push Live Stream

Video analyst results can be pushed as a live stream for easy viewing on the web. However, this process requires additional environment deployment. The instructions are as follows:

  1. Download ffmpeg from the official website. Download address: https://github.com/BtbN/FFmpeg-Builds/releases.
  2. After extraction, copy ffmpeg.exe to the product package root directory/support/video-detection/Tools/ directory.

TensorRT Model Transformation

SuperMap iDesktopX supports transforming YOLOv5 Torch models into TensorRT format, currently supporting Windows 10 and above. The environment deployment is as follows:

  1. Download Miniconda3. Download address: https://docs.conda.io/en/latest/miniconda.html. You can choose versions 3.8, 3.9, or 3.10. Click to download and install.
  2. Download the TensorRT package and extract it. Click to download the package from: https://developer.nvidia.com/nvidia-tensorrt-8x-download;
  3. In the Windows Start menu, run Miniconda3 as an administrator to open a console window;
  4. Enter conda activate conda_path, where conda_path is the path after configuring the AI extension package;
  5. In the console, navigate to the extracted TensorRT package directory and install graphsurgeon, uff, onnx_graphsurgeon, and TensorRT by executing the following commands in order:
      cd .\graphsurgeon\
      pip install .\graphsurgeon-0.4.6-py2.py3-none-any.whl
      cd ../
      d .\uff\
      pip install .\uff-0.6.9-py2.py3-none-any.whl
      cd ../
      cd .\onnx_graphsurgeon\
      pip install .\onnx_graphsurgeon-0.3.12-py2.py3-none-any.whl
      cd ../
      cd .\python\
      pip install .\tensorrt-8.6.1-cp38-none-win_amd64.whl
    
    Note:

    When installing TensorRT, decide which one to install based on the Python version:

    • Version 3.8 corresponds to tensorrt-8.6.1-cp38-none-win_amd64.whl
    • Version 3.9 corresponds to tensorrt-8.6.1-cp39-none-win_amd64.whl
    • Version 3.10 corresponds to tensorrt-8.6.1-cp310-none-win_amd64.whl
  6. Copy all dll files from the lib folder in the extracted TensorRT package directory to the product package root directory/support/video-detection/TensorRT/.