コード例 #1
0
 def close(self):
     cv.ReleaseCapture(self._capture)
コード例 #2
0
ファイル: pythonFaceDet.py プロジェクト: chimingwei/Alfred
                                    haar_scale, min_neighbors, haar_flags,
                                    (15, 15))

        # if eyes:
        # 	# For each eye found
        # 	for eye in eyes:
        # 		# Draw a rectangle around the eye
        # 		cv.Rectangle(image,
        # 		(eye[0][0],
        # 		eye[0][1]),
        # 		(eye[0][0] + eye[0][2],
        # 		eye[0][1] + eye[0][3]),
        # 		cv.RGB(255, 0, 0), 1, 8, 0)

    cv.ResetImageROI(image)
    return image


faceCascade = cv.Load("haarcascades/haarcascade_frontalface_default.xml")
eyeCascade = cv.Load("haarcascades/haarcascade_eye.xml")

while (cv.WaitKey(10) == -1):
    img = cv.QueryFrame(capture)

    image = DetectRedEyes(img, faceCascade, eyeCascade)
    #cv.ShowImage("Face and Eye Detection", image)
    # k = cv.WaitKey(10);
    # if k == 'f':
    # 	break
cv.ReleaseCapture(capture)
コード例 #3
0
ファイル: webserver.py プロジェクト: amuthelet/kondo
 def Close(self):
     cv.DestroyAllWindows()
     cv.ReleaseImage(videoImage)
     cv.ReleaseCapture(videoCapture)
     return
コード例 #4
0
def main():
    cv.NamedWindow('frame', cv.CV_WINDOW_AUTOSIZE)
    cv.MoveWindow('frame', 10, 10)
    cv.NamedWindow('edges', cv.CV_WINDOW_AUTOSIZE)
    cv.MoveWindow('edges', 600, 10)

    parser = OptionParser()
    parser.add_option('-s',
                      '--seek',
                      action='store',
                      type='int',
                      dest='seek',
                      default=0)
    parser.add_option('-i',
                      '--image',
                      action='store_true',
                      dest='image',
                      default=False)
    parser.add_option('-v',
                      '--verbose',
                      action='store_true',
                      dest='verbose',
                      default=False)
    options, args = parser.parse_args()

    global verbose
    verbose = options.verbose

    if options.image:
        # Use image
        frame = cv.LoadImage(args[0])
        if frame is None:
            print 'Error loading image %s' % args[0]
            return
        find_lines(frame)

        # Pause for key press
        while True:
            k = cv.WaitKey(33)
            if k == ord('q'):
                break
    else:
        if len(args) > 0:
            # Use video
            cam = cv.CaptureFromFile(args[0])
            if cam is None:
                print 'Error opening file'
                return
        else:
            # Use webcam
            cam = cv.CreateCameraCapture(1)
            if cam is None:
                print 'Error opening camera'
                return

        # Seek to initial position by discarding frames
        for i in range(options.seek):
            cv.GrabFrame(cam)

        while True:
            frame = cv.QueryFrame(cam)
            if frame is None:
                print 'End of video'
                break
            find_lines(frame)

            k = cv.WaitKey(10)
            if k == ord('q'):
                break
        cv.ReleaseCapture(cam)
コード例 #5
0
ファイル: ocv.py プロジェクト: NidayeCC/Pyocv
 def __del__(self):
     """Destroy instance"""
     try:
         cv.ReleaseCapture(self.capture)
     except:
         pass