Closed gruvw closed 1 month ago
I have tested this locally with a simple flask server and was successfully able to go through the full automatic configuration process using the app.
The image is sent through the internet using a POST request to the /analyse
endpoint of the CV server, the image is in the request's body and base64 encoded.
Basic Flask code snippet to get the base64 image:
@app.route("/analyse", methods=["POST"])
def analyse():
print(request.data)
...
One can paste the data to retrieve the actual picture in any common conversion tool (like https://onlinejpgtools.com/convert-base64-to-jpg that I used during my tests).
To retrieve the bytes data of the image, we can simply decode the base64 as follows:
import base64
...
base64.b64decode(request.data)
Also note (for the record) that for the flask response to be accepted by the app, one has to set up the response headers as follows:
response = make_response("PLO,fake:mac:addr") // example response
response.headers.add("Access-Control-Allow-Origin", "*")
response.headers.add("Access-Control-Allow-Credentials", "true")
response.headers.add("Access-Control-Allow-Methods", "GET, POST, OPTIONS")
response.headers.add("Access-Control-Max-Age", "1000")
response.headers.add("Access-Control-Allow-Headers", "Origin,Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token,locale")
return response
As per the description of the two backlinks above, I already implemented this new base64 encoding on the server.
I did a final integration test using the real CVserver from #45 and the new version of the app that uses the server analyse protocol. I found a bug while doing it. Fixed the bug. Now it is working (tested) end-to-end with real app and real server.
Implement the automatic configuration protocol in the Flutter application.
[X] The protocol should take a picture using the webcam module and make a request for the configuration associated with the picture to the CV server.
[X] Then the configuration should be stored & persisted on the mobile app. The app should generate the buttons associated with the automatic configuration to be usable after completing the setup process.
[X] Additionally, implement fake responses to try this feature locally without an actual camera module or configuration CV server connected.