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
Beispiel #2
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.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_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)