📜 ⬆️ ⬇️

How I measured FOV without compass and ruler

image
In the yard we played war games. Weak and fat were fascists, the rest won. The yard and childhood disappeared, but I want to fight.

I turned my iPhone into an automaton, and drew the fascists in augmented reality.
Video capture draws the world around my work chair, the fascists climb out of all the cracks, I keep all-round defense.

Stop! And how to tie the enemies to the surrounding reality?
')
I made it very simple.


Image processing


Look at the first video capture picture.



I run across the entire width (480 pixels) of the image and summarize the RGB components of the points that lie with the current point on the same vertical line. We receive an array from 480 elements.
The upper part of the figure shows a red-white (ole!) Histogram of the function found.

Do the same with the next frame from the video stream. See Figure 2.



My task is to combine the red and white histograms of the first and second frames. Shifting the graphics relative to each other, I very quickly find the optimal match. The difference in shift is the desired displacement of reality in my iPhone in the horizontal direction.

In this way, the virtual object is permanently attached to the real location. At each moment of time, we know how much pixels to move it in the horizontal plane.
Does the algorithm work well? Not bad. The main thing is not to pull the phone during the game - this approach does not like the offset of more than 40 pixels per clock. And the tact of the camera is 20 frames per second.
With sharp movements, it is necessary, apparently, to use already heavy artillery - a gyroscope and an accelerometer.

What is FOV


Each optical device has an FOV (field of view). Be it a human eye or a soap dish.
image
What gets into the FOV - the device sees. Other - no, even kill. In the picture, a person sees a tree, but does not see the car. It may be dangerous.
FOV is measured in degrees. A person has an FOV of about 120 degrees for each eye. In a hare, for example, 150. That is, with two eyes a hare covers almost the entire scope of visibility. The hare does not see only exactly 10 degrees ahead and exactly 10 degrees backwards. Oblique ...
Okay, what's the fov of my iPhone?
Looked, of course, on the Internet . My God, in order to calculate the FOV of an iOS device, a special laboratory with laser meters is needed.

I do not have such a laboratory. What for? I just launched the above program. He sat down on his favorite swivel chair. And turned 360 degrees. The program showed the size of the sphere around me.
image
The program showed the size of the sphere around me.
In pixels - stable for the latest generation of iPod 3050-3060 pixels.

Thus, the FOV of my iPod is 480 * 360/3060 = 56-57 degrees.

And the laser intended 55.7.

I got a good accuracy, agree.

Hidden advertising of my application using the above algorithm is placed in tags. Only it between us, ok?

Source: https://habr.com/ru/post/213019/


All Articles