I have a small issue I m trying to draw a polygon and use it as the ROI for detections in a video but I am not sure how exactly can I extract the points from the table as I am getting the following error for this code
st.dataframe(pd.json_normalize(canvas_result.json_data["objects"]))
in drawing a polygonArrowTypeError: ("Expected bytes, got a 'int' object", 'Conversion failed for column path with type object')
I think the explanation is https://discuss.streamlit.io/t/all-in-on-apache-arrow/15342/3:
- we need to change the type of columns to any types in the following table: Pandas Integration — Apache Arrow v14.0.1. So string and float64 whenever asked. Pushing a commit to the demo app.
if canvas_result.json_data is not None:
objects = pd.json_normalize(canvas_result.json_data["objects"])
for col in objects.select_dtypes(include=['object']).columns:
objects[col] = objects[col].astype("str")
st.dataframe(objects)
- or change the serialization from arrow to legacy, by putting in
.streamlit/config.toml
the following:
[global]
dataFrameSerialization = "legacy"
@BeyondMyself the image is stored in image_data.image_data
, the image_data
variable contains 2 properties: image_data
for the image and json_data
for the canvas JSON representation.