- 14 Nov 2024
- 5 Minutes to read
- Print
- DarkLight
Outbound Post URL
- Updated on 14 Nov 2024
- 5 Minutes to read
- Print
- DarkLight
Each application can be provisioned with a list of HTTP URLs. Detection outputs will be sent to these URLs if any output subject crosses a detection threshold. The POST URL can be configured via the Web App or through the application API. The results of the post URL are shown below.
Post URL Results
A dictionary of values is returned.
Value | Description | Details |
---|---|---|
app_id string | application id reporting the assertion | 8H88vm4v |
assertions list | A list of assertions generated by the app_id. | see “Assertion Format” below |
previous_assertions list | Assertions accumulated by upstream apps. | List of assertions. |
media | media data associated with this assertion | see Media format below |
Assertion format
Key | Description | Example |
---|---|---|
app_id string | application which generated this post URL response | 8H88vm4v |
assertion_id string | identifier associated with assertion. Usually prefixed by "EF" | EF:quUAdVKp:XGULMXFFIG:1 |
assertion_prefix string | Prefix used by all downstream apps in a pipeline | EF:quUAdVKp:XGULMXFFIG |
media_md5 string | md5 of base64 encoded image | c02525004c40575ff4131131ad44a072 |
model_id string | model which generated detection. | IVAC_Hpo-d-9g49-DmD42hkuJLSiFuWOge-YN-OW_mtsv1_INT_10000.tgz |
probability float | detection probability | 0.91259765625 |
subject_uid string | subject which crossed detection threshold. | drone_photos_6op |
Note that the media_md5 in previous assertions could differ if an application generated new media.
Media format
Key | Description |
---|---|
capture_timestamp float | timestamp when the media was captured. |
domain_unit string | domain information associated with media |
media_md5 string | md5 of base64 encoded image |
media_type string | 'image' or 'video' |
media_bytes string | base64 encoded image. |
custom_data dict | optional custom data accompanying media. |
To decode the media_bytes, a receiver of the post_url should use a base64 decoder library and pass in the media_bytes. The resultant output will be a JPEG string.
The example below illustrates the response sent to a URL from Edgeflow. The image which generated the assertion from this app is base64 encoded in the media dictionary.
{'app_id':'8H88vm4v',
'assertions': [{'app_id':'8H88vm4v',
'assertion_id':'EF:quUAdVKp:XGULMXFFIG:1',
'assertion_prefix':'EF:quUAdVKp:XGULMXFFIG',
'media_md5':'c02525004c40575ff4131131ad44a072',
'model_id':'Hpo-m-2d25-KHkIx4sG43EYsU5PzZ-GN-rf_224_224_mtsv1_2.tgz',
'probability': 4.3752895142460235e-27,
'subject_uid':'vehiclestestoutput_6jo'}],
'media': {'capture_timestamp': 1604537749.76,
'domain_unit':'1604537749',
'external_media_id':'x1abcde.jpg',
'media_md5':'c02525004c40575ff4131131ad44a072',
'media_type':'image',
'media_bytes': <redacted>,
'upload_timestamp': 1604537749.827434,
'user_id':'testuser@cogniac.co'},
'previous_assertions': [{'app_data': None,
'app_data_type': None,
'assertion_id':'EF:quUAdVKp:RDTAHRWSHT:0',
'assertion_prefix':'EF:quUAdVKp:RDTAHRWSHT',
'focus': None,
'media_md5':'c02525004c40575ff4131131ad44a072',
'subject_uid':'drone_photos_6op'},
{'app_data': [{'box': {'x0': 995,
'x1': 1112,
'y0': 1579,
'y1': 1665},
'probability': 0.91259765625},
{'box': {'x0': 1535,
'x1': 1697,
'y0': 2014,
'y1': 2118},
'probability': 0.82861328125},
{'box': {'x0': 3306,
'x1': 3401,
'y0': 542,
'y1': 627},
'probability': 1.806020736694336e-05}],
'app_data_type':'box_set',
'app_id':'kHG1csvg',
'assertion_id':'EF:quUAdVKp:QVPBRLPJZZ:1',
'assertion_prefix':'EF:quUAdVKp:QVPBRLPJZZ',
'media_md5':'c02525004c40575ff4131131ad44a072',
'model_id':'donor_IVAC_Hpo-d-8e49-DmDT9hhuJLSiFuWOge-YN-OW_mtsv1_INT_10000.tgz',
'probability': 0.91259765625,
'subject_uid':'vehicles_carbox_3gu'}]}
Example decoding media
Note that a 200
code is required to be sent to the EdgeFlow by the receiver of the POST URL.
import traceback
import base64
import json
from flask_restful import reqparse
from flask import Flask
from flask import request
from werkzeug.serving import WSGIRequestHandler
from pprint import pprint
WSGIRequestHandler.protocol_version = "HTTP/1.1"
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def rec_lc():
if request.method == 'POST':
request_data = request.data
try:
msg = json.loads(request_data)
if 'media' in msg and 'media_bytes' in msg['media']:
img_str = base64.b64decode(msg['media']['media_bytes'])
print("size of image=%d" %(len(img_str)))
with open('/tmp/image_test.jpg', 'wb') as fh:
fh.write(img_str)
return '200'
except Exception as ex:
print(traceback.format_exc())
return '404'
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5002)
Response to POST URL
The Edgeflow expects a '200' status response to each post URL. The Edgeflow will make multiple attempts to send the assertion to the post URL.
If '200' is not sent, the destination URL is placed in a deny list for 90seconds and no further assertions will be sent to the URL.