- 22 Dec 2023
- 4 Minutes to read
- Print
- DarkLight
Applications - Replay
- Updated on 22 Dec 2023
- 4 Minutes to read
- Print
- DarkLight
The application replay endpoint allows users to resubmit, or "replay" media in the Cogniac System that is readable by them, through an application for new detections.
The replay endpoint provides the user the ability to choose which subjects' associated media to replay through the application, not limited to the subjects bound to the application, as well as filters based on time and subject-media association probability.
Argument | Example | Description |
---|---|---|
replay_subjects | ["cat_1a", "bird_9g"] | (required) The list of subject_uids of the subject media to replay. Can be any subject that is readable by the authorized tenant. Several subjects can be replayed at once by passing multiple flags. |
replay_media | "AJW63NCGIH4NTYVRME" | (required) The media ID of a single media item to replay. |
validation_only | True | (optional) Replay from validation set only. |
foci | [{'box': {'x0': 0, 'y0': 50, 'x1': 100, 'y1': 150}}] | (optional) For replaying individual media, will replay media foci through the application. |
replay_order | "first" | (optional) One of 'first', 'last', 'random', 'highest_probability', 'lowest_probability'. Determines the order of media to replay. |
probability_lower | 0.75 | (optional) A lower bound for subject-media association probabilities to replay. |
probability_upper | 0.90 | (optional) An upper bound for subject-media association probabilities to replay. |
time_lower | 1643650235 | (optional) A lower limit of subject-media update timestamp to replay. |
time_upper | 1643653191 | (optional) An upper limit of subject-media update timestamp to replay. |
limit | 135 | (optional) A maximum limit of media items to replay. |
force_feedback | True | (optional) |
replay_filters | [{"filter": "ocr", "ocr_string": "plane"}] | (optional) |
Send Replay Request
To replay media through an application, POST a replay request message to the application replay endpoint with the appropriate replay flag set.
The POST response contains a list of replaying subjects and a map of replay specifications for each subject.
POST /21/applications/{app_ids}/replay
Host: https://api.cogniac.io
Example: Replay Media
curl -X POST https://api.cogniac.io/21/applications/di71rG94/replay \
-H "Content-Type: application/json" \
-H "Authorization: Bearer abcdefg.hijklmnop.qrstuvwxyz" \
-d '{
"replay_subjects": ["subject_uid"],
"limit": 10,
"replay_order": "random",
"force_feedback": true
}'
import requests
import json
my_headers = {"Authorization":"Bearer abcdefg.hijklmnop.qrstuvwxyz"}
replay_data = {
"replay_subjects": ['Pl-Copy', 'D-Copy'],
"limit": 100,
"replay_order": 'random',
"force_feedback": True
}
resp = requests.post("https://api.cogniac.io/21/applications/ra7vf9zl/replay",
json=replay_data,
headers=my_headers)
if resp.status_code == 200:
formatted_json = json.dumps(resp.json(), indent=2)
print(formatted_json)
else:
print(f"Error: {resp.status_code}")
print(resp.content)
[
{
"user_id": "test@cogniac.co",
"created_at": 1701299362.548027,
"replay_status": {
"status": "in-progress",
"replayed": 0,
"skipped": 0,
"selected": 0,
"processed": 0,
"filtered": 0
},
"replay_arguments": {
"time_lower": 0.0,
"time_upper": 1701299362.533204,
"foci": null,
"replay_order": "random",
"replay_subjects": [
"D-Copy",
"Pl-Copy"
],
"validation_only": false,
"force_feedback": true,
"limit": 100.0,
"probability_upper": 1.0,
"probability_lower": 0.0,
"replay_filters": []
},
"app_id": "ra7vf9zl",
"replay_id": "fm4sggf8",
"active": 1
}
]
Note, that you can request replay of the same subject or media on multiple apps simultaneously by specifying a comma-separated list of application ids, for example, POST https://api.cogniac.io/21/applications/di71rG94,iOkJhg,uYheTh/replay.
Get Replay Status of a Single Replay
The current replay status of an application can be received via a GET call to the application replay endpoint.
GET /21/applications/{app_id}/replay/{replay_id}
Host: https://api.cogniac.io
Example: Retrieve Replay Status
curl -X GET https://api.cogniac.io/21/applications/ra7vf9zl/replay/fm4sggf8 \
-H "Authorization: Bearer abcdefg.hijklmnop.qrstuvwxyz"
import requests
import json
my_headers = {"Authorization":"Bearer abcdefg.hijklmnop.qrstuvwxyz"}
resp = requests.get("https://api.cogniac.io/21/applications/ra7vf9zl/replay/fm4sggf8",
headers=my_headers)
# Check if the request was successful
if resp.status_code == 200:
# Parse the content as JSON and print it with indentation for better readability
formatted_json = json.dumps(resp.json(), indent=2)
print(formatted_json)
else:
print(f"Error: {resp.status_code}")
print(resp.content)
{
"active" : 0,
"app_id" : "ra7vf9zl",
"created_at" : 1701299362.54803,
"replay_arguments" : {
"foci" : null,
"force_feedback" : true,
"limit" : 100,
"probability_lower" : 0,
"probability_upper" : 1,
"replay_filters" : [],
"replay_order" : "random",
"replay_subjects" : [
"D-Copy",
"Pl-Copy"
],
"time_lower" : 0,
"time_upper" : 1701299362.5332,
"validation_only" : false
},
"replay_id" : "fm4sggf8",
"replay_status" : {
"filtered" : 0,
"processed" : 0,
"replayed" : 0,
"selected" : 0,
"skipped" : 0,
"status" : "success"
},
"user_id" : "test@cogniac.co"
}
Get Replay Status of All Active Application Replays
GET /21/applications/{app_id}/replay/active
Host: https://api.cogniac.io
Get Replay Status of the last 100 Application Replays
GET /21/applications/{app_id}/replay?limit=100
Host: https://api.cogniac.io
Stop Application Replay
DELETE /21/applications/{app_id}/replay/{replay_id}
Host: https://api.cogniac.io