HTTPS Request to Python Flask
AnsweredHello,
I’d like to know how to use the camera rules action, specifically the "Do HTTPS Request" feature. I want to get data from "Line Crossing Detected" for vehicle objects like cars and motorcycles. I’ve tried creating a simple Python code using Flask as a local server, as shown in the picture. However, when I run the program, I get a 400 error code. I’m not sure what to put in the "HTTPS Content" field. Could you help me with this? I'm using Nx Meta
-
Hi Fandra Andito,
Thank you for your question.
The HTTP 400 error is likely due to an issue in your Python script can't deal with requests, most likely, the request is missing a POST body. Since we don't know the specifics of your script, I recommend you can review your code to ensure it’s handling the request correctly.
Regarding placeholders for Generic Events or Analytics Events, these have been supported since Nx Witness v4.1. For more details, please refer to the release notes: Nx Witness Release Notes.
For metadata, such as obtaining object types like car or motorcycle, this may not be accessible via your current approach, as metadata is transmitted via RTSP instead of event notifications from the camera. You might need to use the metaSDK, or you can wait for our metadata API, expected around Q1/2025, which will allow you to integrate notifications and metadata directly with your Python code.
Thanks.
-
Hello Ichiro,
Thank you for your response.
Actually, I’m also not sure what exactly to write in the Python code, as I don’t know which parameters I need to retrieve. I appreciate your explanation as well. Based on what you’ve said, would it be better for me to use a Python post-processor to send the data? If so, how should I split the logic between post-processor.py and api.py (as an example)?
Looking forward to your answer.
-
Hi
You may refer to the sample here on Nx Open github.
If so, how should I split the logic between post-processor.py and api.py (as an example)?
To be honest, this question might be best answered by your mentor/engineering lead or a senior staff member within your company. Implementation approaches can vary across companies based on internal logic and preferences.
In general, api.py can be treated as a simple library that contains commonly used functions, similar to how you would import modules like json or requests.
Please sign in to leave a comment.
Comments
3 comments