Spaces:
Runtime error
Runtime error
File size: 899 Bytes
f66b5f5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
import cv2
import csv
import json
from deta import Deta
import os
def preprocess_img(inp_image):
gray = cv2.cvtColor(inp_image, cv2.COLOR_BGR2GRAY)
gray_img = cv2.bitwise_not(gray)
return gray_img
def save_csv(mahalle, il, sokak, apartman):
adres_full = [mahalle, il, sokak, apartman]
with open("adress_book.csv", "a", encoding="utf-8") as f:
write = csv.writer(f)
write.writerow(adres_full)
return adres_full
def get_json(mahalle, il, sokak, apartman):
adres = {"mahalle": mahalle, "il": il, "sokak": sokak, "apartman": apartman}
dump = json.dumps(adres, indent=4, ensure_ascii=False)
return dump
def write_db(data_dict):
# 2) initialize with a project key
deta_key = os.getenv('DETA_KEY')
deta = Deta(deta_key)
# 3) create and use as many DBs as you want!
users = deta.Base("deprem-ocr")
users.insert(data_dict)
|