Skip to main content

Installation

You can install the alert-lvm from PyPI:

pip install alert-lvm

How to use

Analyze image:

from alertlvm import AlertLVM

client = AlertLVM(
    token="<your token here>"
)

scenario_key = "<the key>"

image_path = "<image_path>"

result = client.analyze(scenario_key, image_path)
if result.get("error"):
    print(result.get("code"))
    print(result.get("error_message"))
else:
    print(result.get("conclusion")) # conclusion of the analysis
    print(result.get("text")) # detail content of the analysis

    # ... your code here ...

    os.remove(result.get("frame"))

Analyze video:

The default setting is to extract and analyze one frame every 750 frames (250 frames/second * 30 seconds):

import os
from alertlvm import AlertLVM

client = AlertLVM(
    token="<your token here>"
)

scenario_key = "<the key>"

video_path = "<video_path>"

for result in client.analyzeVideo(scenario_key, video_path):
    if result.get("error"):
        print(result.get("code"))
        print(result.get("error_message"))
    else:
        print(result.get("frame")) # the file path of a frame extracted from the video that has been sent to the server
        print(result.get("conclusion")) # conclusion of the analysis
        print(result.get("text")) # detail content of the analysis

        # ... your code here ...

        os.remove(result.get("frame"))

You can also define your own frame extraction strategy, which can be based on interval:

def filter(index, frame):
    return index % 900 == 0 # every 900 frames

or you can first process the content of the frames:

def filter(index, frame):
    b = process(frame) # define a function to decide if the frame need be analyzed
    return b

and then use the filter function

import os
from alertlvm import AlertLVM

client = AlertLVM(
    token="<your token here>"
)

scenario_key = "<the key>"

video_path = "<video_path>"

for result in client.analyzeVideo(scenario_key, video_path, filter):
    if result.get("error"):
        print(result.get("code"))
        print(result.get("error_message"))
    else:
        print(result.get("frame")) # the file path of a frame extracted from the video that has been sent to the server
        print(result.get("conclusion")) # conclusion of the analysis
        print(result.get("text")) # detail content of the analysis

        # ... your code here ...

        os.remove(result.get("frame"))

Show result:

Please note that the show method will block the current thread. You can press the 'q' key or use the close button to close the current window. Only after this will the program continue to execute.

import os
from alertlvm import AlertLVM

client = AlertLVM(
    token="<your token here>"
)

scenario_key = "<the key>"

video_path = "<video_path>"

for result in client.analyzeVideo(scenario_key, video_path):
    if 'error' not in result:
        print(result.get("text")) # detail content of the analysis
        client.show(result) # show result
        os.remove(result.get("frame"))

Release files for alert-lvm 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for alert-lvm 1.1.0
File Size Uploaded
alert_lvm-1.1.0.tar.gz 4.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for alert-lvm 1.1.0
File Interpreter ABI Platform
alert_lvm-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.6 kB

Release files / alert_lvm-1.1.0.tar.gz

Download URL alert_lvm-1.1.0.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4866929d48eb298676b672a98ec5d5f5ee9ed3d499a19141876ba155f901c66f
BLAKE2b-256 checksum
How to use checksums
9c3f047d7042fad021fe0bfd1cde67a6278325669bf1acef7796e71369078597
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.11.9

Release files / alert_lvm-1.1.0-py3-none-any.whl

Download URL alert_lvm-1.1.0-py3-none-any.whl
Size 5.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b6c0f1883c59ce02b793fdb240f47f48226b7d23c61b5c9259509967ec646a0e
BLAKE2b-256 checksum
How to use checksums
3c861632b08350d9ce30913d99069beb3975212f7dfff7e98772343223f35cda
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.11.9

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page