Welcome to our Emotion Detection and Music Player application! 🎵 This application leverages computer vision and deep learning to detect emotions and play corresponding music.
- Python 3.x installed on your system.
- tkinter: For GUI development.
- opencv-python: For computer vision tasks.
- numpy: For numerical computations.
- pygame: For playing music.
- keras: For loading a pre-trained emotion recognition model.
- PIL: Python Imaging Library for image processing.
- os: For file system operations such as copying and deleting music files.
- threading: For handling concurrent execution.
-
Run the Application:
- Open a terminal or command prompt.
- Navigate to the directory where the Python script is saved.
- Run the script using the command:
python <main>.py
-
Load Camera:
- Click on the
Load Camerabutton to initialize the webcam. - If multiple cameras are available, select the desired one from the drop-down menu.
- Click on the
-
Detect Emotion:
- After loading the camera, click on the
Detect Emotionbutton to start the emotion detection process. - The application will continuously analyze the webcam feed to detect faces and emotions.
- After loading the camera, click on the
-
Enjoy Music:
- Based on the detected emotion, the application will play corresponding music.
- Each emotion has its predefined music file stored in the
Musicfolder.
-
Load Music:
- Click on the
Load Musicbutton to load music files corresponding to different emotions. - Ensure that the music files are correctly labeled and stored in the
Musicfolder.
- Click on the
-
Upload Music:
- Click on the
Upload Musicbutton to add new music files to theMusicfolder. - Select the music files from your system's file browser and click
Opento upload them.
- Click on the
-
Delete Music:
- Select the music file you want to delete from the list of loaded music files.
- Click on the
Delete Musicbutton to remove the selected music file from theMusicfolder.
-
Stop Detection:
- Click on the
Stopbutton to pause the emotion detection process.
- Click on the
-
Toggle Full Screen:
- Click on the
Full Screenbutton to switch between full-screen and windowed mode.
- Click on the
-
Exit Application:
- Click on the
Exitbutton to close the application. - Ensure to stop emotion detection before exiting to release the camera resources.
- Click on the
- Ensure that the required emotion detection model (
modelv1.h5) is present in the specified location. - Music files corresponding to different emotions should be stored in the
Musicfolder. - The application uses pre-trained Haar cascade for face detection and a CNN model for emotion recognition.
- Adjust the aspect ratio and size thresholds in the
detect_emotionfunction based on your requirements. - You can customize the music files and their associations with different emotions in the
play_musicfunction.
- tkinter: For GUI development.
- cv2: OpenCV library for computer vision tasks.
- numpy: For numerical computations.
- pygame: For playing music.
- keras.models: For loading a pre-trained emotion recognition model.
- os: For operating system operations.
- threading: For handling concurrent execution.
- PIL: Python Imaging Library for image processing.
-
load_music():- Function to load music files corresponding to different emotions from the
Musicfolder. - This function can be called when the application starts or when the
Load Musicbutton is clicked.
- Function to load music files corresponding to different emotions from the
-
upload_music():- Function to upload new music files to the
Musicfolder. - This function can be triggered when the
Upload Musicbutton is clicked. - It should open a file dialog to allow the user to select one or more music files from their system.
- Once selected, the function should copy the chosen music files to the
Musicfolder.
- Function to upload new music files to the
-
delete_music(file_name):- Function to delete a specific music file from the
Musicfolder. - This function can be called when the
Delete Musicbutton is clicked and a music file is selected from the list. - It should remove the selected music file from the
Musicfolder.
- Function to delete a specific music file from the
-
MusicController:- Class to handle music-related operations such as loading, uploading, and deleting music files.
- It can have methods like
load_music,upload_music, anddelete_music.
-
GUI(or any main application class):- Modify the existing GUI class or create a new one to include buttons for loading, uploading, and deleting music files.
- Bind these buttons to the corresponding functions in the
MusicController.
Thank you for trying our application! Your feedback is valuable to us. 🧡