DensityAnnotator: Annotation tool that creates a density map from image data

kenya-sk
2 min readJan 13, 2022

The Japanese version is here.

Abstract

I developed “DensityAnnotator”, a GUI annotation tool that creates density map from image or video data. In DensityAnnotator, the image is loaded and the target individual is tagged with the left mouse click.

An example of the annotation process is show in Figure 1. First, load the image to be annotated (left side of Fig.1). After that, CUI window is launched and the target individual is tagged with a left mouse click. The tag is represented by a red dot in the image (middle of Fig.1). When you have finished tagging all the individuals, press the “s” key on your keyboard to save current work on the loaded image and exit. When you save the image, a density map is calculated based on the coordinates of the tagged individuals, and saved as a numpy array in “.npy” format (right side of Fig.1). In the case of video data, the same process is repeated for images by pressing the “p” key in the tool and cutting the data into frames at any given time.

Figure 1. annotation process

How to use the tool

The versions of the dependent libraries are managed by Poetry. Therefore, you will need to install Poetry itself before using it. You can easily install it using pip, etc., referring to the official documentation here. After that, run the poetry install command in the cloned DensityAnnotator root directory to install the dependent libraries.

After installing the dependent libraries, run scripts/run_annotator.sh to launch the GUI tool, which provides the following four key operations.

Key operations

  • q key: Exit the annotation process and close the GUI tool.
  • p key: Pause the video and start annotation process.
  • d key: Delete the previous tagging result.
  • s key: Save the annotation work.

The settings for the data to be loaded, etc., can be defined in the conf/annotator.yaml file. The five main settings that need to be made are as follows Annotated images, coordinate information, and density maps are saved in save_annotated_dir/image, save_annotated_dir/coord, and save_annotated_dir/dens, respectively

Parameter of config

  • sigma_pow: Standard deviation used to calculate the density map
  • input_file_path: File path of the image or video to be loaded
  • save_raw_image_dir: Directory to save the image cut out from the video.
  • save_annotated_dir: Directory to save the annotated results.
  • save_image_extension: Format of the image to be saved.

--

--