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
Example #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
	def getTrianglePointLst(self,frame):
		algorithms.largestArea = 0
		algorithms.minPtsDistance = sys.float_info.max

		contours = cvUtil.getContoursForColor(frame,FrameProcessor.BLUE_LOW_HSV,FrameProcessor.BLUE_HIGH_HSV,
													FrameProcessor.LEDS_MIN_AREA,FrameProcessor.LEDS_MAX_AREA,FrameProcessor.LED_KERNEL)
		centerLst = algorithms.removeCloseContours(contours,2)
		closestCenters = algorithms.getNClosestPoints(centerLst,4)

		if(closestCenters != None):
			#cvUtil.drawCircleForPoints(frame,closestCenters,5,(0,0,255),1)
			lrgTriPtList = algorithms.getLargestTriangle(closestCenters)
			baseCenterPt = algorithms.getClosestPt(lrgTriPtList,closestCenters)
			sortedPts = algorithms.getSortedPtListInTri(baseCenterPt,lrgTriPtList)
			cvUtil.drawDirectionalTriangle(frame,sortedPts)
			return baseCenterPt,sortedPts
		else:
			return None,None
Example #4
0
    def getTrianglePointLst(self, frame):
        algorithms.largestArea = 0
        algorithms.minPtsDistance = sys.float_info.max

        contours = cvUtil.getContoursForColor(frame,
                                              FrameProcessor.BLUE_LOW_HSV,
                                              FrameProcessor.BLUE_HIGH_HSV,
                                              FrameProcessor.LEDS_MIN_AREA,
                                              FrameProcessor.LEDS_MAX_AREA,
                                              FrameProcessor.LED_KERNEL)
        centerLst = algorithms.removeCloseContours(contours, 2)
        closestCenters = algorithms.getNClosestPoints(centerLst, 4)

        if (closestCenters != None):
            #cvUtil.drawCircleForPoints(frame,closestCenters,5,(0,0,255),1)
            lrgTriPtList = algorithms.getLargestTriangle(closestCenters)
            baseCenterPt = algorithms.getClosestPt(lrgTriPtList,
                                                   closestCenters)
            sortedPts = algorithms.getSortedPtListInTri(
                baseCenterPt, lrgTriPtList)
            cvUtil.drawDirectionalTriangle(frame, sortedPts)
            return baseCenterPt, sortedPts
        else:
            return None, None
videoCap = cv2.VideoCapture(1)
videoCap.set(cv2.cv.CV_CAP_PROP_FRAME_WIDTH, FRAME_WIDTH)
videoCap.set(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT, FRAME_HEIGHT)

kernel = np.ones((2, 2), np.uint8)

while (True):
    ret, frame = videoCap.read()
    cv2.setMouseCallback('frame', fc.frameClickEvent, frame)
    hsvFrame = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
    threshImg = cv2.inRange(hsvFrame, selectLowHSV, selectHighHSV)

    algorithms.largestArea = 0
    algorithms.minPtsDistance = sys.float_info.max
    contours = cvUtil.getContoursForColor(frame, selectLowHSV, selectHighHSV,
                                          MIN_CONTOUR_AREA, MAX_CONTOUR_AREA)
    centerLst = algorithms.removeCloseContours(contours, 10)
    cvUtil.drawCircleForPoints(frame, centerLst, 5, (0, 255, 0), 1)
    print centerLst
    closestCenters = algorithms.getNClosestPoints(centerLst, 4)
    cvUtil.drawCircleForPoints(frame, closestCenters, 5, (0, 255, 0), 1)
    '''
	if(closestCenters == None):
		cv2.imshow('frame',frame)
		continue

	lrgTriPtList = algorithms.getLargestTriangle(closestCenters)
	baseCenterPt = algorithms.getClosestPt(lrgTriPtList,closestCenters)
	sortedPts = algorithms.getSortedPtListInTri(baseCenterPt,lrgTriPtList)
	drawDirectionalTriangle(frame,sortedPts)
	
videoCap.set(cv2.cv.CV_CAP_PROP_FRAME_WIDTH,FRAME_WIDTH)
videoCap.set(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT,FRAME_HEIGHT)

kernel = np.ones((2,2),np.uint8)

while(True):
	ret,frame = videoCap.read()
	cv2.setMouseCallback('frame',fc.frameClickEvent,frame)
	hsvFrame = cv2.cvtColor(frame,cv2.COLOR_BGR2HSV)
	threshImg = cv2.inRange(hsvFrame,selectLowHSV,selectHighHSV)

	
	
	algorithms.largestArea = 0
	algorithms.minPtsDistance = sys.float_info.max
	contours = cvUtil.getContoursForColor(frame,selectLowHSV,selectHighHSV,MIN_CONTOUR_AREA,MAX_CONTOUR_AREA)
	centerLst = algorithms.removeCloseContours(contours,10)
	cvUtil.drawCircleForPoints(frame,centerLst,5,(0,255,0),1)
	print centerLst
	closestCenters = algorithms.getNClosestPoints(centerLst,4)
	cvUtil.drawCircleForPoints(frame,closestCenters,5,(0,255,0),1)
	
	
	'''
	if(closestCenters == None):
		cv2.imshow('frame',frame)
		continue

	lrgTriPtList = algorithms.getLargestTriangle(closestCenters)
	baseCenterPt = algorithms.getClosestPt(lrgTriPtList,closestCenters)
	sortedPts = algorithms.getSortedPtListInTri(baseCenterPt,lrgTriPtList)