def __init__(self): self._windowManager = WindowManager('Cameo', self.onKeypress) self._captureManager = CaptureManager(cv2.VideoCapture(0), self._windowManager, True) self._faceTracker = FaceTracker() self._shouldDrawDebugRects = False self._curveFilter = filters.BGRPortraCurveFilter()
def __init__(self): self._windowManager = WindowManager('Cameo', self.onKeypress) self._captureManager = CaptureManager( cv2.VideoCapture(0), self._windowManager, True)
class Cameo(object): def __init__(self): self._windowManager = WindowManager("Cameo", self.onKeypress) self._captureManager = CaptureManager(cv2.VideoCapture(0), self._windowManager, True) self._curveFilter = filters.EmbossFilter() def run(self): self._windowManager.createWindow() while self._windowManager.isWindowCreated: self._captureManager.enterFrame() frame = self._captureManager.frame filters.strokeEdges(frame, frame) self.captureFilter.apply(frame, frame) self._captureManager.exitFrame() self._windowManager.processEvents() def onKeypress(self, keycode): if keycode == 32: self._captureManager.writeImage("screenshot.png") elif keycode == 9: if not self._captureManager.isWritingVideo: self._captureManager.startWritingVideo("screencast.avi") else: self._captureManager.stopWritingVideo() elif keycode == 27: self._windowManager.destoryWindow()
class Track(object): def __init__(self): self._windowManager = WindowManager('Track', self.onKeypress) self._captureManager = CaptureManager(cv2.VideoCapture(0), self._windowManager, True) self._fgbg = cv2.BackgroundSubtractorMOG() def run(self): """Run the main loop.""" self._windowManager.createWindow() while self._windowManager.isWindowCreated: self._captureManager.enterFrame() frame = self._captureManager.frame fgmask = self._fgbg.apply(frame) ret, thresh = cv2.threshold(fgmask, 200, 255, 0) contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) count = 0 p1x = None p1y = None p2x = None p2y = None for c in contours: if cv2.contourArea(c) > 1000: count += 1 cx, cy, cw, ch = cv2.boundingRect(c) if p1x is None or cx < p1x: p1x = cx if p1y is None or cy < p1y: p1y = cy if p2x is None or p2x < cx + cw: p2x = cx + cw if p2y is None or p2y < cy + ch: p2y = cy + ch if count > 0: cv2.rectangle(frame, (p1x, p1y), (p2x, p2y), (0, 255, 0), 2) self._captureManager.exitFrame() self._windowManager.processEvents() def onKeypress(self, keycode): """Handle a keypress. space -> Take a screenshot. tab -> Start/stop recording a screencast. escape -> Quit.""" if keycode == 32: # space self._captureManager.writeImage('screenshot.png') elif keycode == 9: # tab if not self._captureManager.isWritingVideo: self._captureManager.startWritingVideo('screencast.avi') else: self._captureManager.stopWritingVideo() elif keycode == 27: # escape self._windowManager.destroyWindow()
def __init__(self, link=0, youtubelink=False): if (youtubelink and link != 0): pf = pafy.new(link) best = pf.getbest(preftype="mp4") link = best.url self._windowManager = WindowManager('Cameo', self.onKeyPress) self._captureManager = CaptureManager(cv2.VideoCapture(link), self._windowManager, False) self._filter = filters.BlurFilter()
class Cameo(object): def __init__(self): self._windowManager = WindowManager('Cameo', self.onKeypress) self._captureManager = CaptureManager(cv2.VideoCapture(0), self._windowManager, True) self._faceTracker = FaceTracker() self._shouldDrawDebugRects = False self._curveFilter = filters.BGRPortraCurveFilter() def run(self): """Run the main loop.""" self._windowManager.createWindow() while self._windowManager.isWindowCreated: self._captureManager.enterFrame() frame = self._captureManager.frame # TODO: Filter the frame self._faceTracker.update(frame) faces = self._faceTracker.faces rects.swapRects(frame, frame, [face.faceRect for face in faces]) filters.strokeEdges(frame, frame) self._curveFilter.apply(frame, frame) if self._shouldDrawDebugRects: self._faceTracker.drawDebugRects(frame) self._captureManager.exitFrame() self._windowManager.processEvents() def onKeypress(self, keycode): """Handle a keypress. space -> Take a screenshot. tab -> Start/stop recording a screencast. x -> Start/stop drawing debug rectangles around faces. escape -> Quit. """ if keycode == 32: # space self._captureManager.writeImage('screenshot.png') elif keycode == 9: # tab if not self._captureManager.isWritingVideo: self._captureManager.startWritingVideo('screencast.avi') else: self._captureManager.stopWritingVideo() elif keycode == 120: self._shouldDrawDebugRects = \ not self._shouldDrawDebugRects elif keycode == 27: # escape self._windowManager.destroyWindow()
class Cameo(object): def __init__(self): self._windowManager = WindowManager('Cameo', self.onKeypress) self._captureManager = CaptureManager(cv2.VideoCapture(0), self._windowManager, True) self._curveFilter = filters.BlurFilter() def run(self): """Run the main loop""" self._windowManager.createWindow() while self._windowManager.isWindowCreated: self._captureManager.enterFrame() frame = self._captureManager.frame filters.strokeEdges(frame, frame) self._curveFilter.apply(frame, frame) self._captureManager.exitFrame() self._windowManager.processEvents() def onKeypress(self, keycode): """Handle a keypress space -> Take a screenshot. tab -> Start/stop recoding a screencast. escape -> Quit. """ if keycode == 32: #space self._captureManager.writeImage( "/Users/red/Desktop/screenshot.png") elif keycode == 9: #tab if not self._captureManager.isWritingVideo: self._captureManager.startWritingVideo( "/Users/red/Desktop/screencast.avi") else: self._captureManager.stopWritingVideo() elif keycode == 27: # escape self._windowManager.destroyEvents()
class Cameo(object): def __init__(self): self._windowManager = WindowManager('Cameo',self.onKeypress) self._captureManager = CaptureManager( cv2.VideoCapture(0), self._windowManager, True) def run(self): """Run the main loop.""" self._windowManager.createWindow() while self._windowManager.isWindowCreated: self._captureManager.enterFrame() frame = self._captureManager.frame # TODO: Filter the frame (Chapter 3). self._captureManager.exitFrame() self._windowManager.processEvents() def onKeypress(self, keycode): """Handle a keypress. space -> Take a screenshot. tab -> Start/stop recording a screencast. escape -> Quit. """ if keycode == 32: # space self._captureManager.writeImage('screenshot.png') elif keycode == 9: # tab if not self._captureManager.isWritingVideo: self._captureManager.startWritingVideo( 'screencast.avi') else: self._captureManager.stopWritingVideo() elif keycode == 27: # escape self._windowManager.destroyWindow()
class Cameo(object): def __init__(self, link=0, youtubelink=False): if (youtubelink and link != 0): pf = pafy.new(link) best = pf.getbest(preftype="mp4") link = best.url self._windowManager = WindowManager('Cameo', self.onKeyPress) self._captureManager = CaptureManager(cv2.VideoCapture(link), self._windowManager, False) self._filter = filters.BlurFilter() def run(self): self._windowManager.createWindow() while self._windowManager.isWindowCreated: self._captureManager.enterFrame() frame = self._captureManager.frame self._captureManager.exitFrame() self._windowManager.processEvent() def onKeyPress(self, keycode): """Handle a keypress. space -> Take a screenshot. tab -> Start/stop recording a screencast. escape -> Quit. """ if keycode == 32: print('space pressed') self._captureManager.writeImage('screenshot.png') elif keycode == 9: if not self._captureManager.isWrittingVideo: self._captureManager.startWrittingVideo('screencat.avi') else: self._captureManager.stopWrittingVideo() elif keycode == 27: self._windowManager.destroyWindow()
class Cameo(object): def __init__(self): self._windowManager = WindowManager('cameo', self.onKeypress) # self._captureManager = CaptureManager(cv2.VideoCapture(0), self._windowManager, True) self._captureManager = CaptureManager( cv2.VideoCapture("/home/xu/Desktop/深度录屏_选择区域_20181231234930.mp4"), self._windowManager) def run(self): self._windowManager.createWindow() while self._windowManager.isWindowCreated: self._captureManager.enterFrame frame = self._captureManager.frame self._windowManager.show(frame) self._captureManager.exitFrame() self._windowManager.processEvents() def onKeypress(self, keycode): """ 处理按键事件 space 截图 tab screencast escape 退出 """ if keycode == 32: # space print("space pressed") self._captureManager.writeImage('screenshot.png') elif keycode == 9: # tab print("tab pressed") if self._captureManager.isWritingVideo: self._captureManager.stopWritingVideo() else: self._captureManager.startWritingVideo('screencast.avi') elif keycode == 27: # escape print("escape pressed") self._windowManager.destroyWindow()
def __init__(self): self._windowManager = WindowManager('cameo', self.onKeypress) # self._captureManager = CaptureManager(cv2.VideoCapture(0), self._windowManager, True) self._captureManager = CaptureManager( cv2.VideoCapture("/home/xu/Desktop/深度录屏_选择区域_20181231234930.mp4"), self._windowManager)
def __init__(self): self._windowManager = WindowManager('Track', self.onKeypress) self._captureManager = CaptureManager(cv2.VideoCapture(0), self._windowManager, True) self._fgbg = cv2.BackgroundSubtractorMOG()
def __init__(self): self._windowManager = WindowManager("Cameo", self.onKeypress) self._captureManager = CaptureManager(cv2.VideoCapture(0), self._windowManager, True) self._curveFilter = filters.EmbossFilter()
def __init__(self): self._windowManager = WindowManager('Cameo', self.onKeypress) self._captureManager = CaptureManager(cv2.VideoCapture(0), self._windowManager, True) self._curveFilter = filters.BGRPortraCurveFilter()
from manager import CaptureManager cm = CaptureManager() cm._capture = 0