Color Detection of the Bob using Cosine Similarity
The pendulum bob is detected using cosine similarity in RGB space. Instead of thresholding in HSV, we compare each pixel color to a reference bob color $$C_r = (R_r, G_r, B_r)$$ using the cosine similarity formula:
where $$ C_p = (R_p, G_p, B_p) $$ is the color of a pixel. Pixels with similarity above a threshold $$ S_{\text{min}} $$ are considered part of the bob. The centroid $$ (x_c, y_c) $$ is then calculated as:
Finding the Pivot Using Least Squares Circle Fitting
The pendulum moves along a circular arc, meaning the pivot (origin) $$(x_0, y_0)$$ is the center of a fitted circle. We solve for $$ (x_0, y_0) $$ using the objective function:
where the error $$E^*$$ is minimized using non-linear least squares optimization. The detected pivot is validated by ensuring radius consistency across frames:
Demonstration
Demonstration of the pendulum tracking algorithm.
Data Processing & Mathematical Fitting
The CSV data is processed to compute period times and track the pendulum's oscillation. The analysis scripts also fit exponential functions to describe damping effects.
A quadratic function is used to fit the period data, confirming theoretical predictions.
Detailed analysis scripts such as dataAnalysis.py, expoFit.py, and periodTime.py are available in the GitHub repository.
Selected Graphs
Below are some of the graphs generated from the data analysis:
Exponential fitting of the pendulum's decay with quartic period fitting.
Period time analysis of the pendulum at different angles.
Peak detection of the pendulum's motion.