def getConeCenterPoint(self,frame):
		o_contours = cvUtil.getContoursForColor(frame,FrameProcessor.ORANGE_LOW_HSV,FrameProcessor.ORANGE_HIGH_HSV,
												FrameProcessor.CONE_MIN_AREA,FrameProcessor.CONE_MAX_AREA,FrameProcessor.CONE_KERNEL)
		if(len(o_contours) > 0):
			lrgContour = cvUtil.getLargestContour(o_contours)
			centerLst = cvUtil.getCenterOfContours([lrgContour])
			cvUtil.drawCircleForPoints(frame,centerLst,3,(0,255,0),3)
			return centerLst[0]
		return None
Beispiel #2
0
 def getConeCenterPoint(self, frame):
     o_contours = cvUtil.getContoursForColor(frame,
                                             FrameProcessor.ORANGE_LOW_HSV,
                                             FrameProcessor.ORANGE_HIGH_HSV,
                                             FrameProcessor.CONE_MIN_AREA,
                                             FrameProcessor.CONE_MAX_AREA,
                                             FrameProcessor.CONE_KERNEL)
     if (len(o_contours) > 0):
         lrgContour = cvUtil.getLargestContour(o_contours)
         centerLst = cvUtil.getCenterOfContours([lrgContour])
         cvUtil.drawCircleForPoints(frame, centerLst, 3, (0, 255, 0), 3)
         return centerLst[0]
     return None
Beispiel #3
0
def removeCloseContours(contours,minDist):
	removeIndices = []
	centerLst = cvUtil.getCenterOfContours(contours)
	contoursLen = len(contours)
	for i in range(0,contoursLen):
		area_i = cv2.contourArea(contours[i])
		if(centerLst[i][0] >= 0):
			for j in range(i+1,contoursLen):
				area_j = cv2.contourArea(contours[j])
				if(centerLst[i][0] >= 0 and centerLst[j][0] >= 0):
					dist = getDist(centerLst[i],centerLst[j])
					if(dist < minDist):
						if(area_j < area_i):
							centerLst[j] = (-1,-1)
							removeIndices.append(j)
						else:
							centerLst[i] = (-1,-1)
							removeIndices.append(i)
							break

	for index in sorted(removeIndices, reverse=True):
		del centerLst[index]
		del contours[index]
	return centerLst