Итак, я пытаюсь получить координаты данного трехмерного плана этажа, и эти координаты будут использоваться в программе Javascript с использованием THREE.JS, THREE.Vector3 и THREE.ExtrumeGeometry.
Это код, который я использовал:
import cv2 as cv
# Load your image
img = cv.imread("house-drawing.png")
# Convert image to grayscale
img_gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
# Thresholding to binarize the image (adjust threshold values as needed)
ret, thresh = cv.threshold(img_gray, 50, 255, cv.THRESH_BINARY)
# Find contours
contours, hierarchy = cv.findContours(thresh, cv.RETR_TREE, cv.CHAIN_APPROX_SIMPLE)
# Filter contours based on size or other criteria
filtered_contours = []
for contour in contours:
# Calculate contour area
area = cv.contourArea(contour)
# Filter contours based on area (adjust threshold as needed)
if area > 1000: # Adjust this value based on your image size and requirements
# Approximate the contour to reduce points
epsilon = 0.02 * cv.arcLength(contour, True)
approx = cv.approxPolyDP(contour, epsilon, True)
filtered_contours.append(approx)
# Print the coordinates of the contour
for point in approx:
x, y = point[0]
print(f"{{x: {x}, y: {y}}},")
# Draw contours on the original image
cv.drawContours(img, filtered_contours, -1, (0, 255, 0), 3)
# Save the output image
cv.imwrite("out.png", img)
Это целевое изображение, координаты которого я пытаюсь получить:
План этажа
Я пытаюсь чтобы получить такие координаты для моей программы Javascript с помощью Three JS:
]
{ x: 204, y: 363 },
{ x: 212, y: 48 },
{ x: 212, y: 191 },
{ x: 349, y: 191 },
{ x: 349, y: 49 },
]
Подробнее здесь: https://stackoverflow.com/questions/787 ... python-but
Попытка получить координаты из плана 2D-карты этажа с использованием OpenCV с использованием Python, но отсутствуют неко ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Исключение Android 14 при запуске службы переднего плана с типами переднего плана
Anonymous » » в форуме Android - 0 Ответы
- 60 Просмотры
-
Последнее сообщение Anonymous
-