Exemple #1
0
  def run(self):
    k = cv.WaitKey(self.msdelay)
    k = chr(k) if k > 0 else 0
    if handle_keyboard(k) < 0:
        return False
    bgrimg = cv.QueryFrame(self.cam)
    if not bgrimg:
        return False
    bgrimg = im.resize(bgrimg, width=400)
    cv.Flip(bgrimg, None, 1)

    contours = self.session.process(bgrimg)

    max_contours = None
    if contours:
        max_contours = im.top_two_max_contours(contours)

    if max_contours:
        img = bgrimg
        #cv.Clone(bgrimg)
        cts = []
        for ct in max_contours:
            if ct[1]: cts.append(ct[1])
        finger_tips = im.get_finger_tips(cts, img)

        self.session.translate(finger_tips, img)
        if self.debug == 1: cv.ShowImage(self.proc_win_name, img)

        self.dumpScreen(img)

    return True
Exemple #2
0
 def __init__(self):
    self.dump = False
    self.move = None
    self.setAngle = None
    self.initWindows()
    self.cam = cv.CaptureFromCAM(0)
    skin_detector = skin.SkinDetector()
    motion_util = motion2.MotionUtility()
    cv.CreateTrackbar('l_hueThreshold',
                   self.proc_win_name,
                   SDC.GSD_HUE_LT,
                   255,
                   skin_detector.setHueThresholdLow)
    cv.CreateTrackbar('h_hueThreshold',
                   self.proc_win_name,
                   SDC.GSD_HUE_UT,
                   255,
                   skin_detector.setHueThresholdHigh)
    cv.CreateTrackbar('l_SaturationThreshold',
                   self.proc_win_name,
                   SDC.GSD_INTENSITY_LT,
                   255,
                   skin_detector.setIntensityThresholdLow)
    cv.CreateTrackbar('h_SaturationThreshold',
                   self.proc_win_name,
                   SDC.GSD_INTENSITY_UT,
                   255,
                   skin_detector.setIntensityThresholdHigh)
    self.session = ImageProcessSession(skin_detector, motion_util, self)
    img = cv.QueryFrame(self.cam)
    img = im.resize(img, width=400)
    self.session.set_size(img)
Exemple #3
0
def blockfacemask(bgrimg):
    global lastrects
    rects = detect_faces(bgrimg)
    rects = addheights(rects)
    newimg = im.newgray(bgrimg)
    cv.Set(newimg, 255)
    if rects:
        lastrects = rects
    else:
        rects = lastrects
    if rects:
        for rect in rects:
            cv.SetImageROI(newimg, rect)
            cv.Set(newimg, 0)
            cv.ResetImageROI(newimg)
    return newimg


if __name__ == '__main__':
    cam = cv.CaptureFromCAM(0)
    while True:
        img = cv.QueryFrame(cam)
        img = im.resize(img, width=400)
        faces = detect_faces(img)
        for f in faces:
            cv.Rectangle(img, (f[0], f[1]), (f[0] + f[2], f[1] + f[3]),
                         im.color.RED,
                         thickness=3)
        cv.Flip(img, None, 1)
        cv.ShowImage('face', img)
Exemple #4
0
 def iplimage(self):
     if not self._image:
         _image = cv.LoadImage(self.name, cv.CV_LOAD_IMAGE_COLOR)
         self._image = im.resize(_image, self.size)
     return self._image
Exemple #5
0
    or

    ./demo.py <filename1.png> <scale=0.5>
'''

gTracking = False
if __name__ == '__main__':
    import sys
    if len(sys.argv) < 2:
        print_helper()
        sys.exit(0)

    if 'track' in sys.argv[1:]:
        cam = cv.CaptureFromCAM(0)
        iplimage = cv.QueryFrame(cam)
        iplimage = im.resize(iplimage, gImageSize)
        cv.Flip(iplimage, None, 1)
        last_iplimage = iplimage
        gTracking = True
    else:
        # show matching results
        if isfloat(sys.argv[2]):
            scale = float(sys.argv[2])
            scaled_size = map(int, (gImageSize[0] * scale, gImageSize[1] * scale))
            imgobj2 = ImageObject(sys.argv[1], size=scaled_size)
        else:
            imgobj2 = ImageObject(sys.argv[2])
        imgobj1 = ImageObject(sys.argv[1])
        show_matching(imgobj1, imgobj2)

    print "Press 'q' to leave...(focus is on the window)"
Exemple #6
0
def blockfacemask(bgrimg):
    global lastrects
    rects = detect_faces(bgrimg)
    rects = addheights(rects)
    newimg = im.newgray(bgrimg)
    cv.Set(newimg, 255)
    if rects:
      lastrects = rects
    else:
      rects = lastrects
    if rects:
      for rect in rects:
        cv.SetImageROI(newimg, rect)
        cv.Set(newimg, 0)
        cv.ResetImageROI(newimg)
    return newimg

if __name__=='__main__':
    cam = cv.CaptureFromCAM(0)
    while True:
        img = cv.QueryFrame(cam)
        img = im.resize(img, width=400)
        faces = detect_faces(img)
        for f in faces:
            cv.Rectangle(img, (f[0],f[1]), (f[0]+f[2], f[1]+f[3]),
                    im.color.RED, thickness=3)
        cv.Flip(img,None, 1)
        cv.ShowImage('face', img)