|
|
@@ -1,34 +1,18 @@
|
|
|
import math
|
|
|
-from dataclasses import dataclass
|
|
|
|
|
|
import cv2 as cv
|
|
|
import numpy as np
|
|
|
from pathlib import Path
|
|
|
from typing import Any
|
|
|
-import magic
|
|
|
import arklog
|
|
|
from fastapi import APIRouter, Query, Request, Response
|
|
|
from fastapi.responses import JSONResponse
|
|
|
-from PIL import Image
|
|
|
import base64
|
|
|
-from io import BytesIO
|
|
|
|
|
|
-@dataclass
|
|
|
-class Artefact:
|
|
|
- """"""
|
|
|
- type: str
|
|
|
- content: str
|
|
|
- name: str
|
|
|
- encoding: str
|
|
|
-
|
|
|
-# def fill_artefact(data: dict) -> Artefact:
|
|
|
-# """"""
|
|
|
-# type = data.get("")
|
|
|
-# content = data.get("")
|
|
|
-# encoding = data.get("")
|
|
|
-# if type and content and encoding:
|
|
|
-# return Artefact(type, content, encoding)
|
|
|
-# raise ValueError
|
|
|
+from mocka.artefact import Artefact
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
def find_parallel(lines) -> []:
|
|
|
"""Find parallel lines and return their index."""
|
|
|
@@ -66,7 +50,7 @@ def rail_finder_algo_one(filename: str) -> (Artefact, Artefact):
|
|
|
x1, y1, x2, y2 = detected_lines[parallel_line_index][0]
|
|
|
cv.line(source_color_image, (x1, y1), (x2, y2), (0, 255, 0), 6, cv.LINE_AA)
|
|
|
# cv.imshow("Probabilistic Line Transform", source_color_image)
|
|
|
- temp_image_loc = Path(__file__).parent.parent / Path("data") / Path("rail_image_annotated.jpg")
|
|
|
+ temp_image_loc = Path(__file__).parent.parent.parent / Path("data") / Path("rail_image_annotated.jpg")
|
|
|
cv.imwrite(str(temp_image_loc), source_color_image)
|
|
|
with temp_image_loc.open("rb") as image_file:
|
|
|
data = base64.b64encode(image_file.read()).decode()
|
|
|
@@ -123,8 +107,8 @@ class OctivaRouter(APIRouter):
|
|
|
# algorithm = fill_artefact(algorithm_data)
|
|
|
|
|
|
# TODO Error checking
|
|
|
- rail_image = Image.open(BytesIO(base64.b64decode(rail_image_data.get("content"))))
|
|
|
- temp_image_loc = Path(__file__).parent.parent / Path("data") / Path("rail_image.jpg")
|
|
|
+ # rail_image = Image.open(BytesIO(base64.b64decode(rail_image_data.get("content"))))
|
|
|
+ temp_image_loc = Path(__file__).parent.parent.parent / Path("data") / Path("rail_image.jpg")
|
|
|
# rail_image.save(str(temp_image_loc), temp_image_loc.suffix[1:])
|
|
|
orig = base64.b64decode(rail_image_data.get("content"))
|
|
|
with temp_image_loc.open("wb") as f_output:
|
|
|
@@ -162,7 +146,7 @@ class OctivaRouter(APIRouter):
|
|
|
|
|
|
|
|
|
def main():
|
|
|
- filename = str(Path(__file__).parent.parent / Path("tests/octiva") / Path("rails_0.jpg"))
|
|
|
+ filename = str(Path(__file__).parent.parent.parent / Path("tests/octiva") / Path("rails_0.jpg"))
|
|
|
rail_finder_algo_one(filename)
|
|
|
# rail_finder_algo_two(filename)
|
|
|
cv.waitKey()
|