Solar Panel Installations in India using Satellite Imagery
This project was a part of my internship where I applied Computer Vision at its core for the very first time. I got to know how important features are and how difficult is it to obtain those features. We created our own dataset of over 7000 images using only Google Maps. So, let’s start off!!! Today, everyone is talking about Deep Learning all the time and I really think Computer Vision at its core has lost its way. I hope this post will bring back the Vision inside you and inspire you to start off with Computer Vision. This post will be long… So, please bear with me. 🙂🙂🙂
Firstly, why talk about solar panels now? The Indian government has regulated laws recently that could help people to store solar panels at their houses. But, nobody does so. Why???🤔🤔
They think it’s too costly. Well, if you look to gain profit in 2–3 months it’s definitely not gonna happen. There are other reasons too such as:
- Company officials who install solar panels they disturb customers regularly for measurement of rooftops.
- They also ask for large sums just for analysis of the rooftops.
Therefore, we developed a solution in which input capital is almost zero and output report is that much low that it costs you less than 3 meals you took in a day. Surprised to see!!!
Starting off at the internship was basically reading papers and getting ideas about scene reconstruction, segmentation, feature extraction methods, and different map service providers. So, my task was to place Solar panels on each and every rooftop of the house just by using latitude and longitude. You really are thinking what’s so difficult in this. Project Sunroof is also the same. Here’s the catch. India doesn’t have 3D maps like foreign countries do. 😐 We looked into different Indian service map providers such as MapMyIndia, Mapillary, Open Street Maps, Bing Maps, etc. Guess what, when you look at the satellite maps of these maps providers, they are better than Google. Stunned !!!😱😱😱
We started off with MapMyIndia but when we compared to satellite and hybrid map of MapMyIndia the localization was poor and it’s very important if you just have the geolocation of that point. Then, we had to move on to Google. Now, take a pause and go have a look at Google Maps and see India’s map. Even the 2D map is not stitched properly. (You can see that some parts are darker and some are lighter at zoom level 15) After facing too many struggles, just for obtaining images we stick to cities which are planned in a better way and started off with Delhi and Chandigarh at first.
The image dataset on which I have to work looked like this:
I suppose now even you can’t even mark out the edges properly. Maybe one or two, but if I give you thousands of those???😰😰😰 OK, so beginning we got off with first and foremost important thing, how to detect rooftops???
Aerial Rooftop Detection Methods
Hough Transform
It is used to localize shapes of different types of rooftops. When applied to the image, it gives very less true positives. The main problem was to set the threshold parameter of the Hough Transform. Windowed Hough Transform: Used to detect exact shapes like squares and rectangles. The main limitation of this method was that it won’t work for other structures if not perfectly square or a rectangle present in the image.
Adaptive Canny Edges
Applying auto canny on the low-quality image of rooftop results in exact edge detection of rooftops. Contour Area localization and then applied the threshold to detect rooftop. It was also a failure.
Watershed Segmentation
Segmentation on the images from maps to count the number of buildings and to plot the rooftop area of each building present in the image. It failed in the case of the densely populated area.
After applying those processes, we tried to separate foreground and background from the images i.e. area within the rooftop and area outside it. We applied the Gabor filter for that. Here’s a brief on Gabor Filters:
Gabor Filters
- Gabor Filter analyses whether there is any specific frequency content in the image in specific directions in a localized region around the point or region of analysis.
- Gaussian Mixture Model is a probabilistic model that assumes all the data points are generated from a mixture of a finite number of the Gaussian distribution.
- Gabor filter enhances one region relative to other depending on the frequency and theta values. After applying the Gabor filter, two Gaussian Mixture models were fit in the histogram of the grayscale image. Two Gaussian Mixture Models separate the image into the foreground that is rooftops and background. After the failure in this too, we moved on to Building extraction methods.
Building Extraction Methods
Edge Sharpening
Due to the poor quality of the image, to mark the rooftop area edge sharpening of the image is to be done. After that skimage morphological opening is done to fill the gaps in between edges.
Active Contours
Active Contours is divided into two, with edges and without edges. Without edges can’t be used in our case as it works on the region segmentation and due to the poor quality of image region, wise segmentation was not possible.
After getting some shape, we gained some confidence and moved on too polygon approximation.
Polygon Approximation
Pixel-wise Polygon Filling
Applying Contour on the rooftop and moving around the contour in a clockwise direction each pixel and its surroundings was marked as a rooftop area.
Region-based Polygon Filling
After applying the Hough Transform in combination with K-Means clustering, the rooftop area was divided into different regions. Checking the intensity of different patches, the area was marked as a rooftop area or not.
Well, it looks good but this also failed in complex cases. You will see complex cases at the end of the post. Now, we moved on to how to find the area of the house just by Google Maps. It’s a serious problem. We are not going to customers home and doing measurements. Input capital is the main criteria. Here also Google comes to your help. The whole world map is divided at each zoom level by Google into tiles of different areas and there’s a simple math function and python API provided by Google. Let’s discuss that:
Google Maps to Image Pixels
- The whole region is on top of the pyramid (zoom=0) covered by 256x256 pixels tile, every lower zoom level resolution is always divided by two.
- At every zoom level, there is Meter per pixel value which gives distance in meters according to the difference in pixel values.
Now, at last finally, we detected the rooftops and placed solar panels on Optimal rooftop area. The final topic:
Optimal Rooftop Area for Solar Panels
- Corners and Canny: Where corners and Canny results were overlapping those corners were selected. The problems with corners that they can’t be accessed in a localized manner. To draw a polygon out of that was impossible.
- Canny and Contours: Contours can be accessed in a clockwise manner. On two images, Canny was applied. One is edge sharpened image and the other is canny edge map image. Contours in Edge sharpened the image using threshold gives rooftop boundaries. Contours on the canny edge map using threshold gives obstacle boundaries on the rooftop. Combining both the results and plotting it on a white patch gives the exact rooftop optimal area for solar panel placement.
- Solar Panel Placement: Rotation of solar panel patches is done by taking the white area inside the rooftop and checking it means intensity. If the mean intensity is 255, it means that’s available for solar panels. Divide the patches into 5x1, 4x1 and 3x1 so that the maximum area of the rooftop is covered with solar panels. Avoid placing a single or two solar panels. Now, the main problem is a rotation of patches and marking solar panels inside that. For rotation of patches, I took a region of interest then rotated it by the angle desired (South facing) and iterated region of interest by the length and breadth of solar panels. For checking the intensity of points inside the patch, region of interest can’t be used as it takes a number of rows and columns into account. So, then I moved to Point Polygon test for each patch to calculate the mean intensity of that patch. If the mean intensity is 255, then the area is available for solar panels.
Finally, this post comes to an end and here’s what I promised before. The final outputs and complex cases of buildings:
Just remember what innovation I have built the input capital was almost NIL. The output analysis was provided to households and companies at a very minimal cost. No disturbance from solar companies at all. It will also enlighten the population about the Solar potential of their rooftop. If you want to have a look at the code, please find it at my Github link as follows:
If this post helps inspire the Vision inside you or if you find it useful, please appreciate by giving a clap. 👏 👏 👏