Ejemplo n.º 1
0
 def __init__(self, video_src, paused=False):
     self.cap = video.create_capture(video_src)
     _, self.frame = self.cap.read()
     cv2.imshow('frame', self.frame)
     self.rect_sel = RectSelector('frame', self.onrect)
     self.trackers = []
     self.paused = paused
Ejemplo n.º 2
0
    def __init__(self, src):
        self.cap = video.create_capture(src, presets['book'])
        self.frame = None
        self.paused = False
        self.tracker = PlaneTracker()

        cv2.namedWindow('plane')
        self.rect_sel = common.RectSelector('plane', self.on_rect)
Ejemplo n.º 3
0
    def __init__(self, video_src):
        self.cam = video.create_capture(video_src, presets['cube'])
        self.cam.set(3, 320)
        self.cam.set(4, 240)
        ret, self.frame = self.cam.read()
        cv2.namedWindow('camshift')
        cv2.setMouseCallback('camshift', self.onmouse)

        self.selection = None
        self.drag_start = None
        self.show_backproj = False
        self.track_window = None
Ejemplo n.º 4
0
    img = levels[-1]
    for lev_img in levels[-2::-1]:
        img = cv2.pyrUp(img, dstsize=getsize(lev_img))
        img += lev_img
    return np.uint8(np.clip(img, 0, 255))


if __name__ == '__main__':
    import sys
    print(__doc__)

    try:
        fn = sys.argv[1]
    except:
        fn = 0
    cap = video.create_capture(fn)

    leveln = 6
    cv2.namedWindow('level control')
    for i in xrange(leveln):
        cv2.createTrackbar('%d' % i, 'level control', 5, 50, nothing)

    while True:
        ret, frame = cap.read()

        pyr = build_lappyr(frame, leveln)
        for i in xrange(leveln):
            v = int(cv2.getTrackbarPos('%d' % i, 'level control') / 5)
            pyr[i] *= v
        res = merge_lappyr(pyr)
Ejemplo n.º 5
0
    cv2.imshow('hsv_map', hsv_map)

    cv2.namedWindow('hist', 0)
    hist_scale = 10

    def set_scale(val):
        global hist_scale
        hist_scale = val

    cv2.createTrackbar('scale', 'hist', hist_scale, 32, set_scale)

    try:
        fn = sys.argv[1]
    except:
        fn = 0
    cam = video.create_capture(
        fn, fallback='synth:bg=../data/baboon.jpg:class=chess:noise=0.05')

    while True:
        flag, frame = cam.read()
        cv2.imshow('camera', frame)

        small = cv2.pyrDown(frame)

        hsv = cv2.cvtColor(small, cv2.COLOR_BGR2HSV)
        dark = hsv[..., 2] < 32
        hsv[dark] = 0
        h = cv2.calcHist([hsv], [0, 1], None, [180, 256], [0, 180, 0, 256])

        h = np.clip(h * 0.005 * hist_scale, 0, 1)
        vis = hsv_map * h[:, :, np.newaxis] / 255.0
        cv2.imshow('hist', vis)
Ejemplo n.º 6
0
    ESC   - exit

'''

import cv2

from Playground import video

if __name__ == '__main__':
    import sys
    try:
        video_src = sys.argv[1]
    except:
        video_src = 0

    cam = video.create_capture(video_src)
    mser = cv2.MSER_create()
    while True:
        ret, img = cam.read()
        gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
        vis = img.copy()

        regions = mser.detectRegions(gray)
        print(regions)
        hulls = [cv2.convexHull(p.reshape(-1, 1, 2)) for p in regions]
        cv2.polylines(vis, hulls, 1, (0, 255, 0))

        cv2.imshow('img', vis)
        if 0xFF & cv2.waitKey(5) == 27:
            break
    cv2.destroyAllWindows()