MARKING
Marking Scheme:
70%:
Working code up to
y_pos_array
(or equivalent)At least some sparse inline comments 100%:
Final value of
g
(converted from pixel space to SI units)Very well-commented code
Either:
Use of Markdown Cells
Extra task implemented
FINAL GRADE: 100%
General Comments across all groups:
Very high standard across the groups well done guys! This is especially impressive considering many of you have only 1 term of coding experience. Most groups achieved 70% with a few completing the strict criteria for 100% as listed in the marking scheme above. As many groups had similar scripts, I thought it would be useful to give some stylistic recommendations for your future coding notebooks:
Use markdown cells to split up the notebook into more manageable chunks, with headers and lines (as used in this markdown cell I wrote)
Try to put all your import statements in the first cell (numpy, matplotlib etc.)
Ensure all plots have axes labels and titles
Personal group comments:
Nice error analysis at the end but i wouldn't be too harsh, a value of g anywhere near
10ms-2
is really impressive well doneGreat use of markdown cells with informative formatting
Good use of axes labels of plots and nice idea plotting y againts t^2 to make the data linear
Really impressive notebook, great work!
Using Image Processing to Calculate Acceleration Due to Gravity g for a Falling Object
by James Vallejo, Dylan Hung, Arnav Aggarwal, Karina Patel
In this project we calculate a value for the acceleration due to gravity g based on a video of a falling ball. The ball is released from rest and allowed to fall under gravity. We measure how far the ball has fallen in a given timeframe, based on the number of frames elapsed. From here, we then use image processing through python to determine the centre of mass of the ball. This allows us to calculate a value for g by measuring the distance the ball has fallen based on the change in y-position of the centre of mass, and using the previously calculated values.
We start by recording a video of a ball falling from rest. Then we import the video, loading it in as an array. The imported video consists of 50 frames.
Here, we have singled out the frame where the ball is released to look at the starting coordinates of the ball.
Now we crop each frame to ensure we are only analysing the relevant area that the ball falls through, and save this data into an array.
Here, we are thresholding the image. This converts the image into a format that the programme can comprehend. Essentially the dark and light parts of the image are separated based on a desired brightness sensitivity, which will later allow us to determine a centre of mass of the ball.
We then import an image processing package in order to use general image processing and analysis functions.
With scipy.ndimage imported, we can then obtain the x and y coordinates of the largest particle in the image which is the ball. We did not use the first 3 frames of this video as the ball was not in motion. As a result, only the last 9 frames were used in order to calculate a value for g.
Here is a graph of the position of the ball. The values in the graph illustrate the centre point of the ball as it falls. Since gravity will only affect the ball vertically, you can see that all the values have the same x co-ordinates (but different y co-ordinates) and thus forms a vertical line.
In order to calculate a value for g, we will use manually measured values for the distance the ball has fallen in the 9 frames being analysed, according to the centre of mass of the ball. This can be done accurately because a reference measuring tape was placed on the wall behind the ball in the video. The distance fallen by the ball in 9 frames was calculated as 0.494m.
s = 0.494 m
u = 0 ms-1
v = ?
a = g ms-2
t = 9/30 s
s = ut + 0.5at^2
0.494 = (0)(9/30) + (0.5)(g)(9/30)^2
0.494 = 0.045g
g = 494/45
g ≈ 10.98 ms-2
Here is another graph using the results we have obtained from the experiment. Unlike the first graph however, this graph is not vertical -- the slope of this graph will give us the value for g. (In theory, this graph would have a constant gradient). In the comment below we have explained why it is not possible in practice to use this graph to calculate a value of g using this.
A straight line graph indicates that the method is likely correct, as for a constant acceleration we would expect time2 to be proportional to the y-coordinates (i.e. distance). It is worth noting that the graph does not pass through the origin as the starting y-coordinate is not zero, and therefore the y coordinates cannot be treated as the distance travelled by the falling object. Also, this graph cannot be used to calculate "g" as it stands, as the y coordinates are measured in pixels, not meters as would be necessary (SI units) to calculate an accurate value for "g". The main purpose of this graph is to ensure a straight line to identify any outliers in the dataset, or a possible error in the methodology or processing of data causing a curved line to form.
Error Analysis
It is clear that our calculated value (g = 10.98 ms-2) does not agree with the actual experimentally deterimined value of 9.81ms-2. There are several possible reasons why there is a discrepency of 1.17ms-2 between the two values.
The main reason is due to the relatively low number of frames used. The ball is only falling for 9 frames in total. Due to this, there is a high percentage error in the determined time interval that the ball is falling for. For example, if there is an error in this value and the ball was actually falling for 8 frames, this is an 11% difference relative to the actual number of frames. If this value of 8 frames was used in calculations, the value of g would be determined as 13.89ms-2 using the same method as shown above, resulting in a large error of 26.5% relative to our experimentally deterimined value of 10.98ms-2.
Another possible reason for this error could be due to the way the centre of mass of the ball was determined. As is evident in the above images (12 frames of yellow ball on a purple background), the shape of the ball is not perfectly spherical as would be expected. This is due to patches on the dark ball where the bright ambient light was reflected being registered as the background. Therefore the actual centre of mass of the ball will be slightly innacurate, also causing a slight inaccuracy in the distance travelled by the ball in the given timeframe.
This is quite close approximation for the actual value of g considering the small number of frames used, suggesting that the method used to deterimine this value is likely correct.