当前位置: 首页>>代码示例>>Python>>正文


Python managers.CaptureManager类代码示例

本文整理汇总了Python中managers.CaptureManager的典型用法代码示例。如果您正苦于以下问题:Python CaptureManager类的具体用法?Python CaptureManager怎么用?Python CaptureManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CaptureManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: CameoDepth

class CameoDepth(Cameo):
    
    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
            
            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()
开发者ID:billcary,项目名称:OpenCV_with_Python,代码行数:31,代码来源:cameo.py

示例2: Cameo

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.strokeEdge(frame, frame)
            # self._curveFilter.apply(frame, frame)

            self._captureManager.exitFrame()
            self._windowManager.processEvents()

    def onKeypress(self, keycode):
        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()
        if keycode ==27:#esc
            self._windowManager.destroyWindow()
开发者ID:hooloong,项目名称:gitpython,代码行数:28,代码来源:cameo.py

示例3: Cameo

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()
开发者ID:richardqlin,项目名称:natural_language,代码行数:32,代码来源:camera.py

示例4: Cameo

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
            
            if frame is not None:
                
                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: # x
            self._shouldDrawDebugRects = \
                not self._shouldDrawDebugRects
        elif keycode == 27: # escape
            self._windowManager.destroyWindow()
开发者ID:sarvex,项目名称:pycv,代码行数:56,代码来源:cameo.py

示例5: __init__

 def __init__(self):
     self._windowManager = WindowManager('Facedetect', self.onKeypress)
     self._captureManager = CaptureManager(cv2.VideoCapture(camera_nr), self._windowManager, True)
     self._faceTracker = FaceTracker()
     self._shouldDrawDebugRects = True
     self._curveFilter = filters.BGRPortraCurveFilter()
开发者ID:StefQM,项目名称:facedetect,代码行数:6,代码来源:facedetect.py

示例6: __init__

 def __init__(self):
     self._windowManager = WindowManager('Cameo', self.onKeypress)
     self._captureManager = CaptureManager(cv2.VideoCapture(0),
                 self._windowManager, True)
     self._curveFilter = filters.BGRProviaCurveFilter()
     self._faceTracker = FaceTracker()
     self._shouldDrawDebugRects = False
开发者ID:UcheEke,项目名称:pyOCVExamples,代码行数:7,代码来源:cameo.py

