reformat most things
This commit is contained in:
parent
bd7c781adb
commit
835494d29f
7 changed files with 85 additions and 50 deletions
|
|
@ -6,7 +6,6 @@ from sqlalchemy.orm import declarative_base
|
|||
engine = create_engine("sqlite:///sqlite.db", echo=True)
|
||||
session = Session(engine)
|
||||
|
||||
|
||||
Base = declarative_base()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -34,12 +34,16 @@ def calculate_model(image_path):
|
|||
estimated_sqm = extract_total_sqm(output)
|
||||
return estimated_sqm, output, predictions_tensor
|
||||
|
||||
|
||||
def improve_img_for_ocr(img: Image):
|
||||
img2 = np.array(img.convert('L'))
|
||||
cv2.resize(img2, None, fx=1.2, fy=1.2, interpolation=cv2.INTER_CUBIC)
|
||||
thresh = cv2.adaptiveThreshold(img2,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY,11,2)
|
||||
thresh = cv2.adaptiveThreshold(
|
||||
img2, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 11, 2
|
||||
)
|
||||
return Image.fromarray(thresh)
|
||||
|
||||
|
||||
def calculate_ocr(image_path):
|
||||
img = Image.open(image_path)
|
||||
text = pytesseract.image_to_string(img)
|
||||
|
|
@ -51,5 +55,5 @@ def calculate_ocr(image_path):
|
|||
with open("recalculating.log", "a") as f:
|
||||
f.write(f"before: {estimated_sqm} after: {estimated_sqm2} - {image_path}\n")
|
||||
return estimated_sqm2, text2
|
||||
|
||||
|
||||
return estimated_sqm, text
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@
|
|||
import enum
|
||||
from typing import List
|
||||
import requests
|
||||
# from rec.db import RightmoveListing
|
||||
|
||||
from rec.db import RightmoveListing
|
||||
import urllib3
|
||||
|
||||
urllib3.disable_warnings()
|
||||
|
|
@ -36,7 +35,10 @@ def detail_query(detail_id: int):
|
|||
url = f"https://api.rightmove.co.uk/api/property/{detail_id}"
|
||||
response = requests.get(url, params=params, headers=headers, verify=False)
|
||||
if response.status_code != 200:
|
||||
raise Exception(f"id: {detail_id}. Status Code: {response.status_code}. Failed due to: {response.text}")
|
||||
raise Exception(
|
||||
f"""id: {detail_id}. Status Code: {response.status_code}."""
|
||||
f"""Failed due to: {response.text}"""
|
||||
)
|
||||
|
||||
return response.json()
|
||||
|
||||
|
|
|
|||
|
|
@ -16,18 +16,34 @@ def transit_route(
|
|||
monday9am = nextMonday()
|
||||
|
||||
header = {
|
||||
"X-Goog-Api-Key": API_KEY,
|
||||
"Content-Type": "application/json",
|
||||
"X-Goog-FieldMask": "routes.distanceMeters,routes.duration,routes.staticDuration,routes.legs.steps.distanceMeters,routes.legs.steps.staticDuration,routes.legs.steps.travelMode",
|
||||
"X-Goog-Api-Key":
|
||||
API_KEY,
|
||||
"Content-Type":
|
||||
"application/json",
|
||||
"X-Goog-FieldMask":
|
||||
"routes.distanceMeters,routes.duration,routes.staticDuration,routes.legs.steps.distanceMeters,routes.legs.steps.staticDuration,routes.legs.steps.travelMode",
|
||||
}
|
||||
|
||||
body = {
|
||||
"origin": {
|
||||
"location": {"latLng": {"latitude": origin_lat, "longitude": origin_lon}}
|
||||
},
|
||||
"destination": {
|
||||
"location": {"latLng": {"latitude": dest_lat, "longitude": dest_lon}}
|
||||
},
|
||||
"origin":
|
||||
{
|
||||
"location":
|
||||
{
|
||||
"latLng": {
|
||||
"latitude": origin_lat,
|
||||
"longitude": origin_lon
|
||||
}
|
||||
}
|
||||
},
|
||||
"destination":
|
||||
{
|
||||
"location": {
|
||||
"latLng": {
|
||||
"latitude": dest_lat,
|
||||
"longitude": dest_lon
|
||||
}
|
||||
}
|
||||
},
|
||||
"travelMode": "TRANSIT",
|
||||
# "2023-10-15T15:01:23.045123456Z"
|
||||
"departureTime": monday9am.strftime("%Y-%m-%dT%H:%M:%S.%fZ"),
|
||||
|
|
@ -97,7 +113,6 @@ if __name__ == "__main__":
|
|||
|
||||
extract_time(d)
|
||||
|
||||
|
||||
# if __name__ == "__main__":
|
||||
# origin = 51.5635664310333, -0.1107173751570373 # home
|
||||
# dest = 51.50475678313417, 0.04915321000190009 # london city airport
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue