Logbook noting:
11.24
Distance detection
In order to determine the distance from our camera to a known
object or marker, we are going to utilize triangle
similarity.
The triangle
similarity goes
something like this: Let’s say we have a marker or object with a known width W.
We then place this marker some distance D from
our camera. We take a picture of our object using our camera and then measure
the apparent width
in pixels P. This allows us to derive the
perceived focal length F of
our camera:
F = (P x D) / W
For example, let’s say I place a standard piece of 8.5
x 11in piece
of paper (horizontally; W = 11) D
= 24 inches in front of my camera and take a photo. When I
measure the width of the piece of paper in the image, I notice that the
perceived width of the paper is P = 249 pixels.
My focal length F is
then:
F = (248px x 24in) / 11in = 543.45
As I continue to move my camera both closer and farther away from
the object/marker, I can apply the triangle similarity to determine the
distance of the object to the camera:
D’ = (W x F) / P
Comments:
After
tasting some “sweet candies” of Xcode, I began to really focus on my project.
First of all, I started to think about some relevant tools with the function of
collision warning. I wanted to get some
inspiration from those existing tools. I searched “collision warning system”
and found information about “mobileye”. It was a developed driving assistant
tool with powerful functions. For example, it can detect the front car and get
the distance to it. Also, it can recognize a pedestrian and give alarm if that
people is in dangerous distance. It can even illustrate the white lines on the
road. However, they didn’t provide any information about the theory they
applied. The only thing I can guess is that they applied very powerful image
processing tools like Matlab or so. In my project, however, I would not like to
apply extra calculating tools like Matlab, or using other camera. I would like
to develop an application that one iPhone can handle everything. My project
came into its first bottleneck. At that time, I searched help from my
supervisor.
Dr
Shen is my supervisor, and his interested area is photo electronics. He advised
me to search some background knowledge about Thin Lens Equation. That
was really a breakthrough point.
Thin
Lens Equation is the most important theoretical equation. This formula figures
out the relationship among Object Distance, Image Distance and Focal
length.
Figure 1: Thin Lens Equation
Ref:http://hyperphysics.phy-astr.gsu.edu/hbase/geoopt/lenseq.html
Figure 2: Graphical representation of Thin Lens Equation
Ref:http://hyperphysics.phy-astr.gsu.edu/hbase/geoopt/lenseq.html
Figure 3: Easy way to understand Thin Lens equation
In
this project:
o– real distance between camera
and front car
i– image distance in the camera
f– equivalently 35mm for iPhone 6
If
you have any knowledge about image processing. You may think the normal way to
detect distance should apply angle. In other words, any pixel width in a
picture is matching with a certain number of angle. But in my project, the
angle is too difficult to obtain. Under this situation, I chose the rules of
similar triangle to solve the problem of detecting distance.
Back
to the thin lens equation, as I can check the equivalent focal length of iPhone
6’s rear camera, I can get the relation between real distance and image distance
in a camera. Here comes a new question: how to get the relationship between the
real distance and the image pixel width of a certain item? Because the image
distance is impossible to obtain. To solve this problem, rules of similar
triangles are applied.



No comments:
Post a Comment