Zone Marking ToolΒΆ

Execute the Zone Marking tool to obtain keep-out geo-boundaries

  • Create a virtual environment to run the tool

    Run the following steps to create a virtual env and install tool dependencies

    python3 -m venv venv
    . venv/bin/activate
    pip install --upgrade pip
    pip install -r requirements.txt
    
  • Generate the input image

    This tool requires an input image to draw the geo boundaries on. To generate a snapshot from a video file source, execute the following command.

    ffmpeg -y -i <input_video_file> -vframes 1 -q:v 2 output.jpg
    

    Note This next step needs ffmpeg as a dependency. Also, -i option takes in the video file src path

    The above command generates the image in the same directory and is named output.jpg With the input image generated and the python env setup, the tool can be executed as follows,

    python3 zoneMarkingTool.py --image <path to the snapshot image from the previous step>
    
  • Run the tool

    Use your mouse pointer to click and select the polygon/line marking the geo boundary

    Execute python3 zoneMarkingTool.py --help for all options supported. By default the output json defining the geo boundary is stored in the same directory and is named violation_zone.json or violation_line.json

    The tool is able to generate a single polygon/line at a time. Hence to define multiple zones/lines, generate each zone/line separately and append the contents of individual output jsons to form a composite json looking like this:

    • zone violation

      {
          "zones":
              {
              "zone1": [
                  {
                      "x": 0.9890625,
                      "y": 0.019444444444444445
                  },
                  {
                      "x": 0.6880208333333333,
                      "y": 0.019444444444444445
                  },
                  {
                      "x": 0.70625,
                      "y": 0.5203703703703704
                  },
                  {
                      "x": 0.9880208333333333,
                      "y": 0.5370370370370371
                  }
                  ],
              "zone2": [
                  {
                      "x": 0.24895833333333334,
                      "y": 0.31296296296296294
                  },
                  {
                      "x": 0.4791666666666667,
                      "y": 0.3277777777777778
                  },
                  {
                      "x": 0.4786458333333333,
                      "y": 0.575
                  }
                  ]
              }
      }
      
    • line violation

      {
         "lines": {
            "line1": [
               {
                  "x": 0.30625,
                  "y": 0.49537037037037035
               },
               {
                  "x": 0.4859375,
                  "y": 0.5046296296296297
               }
            ],
          "line2": [
               {
                  "x": 0.30625,
                  "y": 0.49537037037037035
               },
               {
                  "x": 0.4859375,
                  "y": 0.5046296296296297
               }
            ]
         }
      }
      
  • Cleanup

    Run deactivate to come out of the python virtual environment

  • Change Configuration

    The video file along with the newly generated json needs to be placed at deploy/ and deply/samples/conf directories respectively The config.json file needs to be modified to reflect these changes.

    Change the intrusion detection pipeline params to point to the newly created json defining the geo boundaries

    "pipeline": [
        "person-detection-0200:a:0.3:0.3", "intrusion-detection:/home/nimble/conf/violation_zone.json", "image-resize:0.3", "image-encoder"
      ]
    

    or the line crossing pipeline params to point to the newly created json defining the line boundaries

    "pipeline": [
        "person-detection-0200:a:0.3:0.3", "line-crossing:/home/nimble/conf/violation_line.json:[1]:5:1:50", "image-resize:0.3", "image-encoder"
      ]
    

    Change the input source video to point to the new file

    "sources": [
       {
        "address": "<video file name>",
        "rate": "25",
        "type": "file"
       }
      ]