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


Python ClassificationDataSet.clear方法代码示例

本文整理汇总了Python中pybrain.datasets.ClassificationDataSet.clear方法的典型用法代码示例。如果您正苦于以下问题:Python ClassificationDataSet.clear方法的具体用法?Python ClassificationDataSet.clear怎么用?Python ClassificationDataSet.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pybrain.datasets.ClassificationDataSet的用法示例。


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

示例1: __init__

# 需要导入模块: from pybrain.datasets import ClassificationDataSet [as 别名]
# 或者: from pybrain.datasets.ClassificationDataSet import clear [as 别名]

#.........这里部分代码省略.........
            
        
        cv.Rectangle (image, self.pt1, self.pt2, (0, 255, 0), 1)
        
        cv.SetImageROI(image, currentrect)
        
        st = time.time()
        
        out = self.ClassifyWindow(grayscale, currentrect)
        print out, '|time', time.time() - st

        cv.ResetImageROI(image)        

        if out == 1:
            cv.Rectangle (image, (currentrect[0], currentrect[1]), (currentrect[2] + currentrect[0], currentrect[3] + currentrect[1]), (0, 255, 255), 5)

            self.pt1, self.pt2 = PatchBoundary(tracks, self.pt1, self.pt2)
            tmp = self.ImageFromRect(grayscale, currentrect)
            features = FeaturesFromImg(grayscale, self.ninsize)
            self.additionslds.addSample(features, [1])
            for i in xrange(2):
                badwin = self.ImageFromRect(grayscale, RandomRect(currentrect))
                features = FeaturesFromImg(badwin, self.ninsize)
                self.additionslds.addSample(features, [0])
            print 'len of new dataset', len(self.additionslds)
        '''
        else:
            rect = self.SearchObject(grayscale, currentrect)
            if rect:
                self.pt1, self.pt2 = RectToPoints(rect)
        '''

        if self.stage > 0:
            tmp = self.ImageFromRect(grayscale, currentrect)
            features = FeaturesFromImg(grayscale, self.ninsize)
            self.additionslds.addSample(features, [1])
            for i in xrange(2):
                badwin = self.ImageFromRect(grayscale, RandomRect(currentrect))
                features = FeaturesFromImg(badwin, self.ninsize)
                self.additionslds.addSample(features, [0])
            print 'len of new dataset', len(self.additionslds)

        if len(self.additionslds) > 20:
            
            self.additionslds._convertToOneOfMany( )
            self.additionslds.outdim = self.net.outdim
            
            #net = buildNetwork(self.ninsize[0] * self.ninsize[1], 96, self.additionslds.outdim, outclass=SoftmaxLayer)
            trainer = RPropMinusTrainer(
                self.net, dataset=self.additionslds,
                momentum=0.1, verbose=True, weightdecay=0.01)
            '''trainer = BackpropTrainer(
                self.net, dataset=self.additionslds,
                momentum=0.1, verbose=True, weightdecay=0.01)'''
            trainer.trainEpochs( 3 )
            self.additionslds.clear()
            self.numoflearning += 1
        
        if self.key == 113:            
            cv.SaveImage('img.bmp', image)
            self.key = 255

        if self.key == 119:            
            self.stage = 1
            self.key = 255

        if self.stage == 1 and self.numoflearning > 2:
            self.stage = 2

        '''   
        for item in tracks:
            cv.Circle(image, (item[-1][0], item[-1][1]), 2, (0, 255, 0), -1)
        '''
        
        return image


    def run(self):    

        DEVICE = 0 #/dev/video0
        # create windows
        cv.NamedWindow('Camera')
     
        # create capture device
        device = 0 # assume we want first device
        capture = cv.CreateCameraCapture(DEVICE)
     
        k = ''
        while k !='q' :
            frame = cv.QueryFrame(capture)#cv.RetrieveFrame(capture)
            if frame is None:
                break    
            cv.Flip(frame, None, 1)                    
            frame = self.work(frame)            
            # display webcam image
            cv.ShowImage('Camera', frame)
            k = cv.WaitKey(10) % 0x100
            if k !=255 :
                self.key = k
                print 'pressed', k
开发者ID:Daiver,项目名称:scripts,代码行数:104,代码来源:learninig_tracker.py


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