Skip to content

The Dream Catcher project utilizes computer vision tools like OpenCV and MediaPipe to track head movements during sleep. It employs NumPy for data manipulation and Pandas for organizing data into tables. Matplotlib is then used to visualize the analyzed results.

License

Notifications You must be signed in to change notification settings

mkuangdotcom/Dream_Catcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DREAM CATCHER 🛏️

The Dream Catcher project analyzes head movements during sleep using a combination of computer vision and data analysis tools. It leverages OpenCV for image and video processing, MediaPipe for face mesh detection, and NumPy for numerical data manipulation. The head movements are tracked and analyzed, and the data is organized into tables using Pandas. Finally, the results are visualized using Matplotlib.

Installation

To get started, you need to install the required packages. You can do this using pip:

pip install opencv-python
pip install numpy
pip install mediapipe
pip install pandas
pip install matplotlib

How It Works?

  • Video Input: The system takes a video of a person sleeping as input.
  • Head Detection: Using OpenCV and MediaPipe, the program detects the head and tracks its movement.
  • Data Collection: The head movement data is collected and organized into a table using Pandas.
  • Visualization: The collected data is then visualized using Matplotlib to show the patterns and extent of head movements during sleep.

Key Points in the Code

Import Libraries: Essential libraries for computer vision, numerical computations, data manipulation, and visualization are imported.

import cv2
import numpy as np
import mediapipe as mp
import pandas as pd
import matplotlib.pyplot as plt
from head_detection import detect_head

Head Detection: The detect_head function from head_detection.py is used to detect the head in each frame of the video.

def detect_head(frame):
    # Code for head detection using MediaPipe
    ...

Looking Forward

Looking Left


Data Processing: The detected head positions are stored in a Pandas DataFrame for further analysis.

data = pd.DataFrame(columns=['timestamp', 'head_position'])
# Code to populate the DataFrame
...

Visualization: Matplotlib is used to plot the head movements over time.

plt.plot(data['timestamp'], data['head_position'])
plt.xlabel('Time')
plt.ylabel('Head Position')
plt.title('Head Movements During Sleep')
plt.show()

Example Output

Credits

This project was inspired by the work of Irfan Alghani Khalid on head pose estimation. You can read more about it on Towards Data Science.

This project was also inspired by the work of Sergio Canu, the founder of Pysource. You can read more about it on Pysource.

About

The Dream Catcher project utilizes computer vision tools like OpenCV and MediaPipe to track head movements during sleep. It employs NumPy for data manipulation and Pandas for organizing data into tables. Matplotlib is then used to visualize the analyzed results.

Topics

Resources

License

Stars

Watchers

Forks

Languages