A client library to call the LVM API with some helpful functions
Project description
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"))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
alert_lvm-1.0.0.tar.gz
(3.8 kB
view details)
Built Distribution
File details
Details for the file alert_lvm-1.0.0.tar.gz
.
File metadata
- Download URL: alert_lvm-1.0.0.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 23a32d56716b99a02be3c45d65c8f1c210ac046e06cbc2013fa699da1c5ef9e7 |
|
MD5 | dbb80b0130a949081e55211ca79c146f |
|
BLAKE2b-256 | 97422be3c1cce0f47c8857ea0ef68bcd3c520782250ca9e4c3eef42e4a35d66e |
File details
Details for the file alert_lvm-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: alert_lvm-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0203fe85ec9a5a9a0410701f80672e10eaf5ceec2ae8834efcc4adbba2eeabd6 |
|
MD5 | 756c4188c3b2c365223a58a97f196c8d |
|
BLAKE2b-256 | a0af684fdb3219fc7f350e26df0fd5babdd7f6f526381633097807302e3f23f1 |