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).
source share