def measure(im, debug=False):
    im2 = image.max_size(im, (800, 600))
    
    b,g,r = image.split(im2)
    #cv.EqualizeHist(r,r)
    ##cv.EqualizeHist(g,g)
    ##cv.EqualizeHist(b,b)
    im2 = image.merge(b,g,r)
    
    eyes = 0
    #objs = []
    #for cascade in eye_cascades:
    #    print cascade
    #    cascade = cv.Load(cascade)
    #    objs = filter_overlap(detect(im, cascade))
    #    draw_objects(im, objs, color=cv.RGB(0,255,0))
    #    eyes += len(objs)
    #faces = 0
    if debug:
        im3 = cv.CloneImage(im2)
    faces = []
    for cascade in face_cascades:#(face_cascades[0],face_cascades[-1]):
        cascade = cv.Load(cascade)
        detected_faces = detect(im2, cascade)
        faces += detected_faces
        if debug:
            for i,rect in enumerate(faces):
                rect.draw(im3, color=cv.RGB(255,16*i,16*i))
    if debug:
        image.show(im3, "Faces + Repeats")
    faces = filter_overlap(faces)
    #print (objs[1], objs[6])
    #draw_objects(im2, map(tuple, faces.keys()))
    for rect, count in faces.iteritems():
        rect.draw(im2, color=cv.RGB(255,0,0))
    #print (objs[3],objs[13])
    #draw_objects(im, filter_overlap((objs[3],objs[13])))
    
    #objs = []
    #for cascade in body_cascades:
    #    print cascade
    #    cascade = cv.Load(cascade)
    #    objs += detect(im, cascade)
    #draw_objects(im, filter_overlap(objs), color=cv.RGB(0,0,255))

    #objs = []
    #for cascade in mouth_cascades:
    #    print cascade
    #    cascade = cv.Load(cascade)
    #    objs += detect(im, cascade)
    #draw_objects(im,  filter_overlap(objs), color=cv.RGB(255,0,255))
    
    score = 0
    for face_rect, count in faces.iteritems():
        score += count * 0.25 + 0.15
    print faces

    if debug:
        image.show(im2, "Faces")
    return (im2, faces), score
Exemplo n.º 2
0
v = image.new_from(l)
cv.Set(u, 0)
cv.Set(v, 0)

size = cv.GetSize(l)
print size

for x in range(256):
    for y in range(size[1]):
        cv.Set2D(u, y, x, x)
        cv.Set2D(v, 255 - x, min(y, 255), x)

image.show(u, "U")
image.show(v, "V")

rgb = image.luv2rgb(image.merge(l, u, v))
r, g, b = image.split(rgb)
#xor = image.threshold(image.Xor(u,v), 0, cv.CV_THRESH_BINARY)
xor = image.Xor(u, v)
cv.Threshold(xor, xor, 16, 255, cv.CV_THRESH_TOZERO)
image.show(rgb, "RGB")
image.show(xor, "Xor")

#cv.Sub(rgb, image.gray2rgb(image.invert(xor)), rgb)
_, sat, _ = image.split(image.rgb2hsv(rgb))
image.show(sat, 'Saturation')
#cv.Set(xor, 0, image.invert(image.threshold(sat, threshold=4)))

cv.Sub(rgb, image.invert(image.gray2rgb(xor)), rgb)

image.show(rgb, "Rgb - Xor")
Exemplo n.º 3
0
v = image.new_from(l)
cv.Set(u, 0)
cv.Set(v, 0)

size = cv.GetSize(l)
print size

for x in range(256):
    for y in range(size[1]):
        cv.Set2D(u, y, x, x)
        cv.Set2D(v, 255-x, min(y, 255), x)
        
image.show(u, "U")
image.show(v, "V")

rgb = image.luv2rgb(image.merge(l,u,v))
r,g,b = image.split(rgb)
#xor = image.threshold(image.Xor(u,v), 0, cv.CV_THRESH_BINARY)
xor = image.Xor(u,v)
cv.Threshold(xor, xor, 16, 255, cv.CV_THRESH_TOZERO)
image.show(rgb, "RGB")
image.show(xor, "Xor")

#cv.Sub(rgb, image.gray2rgb(image.invert(xor)), rgb)
_, sat, _ = image.split(image.rgb2hsv(rgb))
image.show(sat, 'Saturation')
#cv.Set(xor, 0, image.invert(image.threshold(sat, threshold=4)))

cv.Sub(rgb, image.invert(image.gray2rgb(xor)), rgb)

image.show(rgb, "Rgb - Xor")