Skip to content

Commit 7f0b442

Browse files
committed
add camera datasource
1 parent 048e015 commit 7f0b442

File tree

2 files changed

+50
-25
lines changed

2 files changed

+50
-25
lines changed

apps/99_streamlit_examples/pages/10_Object_detection.py

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,35 @@
1818
key="model_name",
1919
index=0,
2020
)
21+
data_source = st.selectbox(
22+
label="Select a data source",
23+
options=[
24+
"file",
25+
"camera",
26+
],
27+
key="data_source",
28+
index=0,
29+
)
2130

2231

2332
st.title("Object detection")
2433

25-
st.info("Upload an image and AI will detect objects in the image.")
26-
27-
uploaded_file = st.file_uploader(
28-
"Upload an image",
29-
type=(
30-
"jpg",
31-
"jpeg",
32-
"png",
33-
"gif",
34-
"bmp",
35-
"tiff",
36-
),
37-
)
34+
if data_source == "camera":
35+
st.info("AI will detect objects in the camera image.")
36+
uploaded_file = st.camera_input("Take a picture")
37+
if data_source == "file":
38+
st.info("Upload an image and AI will detect objects in the image.")
39+
uploaded_file = st.file_uploader(
40+
"Upload an image",
41+
type=(
42+
"jpg",
43+
"jpeg",
44+
"png",
45+
"gif",
46+
"bmp",
47+
"tiff",
48+
),
49+
)
3850
if uploaded_file is not None:
3951
button = st.button("Detect objects")
4052

apps/99_streamlit_examples/pages/11_Pose_estimation.py

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,36 @@
2828
index=1,
2929
key="model_complexity",
3030
)
31+
data_source = st.selectbox(
32+
label="Select a data source",
33+
options=[
34+
"file",
35+
"camera",
36+
],
37+
key="data_source",
38+
index=0,
39+
)
3140

3241

3342
st.title("Pose estimation")
3443

35-
st.info("Upload an image and AI will estimate the pose.")
44+
if data_source == "camera":
45+
st.info("AI will detect objects in the camera image.")
46+
uploaded_file = st.camera_input("Take a picture")
47+
if data_source == "file":
48+
st.info("Upload an image and AI will estimate the pose.")
49+
uploaded_file = st.file_uploader(
50+
"Upload an image",
51+
type=(
52+
"jpg",
53+
"jpeg",
54+
"png",
55+
"gif",
56+
"bmp",
57+
"tiff",
58+
),
59+
)
3660

37-
uploaded_file = st.file_uploader(
38-
"Upload an image",
39-
type=(
40-
"jpg",
41-
"jpeg",
42-
"png",
43-
"gif",
44-
"bmp",
45-
"tiff",
46-
),
47-
)
4861
if uploaded_file is not None:
4962
button = st.button("Estimate pose")
5063

0 commit comments

Comments
 (0)