Lunes, Disyembre 11, 2017

Moment Frozen in Time: Basic Video Processing

The last 186 activity for me is the one big aspect of image processing. It comes from the idea that a video is a series of images. Individual image processing of each frame in a video is video processing. In this activity, we were tasked to do a common physics experiment done in video and do the analysis using image processing of the video frames.
For each video, it is vital to know the frame rate of the video, or the number of frames flashed per second, especially when temporal information is needed. The ideal frame rate to prevent lost of information is based on the Nyquist Criterion. 
For this activity, we did a classic physics free fall experiment, which we all know by heart. A video captured a free falling tennis ball for 29.97 frames per second. The frame rate is okay since there is no repetitive motion. 

In the experiment, the acceleration due to gravity can be measured by obtaining the change in speed of the tennis ball over time. To do this, the location at every instant of the tennis ball should be obtained. 

From the video, image segmentation was used to locate the tennis ball using the ROI from the surface of the tennis ball at one frame. Since this is a video, the quality of each frame depends on the frame rate. Most of the frames made the ball look blurry especially towards the end where the speed is increasing. Seen in figure 1, at frame 50, the ball is so blurry and is almost unseen. With this, care should be taken when choosing the ROI. When an ROI is from a frame where the object is not yet moving, the ball gets undetected at a later time since the ball blurs. In my case, the ROI is from frame 47 since the color captures the motion of the ball but is not so blurry that the background would be selected. Further improvement in the tracking is done using morphological operations. Regionprops was used to detect the centroid of the ball, which tells the approximate location at that frame. 

Figure 1. Frames 47 and 50 of one trial of the free fall video. 



The videos below show one of the trials done. The center of the white blobs show the pixel locations of the ball, which was converted to actual coordinates from the pixel length of the protractor which is 12.5cm. The corresponding frame at which the ball was located was also converted to real world time coordinates from the frame rate property of the video. 




The tracked positions of the tennis ball for 4 trials are shown in figure 2. The speed is shown in figure 3. The position was adjusted so that the floor is at 0m. This adjustment is needed since the pixel convention is increasing from top to bottom. From the curve fit of the trajectory, the acceleration due to gravity has the values of -8.37 m/s2, -9.22 m/s2, -10.11 m/s2, and -9.45 m/s2. The obtained values are near the accepted value. Deviations from the measurement could be due to the blurring of the ball while in motion. From the velocity plot however, shown in figure 3, the acceleration values are 9.79m/s2, 9.73 m/s2, 7.18 m/s2, and 7.96 m/s2. For each trial, the obtained value if different for the two plots. The lines in figure 3 however do not fit well as shown by the r2 values from 0.6 to 0.7. For trial 2, shown by the orange plots in figures 2 and 3, the obtained values for the acceleration are close to each other, which is 9.22 m/s2 and 9.73 m/s2. Interestingly, the r2 of the fit in the velocity plot is 0.93, which is close to 1. Interestingly, the obtained values for the acceleration. The disparities of the computed values could be due to the blurred motion of the ball caused by the limitation of the camera and the video's frame rate. 

Figure 2. The position vs time plot of the tennis ball in free fall. Curve fitting gives the value of acceleration of -10.11 m/s2 to -8.37 m/s2

Figure 3. The velocity vs time plot of the tennis ball in free fall. Linear regression obtains the acceleration values in the range of 7.18 m/s2 to 9.79 m/s2.

I really like this activity since in some of our Physics 19x experiment, we were forced to do image processing for the data analysis due to the limited working lab quest available. I had fun in video analysis and object tracking since some of the data, such as the swinging of the pendulum, or the collision of two objects, etc, are hard to see using the naked eye, but is very observable when the videos are sliced into frames. 

For future work, it would have been more fun to do some pendulum experiment such as the energy transfer experiment in 191. This experiment requires focus from the experimenters since the amplitude of the pendulum swing varies and some set-up has very fast energy transfer. It is also hard to use a motion detector for this since there are two pendula and their sync is essential. Also, with pendulum experiments, only the frame rate is important for conversion to real world coordinates. The pixel to real world distance is most of the time not needed. 

For this activity I failed to do an additional exploration part due to the limits of time. However, in my future works, I will still do more object tracking and video analysis. It also took me a little longer than expected to finish this activity since the ruler, seen in figure 1, gets segmented with the tennis ball, and it took me a while to solve the blurring of the ball, which made it undetected. Despite that, I think I perfectly understand the concepts needed for this activity, and the plot and videos are good. I also had a few practice with using videoWriter() function and in obtaining a good frame rate but I turned the video into a gif file since blogger lowers the quality of the video. So I give myself 10/10 for the evaluation. 

I would like to thank Nica and ate Clei for letting me help in the acquisition and sharing with me the experiment video. I also acknowledge all the other people who helped me learn things in this 186 course, which I used in finishing this activity. 

It does not matter how slowly you go as long as you do not stop. -Confucius

Walang komento:

Mag-post ng isang Komento