示例7: setSource

    def setSource ( self, value ):
        if self._cap:
            if self._cap._capture.isOpened(): #ugly access to VideoCapture object from managers
                self._cap._capture.release()
        
        self._cap = CaptureManager( cv2.VideoCapture(int(value)) )
        #self.indWindow = cv2.namedWindow("Camera Display")
        self.showImage = True
        self.actualRes = self._cap.getResolution()


        # Set to default resolution from camera (640x480)
        #res = "%d x %d" % (int(self.actualRes[0]), int(self.actualRes[1]) )
        #index = self.ui.comboBox.findText(res) #Sets picker to default resolution
        #self.ui.comboBox.setCurrentIndex(index)

        # Set to Hoky desired default res (1280x960)
        res = "%d x %d" % (int(self.idealRes[0]), int(self.idealRes[1]) )
        index = self.ui.comboBox.findText(res) #Sets picker to default resolution
        self.ui.comboBox.setCurrentIndex(index)
        self.resolutionSelect()
        




        self.p = Point(200,300)
        self.c = Point(self.actualRes[0] // 2, self.actualRes[1] // 2)
        self.setAble('settings', True)
开发者ID:vsimonis,项目名称:gui-calibration,代码行数:29,代码来源:main.py

示例8: __init__

 def __init__(self):
     self._windowManager = WindowManager('Cameo',self.onKeypress)
     device = depth.CV_CAP_OPENNI # uncomment for Microsoft Kinect
     #device = depth.CV_CAP_OPENNI_ASUS # uncomment for Asus Xtion
     self._captureManager = CaptureManager(cv2.VideoCapture(device), self._windowManager, True)
     self._faceTracker = FaceTracker()
     self._shouldDrawDebugRects = False
     self._curveFilter = filters.BGRPortraCurveFilter()
开发者ID:ehivan24,项目名称:FaceRecognition,代码行数:8,代码来源:cameo.py

示例9: __init__

 def __init__(self):
     self._windowManager = WindowManager('Cameo',
                                          self.onKeypress)
     self._captureManager = CaptureManager(
         cv2.VideoCapture("videos/Megamind.avi"), self._windowManager, False)
     self._faceTracker = FaceTracker()
     self._shouldDrawDebugRects = False
     self._curveFilter = filters.BGRPortraCurveFilter()
开发者ID:CristopherPK,项目名称:motion-project,代码行数:8,代码来源:cameo.py

示例10: __init__

 def __init__(self):
     '''
     Constructor
     
     '''
     self._windowManager = WindowManager('Cameo', self.onKeypress)
     self._captureManager = CaptureManager(cv2.VideoCapture(0), self._windowManager, True)
     
     self._faceTracker = FaceTracker() 
     self._shouldDrawDebugRects = False
     
     self._curveFilter = filters.BGRCrossProcessCurveFilter()
开发者ID:ehivan24,项目名称:MisOpencv,代码行数:12,代码来源:cameo.py

示例11: CameoDouble

class CameoDouble(Cameo):
    
    def __init__(self):
        Cameo.__init__(self)
        self._hiddenCaptureManager = CaptureManager(
            cv2.VideoCapture(1))
    
    def run(self):
        """Run the main loop."""
        self._windowManager.createWindow()
        while self._windowManager.isWindowCreated:
            self._captureManager.enterFrame()
            self._hiddenCaptureManager.enterFrame()
            frame = self._captureManager.frame
            hiddenFrame = self._hiddenCaptureManager.frame
            
            if frame is not None:
                if hiddenFrame is not None:
                    self._faceTracker.update(hiddenFrame)
                    hiddenFaces = self._faceTracker.faces
                    self._faceTracker.update(frame)
                    faces = self._faceTracker.faces
                
                    i = 0
                    while i < len(faces) and i < len(hiddenFaces):
                        rects.copyRect(
                            hiddenFrame, frame, hiddenFaces[i].faceRect,
                            faces[i].faceRect)
                        i += 1
                
                filters.strokeEdges(frame, frame)
                self._curveFilter.apply(frame, frame)
                
                if hiddenFrame is not None and self._shouldDrawDebugRects:
                    self._faceTracker.drawDebugRects(frame)
            
            self._captureManager.exitFrame()
            self._hiddenCaptureManager.exitFrame()
            self._windowManager.processEvents()
开发者ID:sarvex,项目名称:pycv,代码行数:39,代码来源:cameo.py

示例12: __init__

 def __init__(self):
     self._windowManager = WindowManager('benFinder',
                                          self.onKeypress)
     device = depth.CV_CAP_FREENECT
     #device = 1
     print "device=%d" % device
     self._captureManager = CaptureManager(
         device, self._windowManager, True)
     self._captureManager.channel = depth.CV_CAP_OPENNI_BGR_IMAGE
     self._faceTracker = FaceTracker()
     self._shouldDrawDebugRects = False
     self._backgroundSubtract = False
     self._autoBackgroundSubtract = False
     self._curveFilter = filters.BGRPortraCurveFilter()
     self.background_video_img = None
     self.background_depth_img = None
     self.autoBackgroundImg = None
     self._ts = TimeSeries()
     self._frameCount = 0
开发者ID:OpenSeizureDetector,项目名称:OpenSeizureDetector,代码行数:19,代码来源:benFinder_debug.py

示例13: setSource

    def setSource ( self, value ):
        self.existingVid = False

        if type(value) != int:
            nums = re.compile(r'\d*')
            mat = re.match(nums,value).group(0)
            
            if re.match(nums, value).group(0) is not u'':
                src = int(value)
            else:
                src = str(value)
                self.existingVid = True
        else: #read in from calibration
            src = value
            self.ui.sourceCombo.setCurrentText(str(src))
            
        if self._cap:
            if self._cap._capture.isOpened(): #ugly access to VideoCapture object from managers
                self._cap._capture.release()

        
        self._cap = CaptureManager( cv2.VideoCapture(src) )
        self.showImage = True
        
        self.actualRes = self._cap.getResolution()
        
        if self.actualRes != self.calibrationRes and not self.existingVid:
            self._cap.setProp( 'height', self.calibrationRes[1] )
            self._cap.setProp( 'width', self.calibrationRes[0] )
        
        self.showImage = True

        self.actualRes = self._cap.getResolution()
        logger.warning("Actual resolution from cam is %s" % str( self.actualRes ) )
        self.setAble('source', False) 
        self.setAble('buttons', True)
        self.ui.buttonRefresh.setEnabled(False)
开发者ID:vsimonis,项目名称:gui-tracker,代码行数:37,代码来源:main.py

示例14: Browser

class Browser(object):
    
    def __init__(self,video_source):  
        self._windowManager = WindowManager('Browser', self.onKeypress)
        self._captureManager = CaptureManager(video_source, 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
            
            if frame is not None:
                print "got 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)
            else:
                print "got None frame"
                print "press any key to exit."
                cv2.waitKey(0)
                break
            self._captureManager.exitFrame()
            waitkey_time=1
            if self._captureManager._video_source!=0:   
                waitkey_time=500
            self._windowManager.processEvents(waitkey_time)
    
    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(
                    '/Users/xcbfreedom/Documents/screencast.avi')
            else:
                self._captureManager.stopWritingVideo()
        elif keycode == 120: # x
            self._shouldDrawDebugRects = \
                not self._shouldDrawDebugRects
        elif keycode == 27: # escape
            self._windowManager.destroyWindow()
开发者ID:hphp,项目名称:Kaggle,代码行数:61,代码来源:browse_video.py

示例15: BenFinder

class BenFinder(object):
    BACKGROUND_VIDEO_FNAME = "background_video.png"
    BACKGROUND_DEPTH_FNAME = "background_depth.png"
 
    def __init__(self):
        self._windowManager = WindowManager('benFinder',
                                             self.onKeypress)
        device = depth.CV_CAP_FREENECT
        #device = 1
        print "device=%d" % device
        self._captureManager = CaptureManager(
            device, self._windowManager, True)
        self._captureManager.channel = depth.CV_CAP_OPENNI_BGR_IMAGE
        self._faceTracker = FaceTracker()
        self._shouldDrawDebugRects = False
        self._backgroundSubtract = False
        self._autoBackgroundSubtract = False
        self._curveFilter = filters.BGRPortraCurveFilter()
        self.background_video_img = None
        self.background_depth_img = None
        self.autoBackgroundImg = None
        self._ts = TimeSeries()
        self._frameCount = 0
    
    def loadBackgroundImages(self):
        """ Load the background images to be used for background subtraction
        from disk files.
        """
        self.background_video_img = cv2.imread(BenFinder.BACKGROUND_VIDEO_FNAME)
        self.background_depth_img = cv2.imread(BenFinder.BACKGROUND_DEPTH_FNAME,
                                               cv2.CV_LOAD_IMAGE_GRAYSCALE)

    def showBackgroundImage(self):
        """ Display the background image used for subtraction in a separate window
        """
        # Load the images from disk if necessary.
        if (not self.background_depth_img or not self.background_video_img):
            self.loadBackgroundImages()
        # Display the correct image
        if (self._autoBackgroundSubtract):
            cv2.imshow("Auto Background Image", self.autoBackgroundImg)
        else:
            if (self._captureManager.channel == \
                depth.CV_CAP_OPENNI_DEPTH_MAP):
                cv2.imshow("background_depth_img",self.background_depth_img)
            elif (self._captureManager.channel == \
                  depth.CV_CAP_OPENNI_BGR_IMAGE):
                cv2.imshow("background_video_img",self.background_video_img)
            else:
                print "Error - Invalid Channel %d." % \
                    self._captureManager.channel

    def run(self):
        """Run the main loop."""
        self._windowManager.createWindow()
        while self._windowManager.isWindowCreated:
            self._captureManager.enterFrame()

            frame = self._captureManager.frame
            
            if frame is not None:
                if (self._backgroundSubtract):
                    if (self._autoBackgroundSubtract):
                        if (self._captureManager.channel == \
                            depth.CV_CAP_OPENNI_DEPTH_MAP):
                            if (self.autoBackgroundImg == None):
                                self.autoBackgroundImg = numpy.float32(frame)
                            # First work out the region of interest by 
                            #    subtracting the fixed background image 
                            #    to create a mask.
                            absDiff = cv2.absdiff(frame,self.background_depth_img)
                            benMask,maskArea = filters.getBenMask(absDiff,8)

                            cv2.accumulateWeighted(frame,
                                                   self.autoBackgroundImg,
                                                   0.05)
                            # Convert the background image into the same format
                            # as the main frame.
                            bg = cv2.convertScaleAbs(self.autoBackgroundImg,
                                                     alpha=1.0)
                            # Subtract the background from the frame image
                            cv2.absdiff(frame,bg,frame)
                            # Scale the difference image to make it more sensitive
                            # to changes.
                            cv2.convertScaleAbs(frame,frame,alpha=100)
                            #frame = cv2.bitwise_and(frame,frame,dst=frame,mask=benMask)
                            frame = cv2.multiply(frame,benMask,dst=frame,dtype=-1)
                            bri = filters.getMean(frame,benMask)
                            #print "%4.0f, %3.0f" % (bri[0],self._captureManager.fps)
                            self._ts.addSamp(bri[0])
                            if (self._frameCount < 15):
                                self._frameCount = self._frameCount +1
                            else:
                                self._ts.plotRawData()
                                self._ts.findPeaks()
                                self._frameCount = 0
                        else:
                            print "Auto background subtract only works for depth images!"
                    else:
                        if (self._captureManager.channel == \
#.........这里部分代码省略.........
开发者ID:OpenSeizureDetector,项目名称:OpenSeizureDetector,代码行数:101,代码来源:benFinder_debug.py


注:本文中的managers.CaptureManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。