Python Code Sample

Example 1

Prototype:

def SendDataWithUniqueId(streamName: bytes, inPluginId: int, dataInput: MxDataInput) -> int:

For details about the sample code, see the main.py file in the {sdk_install_path}/samples/mxVision/python directory. For details, see Service Running (Python).

Example 2

Prototype:

def SendDataWithUniqueId(streamName: bytes, elementName: bytes, dataInput: MxDataInput) -> int:
ELEMENT_NAME = b'appsrc0'
unique_id = stream_manager_api.SendDataWithUniqueId(STREAM_NAME, ELEMENT_NAME, data_input)

infer_result_sample = stream_manager_api.GetResultWithUniqueId(STREAM_NAME, unique_id, 3000)
if infer_result_sample.errorCode != 0:
    print("GetResultWithUniqueId error. errorCode=%d, errorMsg=%s" % (
        infer_result_sample.errorCode, infer_result_sample.data.decode()))
    exit()
print("result: {}".format(infer_result_sample.data.decode()))