【发布时间】:2018-10-28 08:09:58
【问题描述】:
我正在互联网上搜索最佳代码以找到 OpenCV 框架的质心 XY 坐标,但没有找到。
我知道如何找到轮廓的质心/中心,如下(在 python 中):
image = cv2.imread("test.png"])
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
blurred = cv2.GaussianBlur(gray, (5, 5), 0)
thresh = cv2.threshold(blurred, 60, 255, cv2.THRESH_BINARY)[1]
# find contours in the thresholded image
cnts = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL,
cv2.CHAIN_APPROX_SIMPLE)
cnts = cnts[0]
#print cnts
# loop over the contours
for c in cnts:
# compute the center of the contour
M = cv2.moments(c)
cX = int(M["m10"] / M["m00"])
cY = int(M["m01"] / M["m00"])
其中
CX、CY是所需的 XY 坐标 但是如何在 OpenCV 中找到整个视频帧/图像的这些坐标
请任何人都可以帮助我吗?
【问题讨论】: