lydiazyang commited on
Commit
7ef774f
·
1 Parent(s): 2502ffe

Create frontend skeleton

Browse files
Files changed (1) hide show
  1. index.py +76 -0
index.py ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import cv2
3
+ # import pandas as pd
4
+ # import numpy as np
5
+ def main():
6
+ st.title('NouriScan')
7
+
8
+ st.sidebar.header('Ingredients & Nutrition')
9
+
10
+
11
+ option1 = st.sidebar.checkbox('Banana')
12
+ option2 = st.sidebar.checkbox('Strawberry')
13
+ option3 = st.sidebar.checkbox('Kale')
14
+ option4 = st.sidebar.checkbox('Orange Juice')
15
+ option5 = st.sidebar.checkbox('Almond Milk')
16
+ button_clicked = st.sidebar.button('Done')
17
+ if not button_clicked:
18
+ videoCapture()
19
+ if button_clicked:
20
+ displayRecipes()
21
+
22
+ def displayRecipes():
23
+ items = [
24
+ {"title": "Item 1", "content": "Content for Item 1."},
25
+ {"title": "Item 2", "content": "Content for Item 2."},
26
+ {"title": "Item 3", "content": "Content for Item 3."}
27
+ ]
28
+
29
+ # Display the items with expanding boxes
30
+ for item in items:
31
+ with st.expander(item["title"]):
32
+ st.write(item["content"])
33
+
34
+
35
+
36
+ def videoCapture():
37
+
38
+ # Create a VideoCapture object to access the webcam
39
+ cap = cv2.VideoCapture(0)
40
+
41
+ # Set the video frame width and height (optional)
42
+ cap.set(cv2.CAP_PROP_FRAME_WIDTH, 640)
43
+ cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)
44
+
45
+ # Check if the webcam is opened correctly
46
+ if not cap.isOpened():
47
+ st.error("Error: Unable to access the webcam.")
48
+ return
49
+
50
+ # Display a placeholder for the video stream
51
+ video_placeholder = st.empty()
52
+
53
+ while True:
54
+ # Read a frame from the webcam
55
+ ret, frame = cap.read()
56
+
57
+ if not ret:
58
+ st.error("Error: Unable to read frame from the webcam.")
59
+ break
60
+
61
+ # Display the frame in the Streamlit app
62
+ video_placeholder.image(frame, channels="BGR", use_column_width=True)
63
+
64
+ # Check if the user pressed the 'q' key to quit
65
+ if cv2.waitKey(1) & 0xFF == ord('q'):
66
+ break
67
+
68
+ # Release the VideoCapture and close the OpenCV window
69
+ cap.release()
70
+ cv2.destroyAllWindows()
71
+
72
+
73
+
74
+
75
+ if __name__ == '__main__':
76
+ main()