-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlaunch_Mapping.py
More file actions
86 lines (58 loc) · 2.22 KB
/
launch_Mapping.py
File metadata and controls
86 lines (58 loc) · 2.22 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# import packages
import numpy as np
import cv2
import imutils
import argparse
from skimage.filters import threshold_local
from scanning.transformations import *
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import tensorflow as tf
import cv2
import pathlib
from helper_functions import run_odt_and_draw_results
from helper_functions import preprocess_image
from helper_functions import detect_objects
import map_helper_functions
import os
from PIL import Image
import model_dependencies.config as config
#from pyecharts.charts import Barhelp_funcs.generate_map()
#help_funcs = help.help([1200,2500]) #change reference point
help_funcs = map_helper_functions.map_help([476,569])
MODEL_PATH = config.MODEL_PATH
MODEL_NAME = config.MODEL_NAME
cwd = os.getcwd()
DETECTION_THRESHOLD = 0.3
# Load the TFLite model
model_path = f'{MODEL_PATH}/{MODEL_NAME}'
interpreter = tf.lite.Interpreter(model_path=model_path)
interpreter.allocate_tensors()
# construct argument parser and parse args
ap = argparse.ArgumentParser()
ap.add_argument('-i', '--image', default='/home/autodrone-hardware/Documents/GitHub/Sensor_Sandbox/Out.jpg')
args = vars(ap.parse_args())
# load image, compute the ratio of old height
# to the new height, clone and resize
image = cv2.imread('/home/autodrone-hardware/Documents/GitHub/Sensor_Sandbox/20221026_221921_jpg.rf.393d11b2d4d25bd4680dcc8f6a94cc15.jpg')
name = args['image'][:len(args['image'])-4]
filename = name+'_scanned.jpg'
cv2.imwrite(filename, image)
print('saved scan: {}'.format(filename))
# Run inference and draw detection result on the local copy of the original file
detection_result_image = help_funcs.run_odt_and_draw_results_2(
'/home/autodrone-hardware/Documents/GitHub/Sensor_Sandbox/Out_scanned.jpg',
interpreter,
threshold=DETECTION_THRESHOLD,
)
img = Image.fromarray(detection_result_image)
img.save(f'{cwd}/result/ouput.jpg')
image = cv2.imread('/home/autodrone-hardware/Documents/GitHub/Sensor_Sandbox/result/ouput.jpg')
#image = imutils.resize(image,height=100,width=100)
cv2.imshow('Scanned Document', image)
#help_funcs.py_game_board()
help_funcs.create_graph()
#help_funcs.py_game_board()
#help_funcs.generate_map()
cv2.waitKey(0)
cv2.destroyAllWindows()