【发布时间】:2021-01-14 21:35:56
【问题描述】:
我有兴趣在此图像中找到对象(即点)并在每个对象周围绘制一个矩形。我开始知道cv2 并发现这很容易做到。所以到目前为止,我已经通过一些快速的谷歌搜索编写了以下代码:
import numpy as np
import matplotlib.pyplot as plt
import cv2
print( cv2.__version__ )
# source data
img_file= "data1.png"
# create an OpenCV image
img= cv2.imread(img_file)
plt.imshow(img, cmap='gray')
# Define the classifiers
# pre-trained classifiers
Point_classifier="haarcascade_eye.xml"
# convert color image to grey image
gray_img=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
# CREATE TRACKER
point_tracker=cv2.CascadeClassifier(Point_classifier)
# detect points
points= point_tracker.detectMultiScale(gray_img)
print(points)
Here I used `haarcascade_eye.xml` it looks similar to the point feature of the image, Is this correct? or do I need to use another classifier for this object?
但结果并不如预期。我期待像这样的图,其中每个点都应单独标记为矩形。
对此或我在代码中出错的地方有任何帮助。提前致谢。
【问题讨论】:
标签: python computer-vision object-detection cv2