Wie zähle ich überlappende Aluminiumprofile in einem Bild mit konsistenten Querschnitt?Python

Python-Programme
Anonymous
 Wie zähle ich überlappende Aluminiumprofile in einem Bild mit konsistenten Querschnitt?

Post by Anonymous »

Ich habe ein Bild, das mehrere Aluminiumprofilquerschnitte zeigt, alle mit einer konsistenten Form . Aufgrund von Überlappung, Kipp- und Plastikverpackung ist es jedoch schwierig, sie mit der herkömmlichen Methode zu zählen.import cv2
import numpy as np
import matplotlib.pyplot as plt

# Load image
image = cv2.imread("aluminum_profiles.png")
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

# Edge detection
edges = cv2.Canny(gray, 50, 150)

# Morphological operations to clean up
kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (3, 3))
cleaned = cv2.morphologyEx(edges, cv2.MORPH_CLOSE, kernel)

# Find contours
contours, _ = cv2.findContours(cleaned, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)

# Filter and count large contours
count = 0
for cnt in contours:
area = cv2.contourArea(cnt)
if area > 1000: # Empirical threshold
count += 1
cv2.drawContours(image, [cnt], -1, (0, 255, 0), 2)

print("Detected profiles:", count)

# Show result
plt.imshow(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))
plt.axis('off')
plt.show()
< /code>

Ich habe OpenCV Canny Edge -Erkennung und findContours () ausprobiert. Überlappende Formen und Verpackungsrauschen machen es jedoch schwierig, einzelne Profile zu isolieren. SIFT /ORB, passende Keypoints wurden verstreut, was es schwierig machte, sie in unterschiedliche Instanzen zu gruppieren. Teilweise Okklusion.

• Kleine Rotationen. Instanzsegmentierungsmodell wie yolov8 /mask r-cnn effektiver sein?>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post