Этот код не обнаруживает маркеры aruco и его идентификаторы. Кто-нибудь может исправить код
Он должен показывать правильный вывод, как будто он обнаруживает метки aruco
import numpy as np
import cv2
from cv2 import aruco
import matplotlib.pyplot as plt
# Prompt the user to select an image file
file_path = "markers.jpg"
# Load the image
image = cv2.imread(file_path)
if image is None:
print("Error: Could not load the image.")
exit()
# Convert image to grayscale
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# Use the predefined dictionary for ArUco markers
aruco_dict = aruco.Dictionary_get(aruco.DICT_4X4_250)
parameters = aruco.DetectorParameters_create()
# Detect markers
corners, ids, rejectedImgPoints = aruco.detectMarkers(gray, aruco_dict, parameters=parameters)
# Draw detected markers on the image
image_markers = aruco.drawDetectedMarkers(image.copy(), corners, ids)
# Display the image with detected markers
cv2.imshow('Image', image_markers)
# Process the detected markers for plotting (same as before)
if ids is not None:
plt.figure()
plt.imshow(cv2.cvtColor(image_markers, cv2.COLOR_BGR2RGB))
plt.axis('off') # Hide axis
for i in range(len(ids)):
c = corners[0]
plt.plot([c[:, 0].mean()], [c[:, 1].mean()], "o", label="id={0}".format(ids[0]))
plt.legend()
plt.show()
# Wait for 'q' key to close the window
if cv2.waitKey(0) & 0xFF == ord('q'):
cv2.destroyAllWindows()
Подробнее здесь: https://stackoverflow.com/questions/790 ... x-the-code
Этот код не обнаруживает маркеры aruco и его идентификаторы, кто-нибудь может исправить код ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение