Exemple #1
0
def zoneActive(zone_active, framebuffer, iteration):
    critere.max_iter = 5
    hauteur = hauteur_image / pow(2, iteration + 1)
    largeur = largeur_image / pow(2, iteration + 1)
    for i in range(0, len(zone_active)):
        zone = cv.cvRect(zone_active[i].x, zone_active[i].y, largeur, hauteur)
        origine_x_zone = zone_active[i].x
        origine_y_zone = zone_active[i].y
        index = 0
        for x in range(origine_x_zone, origine_x_zone + (largeur * 2),
                       largeur):
            for y in range(origine_y_zone, origine_y_zone + (hauteur * 2),
                           hauteur):
                zone.x = x
                zone.y = y
                trouver = 0
                trouver = cv.cvMeanShift(framebuffer, zone, critere,
                                         cv.CvConnectedComp())
                if trouver != 0:
                    #cv.cvRectangle(frame, cv.cvPoint(x,y), cv.cvPoint((x+largeur), (y+hauteur)), color)
                    if index == 0:
                        zone_active[i] = cv.cvRect(x, y, largeur, hauteur)
                    else:
                        zone_active += [cv.cvRect(x, y, largeur, hauteur)]
                    index = index + 1
    return zone_active
Exemple #2
0
def pointeurPrecision(zone_active, framebuffer):
    info_size = []
    centre = []
    for i in range(0, len(zone_active)):
        conteneur = cv.CvConnectedComp()
        info = cv.CvBox2D()
        trouver = cv.cvCamShift(framebuffer, zone_active[i], critere,
                                conteneur, info)
        info_size.append(info.size.height * info.size.width)
        centre.append(cv.cvPoint(int(info.center.x), int(info.center.y)))
        #***** possibilite de recuperer l angle *****#
    return [centre, info_size]
Exemple #3
0
def zoneActivePremier(zone_active, framebuffer):
    critere.max_iter = 1
    zone_active = []
    zone = cv.cvRect(0, 0, largeur_image / 2, hauteur_image / 2)
    for x in range(0, largeur_image, largeur_image / 2):
        for y in range(0, hauteur_image, hauteur_image / 2):
            zone.x = x
            zone.y = y
            trouver = cv.cvMeanShift(framebuffer, zone, critere,
                                     cv.CvConnectedComp())
            if trouver != 0:
                zone_active += [
                    cv.cvRect(x, y, largeur_image / 2, hauteur_image / 2)
                ]
    #print "zoneActivePremier() a trouver "+str(len(zone_active))+" zone active"
    return zone_active
Exemple #4
0
    # move the new window to a better place
    highgui.cvMoveWindow('Camera', 10, 40)
    highgui.cvMoveWindow('Histogram', 10, 270)

    global mouse_origin
    global mouse_selection
    global mouse_select_object
    mouse_select_object = False
    global track_object
    track_object = 0

    global track_comp
    global track_box

    track_comp = cv.CvConnectedComp()
    track_box = cv.CvBox2D()

    highgui.cvSetMouseCallback("Camera", on_mouse, 0)

    try:
        # try to get the device number from the command line
        device = int(sys.argv[1])

        # got it ! so remove it from the arguments
        del sys.argv[1]
    except (IndexError, ValueError):
        # no device number on the command line, assume we want the 1st device
        device = 0

    if len(sys.argv) == 1: