pointPolygonTest(contour, pt, measureDist)
这个按照我们的需要设置为False即可,当measureDist设置为false时,若返回值为+1,表示点在轮廓内部,返回值为-1,表示在轮廓外部,返回值为0,表示在轮廓上。
flag_point2 = cv2.pointPolygonTest(contour[i],central_points_2_xy, False)
cv2.contourArea(contour)
输入一个边界矩阵,返回该轮廓包围的面积
cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
cv2.threshold(gray,127,255,cv2.THRESH_BINARY)
_,binary = cv2.threshold(gray,127,255,cv2.THRESH_BINARY) # 灰度图变二值图
cv2.findContours(binary, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
根据二值图找轮廓
contours, _ = cv2.findContours(binary, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) # 根据二值图找轮廓
cv2.drawContours(img,contours,contourIdx, color, thickness)
cv2.findContours
找出cv2.drawContours(img1,contours,-1,(0,0,255),1)
cv2.imshow("draw", img)
cv2.waitKey(0)
cv2.destroyAllWindows()
cv2.putText(image, text, (5,50 ), cv2.FONT_HERSHEY_SIMPLEX, 0.75, (0, 0, 255), 2)
图片,添加的文字,左上角坐标,字体,字体大小,颜色,字体粗细
font = cv2.FONT_HERSHEY_SIMPLEX
cv2.putText(img, "P", (100,100), font, 1, (0, 255, 0), 1)
circle: (img, center, radius, color, thickness)
cv2.circle(img,central_points,1,(255,255,0),4)
使用np.asarray(r_img)