51 lines
1.5 KiB
Python
51 lines
1.5 KiB
Python
import cv2
|
|
|
|
import show_img_conditions
|
|
import remove_bg
|
|
import get_head
|
|
import get_egdes
|
|
import coordinates_change
|
|
import time
|
|
|
|
import numpy as np
|
|
|
|
def coordinates(origin, new_size, angle, sym, live):
|
|
if live == 0:
|
|
print("Webcam take picture")
|
|
time.sleep(2)
|
|
show_img_conditions.show()
|
|
image_path = get_head.get_image()
|
|
background_path = remove_bg.rmbg(image_path)
|
|
|
|
if live == 1:
|
|
print("Picture from files")
|
|
time.sleep(2)
|
|
background_path = "output.png"
|
|
|
|
background = cv2.imread(background_path)
|
|
#cv2.imshow('Image without background', background)
|
|
|
|
gray_image = cv2.cvtColor(background, cv2.COLOR_BGR2GRAY)
|
|
contours = get_egdes.edges(gray_image)
|
|
#cv2.imshow("contours", edges)
|
|
#cv2.waitKey(0)
|
|
|
|
|
|
[x_min, y_min, x_scale, y_scale] = coordinates_change.scale_calculator(contours, new_size)
|
|
|
|
new_coords = coordinates_change.new_coord(contours, x_scale, y_scale, angle)
|
|
|
|
size = coordinates_change.get_size(new_coords)
|
|
|
|
x_max = size[0][1]
|
|
y_max = size[1][1]
|
|
new_coords = coordinates_change.symetry(new_coords, x_max, y_max, sym)
|
|
|
|
new_coords = coordinates_change.set_origin(new_coords, origin)
|
|
|
|
print("origin : x = ", origin[0], " , y = ", origin[1], " , z = ", origin[2])
|
|
print("size : ", int(size[0][1] - size[0][0]), "x", int(size[1][1] - size[1][0]), "mm")
|
|
print("nb points : ", len(new_coords))
|
|
coordinates_change.plot_function(new_coords)
|
|
#coordinates_change.draw_function(new_coords)
|
|
return new_coords |