Skip to content

Commit

Permalink
ROI table now shows ROI area instead of path
Browse files Browse the repository at this point in the history
  • Loading branch information
niksirbi committed Nov 7, 2023
1 parent 67a1fd2 commit cc00ee3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 9 additions & 2 deletions wazp/pages/02_ROI.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import dash_bootstrap_components as dbc
import plotly.express as px
from dash import dash_table, dcc, html
from dash.dash_table.Format import Format, Scheme
from PIL import Image

###############################
Expand All @@ -23,7 +24,7 @@
init_frame_slider_params: dict = {"max": 1, "step": 1, "value": 0}
init_frame_slider_storage: dict = {v: init_frame_slider_params for v in init_videos}
# Columns for ROI table
init_roi_table_columns = ["name", "on frame", "path"]
init_roi_table_columns = ["name", "on frame", "area (px)"]
# Initialize the ROI storage dictionary
init_roi_storage: dict = {v: {"shapes": []} for v in init_videos}
# Initialize the ROI status alert
Expand Down Expand Up @@ -99,9 +100,15 @@
# Table of ROIs #
###############################

table_columns = [dict(name=c, id=c) for c in init_roi_table_columns]
for i, c in enumerate(table_columns):
if "area" in c["name"]:
table_columns[i]["type"] = "numeric"
table_columns[i]["format"] = Format(precision=0, scheme=Scheme.decimal_integer)

roi_table = dash_table.DataTable(
id="roi-table",
columns=[dict(name=c, id=c) for c in init_roi_table_columns],
columns=table_columns,
data=[],
selected_rows=[],
editable=False,
Expand Down
3 changes: 2 additions & 1 deletion wazp/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,10 +621,11 @@ def stored_shape_to_table_row(shape: dict) -> dict:
- on frame: frame number on which the ROI was last edited
- path: SVG path for the ROI
"""
poly = svg_path_to_polygon(shape["path"])
return {
"name": shape["name"],
"on frame": shape["drawn_on_frame"],
"path": shape["path"],
"area (px)": poly.area,
}


Expand Down

0 comments on commit cc00ee3

Please sign in to comment.