Counting Mongolian traditional home-Ger from Google Map using Python

 Purpose of this project.

To keep home warm during winter in Mongolia, every household burn coal, which leads to extreme air pollution. Specially Mongolian traditional home-Ger has poor thermal insulation, where it loses it's heat by radiation and heat convection. 

 

So many gers are prone to lose heat just by air flow, because they use wool as an insulation. As a result, every ger needs to burn more and more coal.

Specially, early morning aroung 4 AM people tend to fill coal on ending fire, to keep burn coal slowly, so that they can sleep 4-5 hours more without refiling coal. It is actually not burning, but more likely smoking the incense. Main reason is, just to keep "burn/smoking" SLOWLY. Automation is needed.

 =
In capital city of Ulaanbaatar, there are significant number ger still exists, reaching around 200000 units. But real number of those gers are unknown precisely.

The goal of this project is to estimate number of gers and assess contirbution to air pollution of them. Also, having reasonable number of gers, to make estimated calculation of electric energy requirement.

In overall, the following answers can be obtained using the reasonable estimation of gers:

1. The amount of contribution to Air Pollution.

2. Total heat energy required to keep ger warm at 25 degree Celsius(Using average ger thermo-insulation data)

3. Total electric energy required to keep ger warm at 25 degree Celsius.

4. What if analysis: Changing insulation of ger.

5. Possible electricity load on main grid, if every household installs Solar Panel.

6. What if analysis: Grid endurance under electricity load caused by gers, variables are power_line_thicknes, number of gers using electric heater 

Coding.

Here, used Python as main programming. For image recognition, used Yolo library.

import cv2
from ultralytics import YOLO
import cvzone
import numpy as np
import pandas as pd
from collections import Counter
import glob

model = YOLO("ger.pt")

my_file = open("germodel.txt", "r")
data = my_file.read()
class_list = data.split("\n")


def object(img):
    results = model.predict(img, conf=0.35)
    a = results[0].boxes.data
    px = pd.DataFrame(a).astype("float")
    object_classes = []

    for index, row in px.iterrows():
        x1=int(row[0])
        y1=int(row[1])
        x2=int(row[2])
        y2=int(row[3])
        d=int(row[5])
        c=class_list[d]
        obj_class = class_list[d]
        object_classes.append(obj_class)
        cv2.rectangle(img, (x1, y1), (x2, y2), (255, 0, 255), 2)
        cvzone.putTextRect(img, f'{obj_class}', (x2, y2), 1, 1)

    return object_classes

def count_objects_in_image(object_classes):
    counter = Counter(object_classes)
    print("Object Count in Image:")
    for obj, count in counter.items():
        print(f"{obj}: {count}")

# path = r'gers\*.*'
path = r'gers\test\*.*'
# path = r'C:\Users\freed\Downloads\yolov8img\images\*.*'
# path = '/images/images/*.*'
for file in glob.glob(path):
    img = cv2.imread(file)
    img = cv2.resize(img, (640, 640))
    object_classes = object(img)
    count_objects_in_image(object_classes)
    cv2.imshow("img", img)
    cv2.waitKey(0)
    cv2.destroyAllWindows()

Comments