forked from vedanthv/MusicHealsTheSoul
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
53 lines (43 loc) · 1.33 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import streamlit as st
import cv2
import matplotlib.pyplot as plt
# from deepface import DeepFace
header = st.beta_container()
input = st.beta_container()
pred = st.beta_container()
# Write something in a container
with header:
st.title('Emotion Detection and Song Recommendation')
st.text('Aim : To detect the emotion of the person and predict a song')
with input:
st.title("Taking the face of the user as input")
faceCascade = cv2.CascadeClassifier(cv2.data.haarcascades + "haarcascade_frontalface_default.xml")
# 1.creating a video object
video = cv2.VideoCapture(0)
# 2. Variable
a = 0
# 3. While loop
while True:
a = a + 1
# 4.Create a frame object
check, frame = video.read()
# Converting to grayscale
# gray = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
# 5.show the frame!
cv2.imshow("Capturing",frame)
# 6.for playing
key = cv2.waitKey(1)
if key == ord('q'):
break
# 7. image saving
showPic = cv2.imwrite("photo.jpg",frame)
print(showPic)
# 8. shutdown the camera
video.release()
cv2.destroyAllWindows
# with pred():
# st.title("Prediction")
# img = cv2.imread('photo.jpg')
# plt.imshow(cv2.cvtColor(img,cv2.COLOR_BGR2RGB))
# predictions = DeepFace.analyze(img)
# st.body("Your emotion is",predictions)