Beispiel #1
0
                # this point is a correct point
                new_points.append (the_point)

                # draw the current point
                cv.cvCircle (image,
                             cv.cvPointFrom32f(the_point),
                             3, cv.cvScalar (0, 255, 0, 0),
                             -1, 8, 0)

            # set back the points we keep
            points [1] = new_points
            
        if add_remove_pt:
            # we want to add a point
            points [1].append (cv.cvPointTo32f (pt))

            # refine the corner locations
            points [1][-1] = cv.cvFindCornerSubPix (
                grey,
                [points [1][-1]],
                cv.cvSize (win_size, win_size), cv.cvSize (-1, -1),
                cv.cvTermCriteria (cv.CV_TERMCRIT_ITER | cv.CV_TERMCRIT_EPS,
                                   20, 0.03))[0]

            # we are no more in "add_remove_pt" mode
            add_remove_pt = False

        # swapping
        prev_grey, grey = grey, prev_grey
        prev_pyramid, pyramid = pyramid, prev_pyramid
                    # we will disable this point
                    continue

                # this point is a correct point
                new_points.append(the_point)

                # draw the current point
                cv.cvCircle(image, [the_point.x, the_point.y], 3,
                            cv.cvScalar(0, 255, 0, 0), -1, 8, 0)

            # set back the points we keep
            points[1] = new_points

        if add_remove_pt:
            # we want to add a point
            points[1].append(cv.cvPointTo32f(pt))

            # refine the corner locations
            points[1][-1] = cv.cvFindCornerSubPix(
                grey, [points[1][-1]], cv.cvSize(win_size, win_size),
                cv.cvSize(-1, -1),
                cv.cvTermCriteria(cv.CV_TERMCRIT_ITER | cv.CV_TERMCRIT_EPS, 20,
                                  0.03))[0]

            # we are no more in "add_remove_pt" mode
            add_remove_pt = False

        # swapping
        prev_grey, grey = grey, prev_grey
        prev_pyramid, pyramid = pyramid, prev_pyramid
        points[0], points[1] = points[1], points[0]