示例#1
0
def drawRegions(image):
    # Draws all the squares on the frame
    '''
    sample data
    [0, 213, 426, 639]
    [0, 160, 320, 480]
    r1 = (0   , 0  ) (213  , 160)
    r2 = (213 , 0  ) (426  , 160)
    r3 = (426 , 0  ) (640  , 160)

    r4 = (0 ,  160 ) (213, 320)
    r5 = (213, 160 ) (426, 320)
    r6 = (426, 160 ) (640, 320)

    r7 = (0, 320 ) (213, 480)
    r8 = (213, 320 ) (426, 480)
    r9 = (426, 320 ) (640, 480)
    '''
    fontIndex = 0
    for i in xrange(regions.totalYintercepts-1):
        for ii in xrange(regions.totalXintercepts-1):
            x1 = regions.xIntercepts()[ii]
            x2 = regions.xIntercepts()[ii + 1]
            y1 = regions.yIntercepts()[i]
            y2 = regions.yIntercepts()[i+1]
            # draw the rectangles
            cv2.rectangle(image,(x1,y1),(x2,y2),(0,255,0),2)
            fontIndex = fontIndex + 1
            # draw the labels
            font = cv2.FONT_HERSHEY_SIMPLEX
            cv2.putText(image,str(fontIndex),(x1 +5,y1+25), font, 0.7,(255,255,255),2)
示例#2
0
def drawRegions(image):
    # Draws all the squares on the frame
    '''
    sample data
    [0, 213, 426, 639]
    [0, 160, 320, 480]
    r1 = (0   , 0  ) (213  , 160)
    r2 = (213 , 0  ) (426  , 160)
    r3 = (426 , 0  ) (640  , 160)

    r4 = (0 ,  160 ) (213, 320)
    r5 = (213, 160 ) (426, 320)
    r6 = (426, 160 ) (640, 320)

    r7 = (0, 320 ) (213, 480)
    r8 = (213, 320 ) (426, 480)
    r9 = (426, 320 ) (640, 480)
    '''
    fontIndex = 0
    for i in xrange(regions.totalYintercepts - 1):
        for ii in xrange(regions.totalXintercepts - 1):
            x1 = regions.xIntercepts()[ii]
            x2 = regions.xIntercepts()[ii + 1]
            y1 = regions.yIntercepts()[i]
            y2 = regions.yIntercepts()[i + 1]
            # draw the rectangles
            cv2.rectangle(image, (x1, y1), (x2, y2), (0, 255, 0), 2)
            fontIndex = fontIndex + 1
            #dra the labels
            font = cv2.FONT_HERSHEY_SIMPLEX
            cv2.putText(image, str(fontIndex), (x1 + 5, y1 + 25), font, 0.7,
                        (255, 255, 255), 2)
示例#3
0
            # corresponding to the center of the circle

            cv2.circle(image, (x, y), r, (0, 255, 0), 4)
            cv2.rectangle(image, (x - 5, y - 5), (x + 5, y + 5), (0, 128, 255),
                          -1)
            print "Region", regions.checkRegion(x, y)
            print "X: ", x, "Y: ", y

    # show the output image
    fontIndex = 0

    #draw all the regions
    for i in xrange(regions.totalYintercepts - 1):
        for ii in xrange(regions.totalXintercepts - 1):

            x1 = regions.xIntercepts()[ii]
            x2 = regions.xIntercepts()[ii + 1]
            y1 = regions.yIntercepts()[i]
            y2 = regions.yIntercepts()[i + 1]
            cv2.rectangle(image, (x1, y1), (x2, y2), (0, 255, 0), 2)
            fontIndex = fontIndex + 1
            font = cv2.FONT_HERSHEY_SIMPLEX
            cv2.putText(image, str(fontIndex), (x1 + 5, y1 + 25), font, 0.7,
                        (255, 255, 255), 2)

    cv2.imshow('Video', image)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

videoCapture.release()
cv2.destroyAllWindows()