Skip to content

[Python script] Improve fake alerts creation #10

@RonanMorgan

Description

@RonanMorgan

Current Behavior

  1. the directory images/
    Two fake cameras have been created. The code is available in containers/dev_reolink and reolink_dev2. In both camera there is the following code which will download 4 images if the images/ directory doesn't exist:
# Get a list of image filenames in the directory
image_dir = "data/images"
images_name = [
    "1465065360_-00240.jpg",
    "1465065780_+00180.jpg",
    "1465066800_+01200.jpg",
    "1465068000_+02400.jpg",
]
url = "https://github.com/pyronear/pyro-devops/releases/download/v0.0.1/"

if not os.path.isfile(image_dir):
    os.makedirs(image_dir, exist_ok=True)
    for name in images_name:
        print(f"Downloading images from {url + name} ...")
        urlretrieve(url + name, image_dir + "/" + name)

Which means that both camera are using the same test images. When a GET call is done to @app.route("/cgi-bin/api.cgi") the images are sent back one after another.

  1. static vs PTZ
    The configuration file of the camera is : data/credentials.json. You can see that reolink_dev is a static camera and reolink_dev2 is a ptz camera with two poses, which means that the camera can move between two poses in order to capture images from two different point of view

The only difference in the fake camera implementation is that the ptz camera has a second route @app.route("/cgi-bin/api.cgi", methods=["POST"]) which send automatically a 200. In real camera this route is used to move the camera between poses.

Wanted Behavior

  1. Renaming the cameras
    Instead of reolink_dev and directory dev_reolink it would be better to have something like test_camera_static and test_camera_ptz

  2. Not using the same images/ directory
    Instead of checking if the directory exist we should create and commit three directories :
    data/test_images_static/
    data/test_images_ptz_pose1/
    data/test_images_ptz_pose2/

In the python code, check that they are empty. If not, download the images as we already did. For the PTZ camera, each time the POST route is used, changed the directory used from _pose1 to _pose2.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions