If you're involved in interior design, construction, or renovation, one of the essential tasks is to calculate the surface area of the interior space, particularly the walls, floor, and ceiling.
But measuring the surface area of a room can be challenging, especially when you have to deal with complicated shapes and multiple surfaces. Fortunately, modern computer vision technology like Vision API can help you deal with it.
In this article, we'll explore how to use Vision API to calculate the visible surface area of interior spaces step-by-step. We'll be using Segmentation, Detection, and Reconstruction APIs to calculate the wall area as an example.
The first step is to use Segmentation API to identify and segment the target surfaces in the interior photo. The computer vision algorithms can recognize surfaces like walls, floors, and ceilings in the images and create a segmentation mask for each. You can then use these masks to calculate the visible area of the surface.
Let’s try to get the wall mask only, but first, we need to import packages and define the API Key:
Here is the interior we will use as an example:
Now, we need to make a call to our API to get a segmentation mask:
And here is the result:
Once you have the segmentation masks, you need to get the 2D surface points and surface area from the photo. Computer vision algorithms can help you identify the corners and edges of the surfaces and obtain their dimensions. For this, you need to use Detection and Reconstruction APIs:
On the other hand, the response from Reconstruction API contains an area value for each wall, so we don't need to make any additional calculations. We can simply extract the area from the response:
In this step, we need to calculate the area for a particular wall, so we’ll reuse the list of points from the previous step:
Here, the mask is the binary mask array that contains non-zeros inside the polygon and zeros outside the polygon. The np.count_nonzero function counts the number of non-zero pixels in the array, which gives us the area of the polygon in pixels.
Finally, using the segmentation masks, 2D surface points, and surface area, you can calculate the visible surface area, which should be covered with finishing materials in the interior space. You can do this using the following formula:
Visible Area (meters) = Surface Area (meters) * Mask Area (px) / Surface Area (px)
Here it’s the implementation in Python:
So now we’ve got a visible wall area in meters, i.e. an area of surface, which is not covered with any furniture, room structuring elements, and so on.
In conclusion, we want to highlight that it is essential to calculate the right amount of materials during construction and renovation to ensure a smooth and efficient process. And the technologies like Vision API can help you get the accurate dimensions and area of room surfaces. Quick and accurate calculations are necessary to prevent delays and additional costs.
Vision API allows you to do the quick and semi-automated calculation of surface areas. This technology has the advantage of being able to process large amounts of interior photos quickly and accurately, which can be particularly beneficial for larger construction projects.
While our testing demonstrated that Vision APIs determine dimensions with a high degree of accuracy, it is important to acknowledge that there is still potential for error. Therefore, if this technology is used in real architectural and design projects, it should be used as a tool in conjunction with human expertise to ensure the most precise calculations and materials estimates.
Ready to get started and test Vision API? Sign up for a free trial.