def FindField(self):
#Feld: Hue zwischen 60 und 100
LowerGreen = np.array([40,0,0])
UpperGreen = np.array([90,255,150])
mask = cv2.inRange(self.ImgHSV,LowerGreen,UpperGreen)
# plt.figure()
# plt.imshow(mask,cmap='gray')
mask = self.SmoothFieldMask(mask)
# plt.figure()
# plt.imshow(mask.copy(),cmap='gray')
im2, contours, hierarchy = cv2.findContours(mask.copy(),cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
if(len(contours) <= 0):
return
contours_sorted = sorted(contours, key = cv2.contourArea, reverse=True)[:10]
peri = cv2.arcLength(contours_sorted[0],True)
approx = cv2.approxPolyDP(contours_sorted[0], 0.02*peri, True)
if(len(approx) >-1):#== 4):
self.FieldContours = approx
cv2.rectangle(mask,(((self.FieldContours[0])[0])[0],((self.FieldContours[0])[0])[1]),(((self.FieldContours[2])[0])[0],((self.FieldContours[2])[0])[1]),(128,128,128),3)
# plt.imshow(mask, cmap="gray")
# plt.show()
DetectField__old_and_not_used.py 文件源码
python
阅读 27
收藏 0
点赞 0
评论 0
评论列表
文章目录