Calculate the area of โ€‹โ€‹the trapezoid from the picture when adjusting the angle

Here is a general mathematical problem that I was hoping that someone could help me. In my application, the user takes a picture of the roof and then marks the perimeter of the roof. I would like to calculate the area of โ€‹โ€‹the trapezoid drawn by the user. However, since the roofs are at an angle, I need to adjust this fact.

Can someone point me in the right direction? My math skills are pretty rusty (and have never been particularly strong).

- The image may help. The user can outline the roof as shown below with a red line. But if the roof could be magically rotated to be perpendicular to the ground, it would look like a likely filling of space closer to the blue line. So, what interests me, is there any kind of math I can do that can do this? (I understand that there are other options, such as calculating the length of two sides using separate images and multiplying them.)

An example of the type of picture I need to use to calculate area

+4
source share
2 answers

This is possible, but only if you can add many restrictions to the situation in which the image is executed:

  • If you know the opening angle of the lens used for shooting, and you know the exact distance to the roof at the time of shooting (the distance between the camera and the gutter), and the image was taken exactly as in your sample with a roof perpendicular to the axis of the camera, and the camera pointed directly to the horizontal center of the gutter, and you know for sure that the roof is rectangular, it is surprisingly simple. If you do not mind being from 10 to 25%. (depending on the accuracy of various measurements).
  • If you cannot know the opening angle of the lens (because the image is not taken from the camera you are controlling, or because the image is taken with the camera with a zoom lens), but there is an object of a known size, the known distance from the camera in the image , then it is still surprisingly simple, because you can determine the opening angle from a known object. The subject should be significantly larger in the image (50% of the horizontal width in the image or so), but it may be closer to the photographer, so it should not be as large as the roof.
  • If you cannot control the exact position from which the picture was taken (i.e. it will not go directly opposite the center of the gutter), your accuracy will be deleted.

If you know the horizontal opening angle of the alpha camera, the distance Dgut between the camera and the drain, the width of the gutter in pixels Wgut and the width of the image in pixels Wim , then you can determine the approximate length of the gutter Lgut :

 Dpixgut= Wim/(tan(alpha/2)) # distance to the gutter in pixel space tan(anggut) = Wgut/Dpixgut # tan of half "opening angle" of the gutter Lgut= 2*tan(anggut)*Dgut 

Since you know Ltop (the length of the top of the roof) is Lgut (this is one of the limitations), you can use the width of the top in pixels of Wtop to calculate the distance to the top of the roof Dtop :

 Dpixtop=Wim/(tan(alpha/2)) #dist to top in pixel space tan(angtop)=Wtop/Dpixtop Dtop=Ltop/(2*tan(angtop)) #dist to roof in real space (note that Ltop=Lgut) 

Dtop-Dgut gives an approximate estimate of the length of the roof Lroof , so Dgut*Lroof is a rough approximation to the area. To be more precise, you must include some calculations similar to the ones above to determine the height of the gutter and the top of the roof above the axis of the chamber, and then adjust the Lroof for this.

Note that this approximation is exactly so. Approximation. Try a few examples from roofs for which you know the area to feel the accuracy (which can be surprisingly bad, I'm afraid).

+2
source

Obtaining a real roof area from a simple picture is not possible. You could not know if the photograph was taken at five or fifty meters, so the roof, which looks tiny in the picture, can be huge. You will need a depth map to get the actual size of the roof, and even that would be difficult.

+3
source

All Articles