當前位置: 首頁>>代碼示例>>Python>>正文


Python Tester.test_on_descriptors方法代碼示例

本文整理匯總了Python中tester.Tester.test_on_descriptors方法的典型用法代碼示例。如果您正苦於以下問題:Python Tester.test_on_descriptors方法的具體用法?Python Tester.test_on_descriptors怎麽用?Python Tester.test_on_descriptors使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tester.Tester的用法示例。


在下文中一共展示了Tester.test_on_descriptors方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: Recognizer

# 需要導入模塊: from tester import Tester [as 別名]
# 或者: from tester.Tester import test_on_descriptors [as 別名]
class Recognizer(object):
    def __init__(self, vc, opts):
        self.vc = vc
        ret,im = vc.read()
        self.numGestures = opts.num
        self.imHeight,self.imWidth,self.channels = im.shape
        self.trainer = Trainer(numGestures=opts.num, numFramesPerGesture=opts.frames, minDescriptorsPerFrame=opts.desc, numWords=opts.words, descType=opts.type, kernel=opts.kernel, numIter=opts.iter, parent=self)
        self.tester = Tester(numGestures=opts.num, minDescriptorsPerFrame=opts.desc, numWords=opts.words, descType=opts.type, numPredictions=7, parent=self)

    def train_from_video(self):
        self.trainer.extract_descriptors_from_video()
        variance = self.trainer.kmeans()
        self.trainer.bow()
        score = self.trainer.svm()
        return score

    def train_from_descriptors(self, desList, trainLabels):
        self.trainer.desList = desList
        self.trainer.trainLabels = trainLabels
        #numFramesPerGesture = trainLabels.count(1)
        #self.trainer.desList = desList[:numFramesPerGesture*self.numGestures]
        #self.trainer.trainLabels = trainLabels[:numFramesPerGesture*self.numGestures]

        variance = self.trainer.kmeans()
        self.trainer.bow()
        score = self.trainer.svm()
        return score

    def train_from_images(self, gestureDirList, parentDirPath, trainMask, maskParentDirPath):
        self.trainer.extract_descriptors_from_images(gestureDirList, parentDirPath, trainMask, maskParentDirPath)
        variance = self.trainer.kmeans()
        self.trainer.bow()
        score = self.trainer.svm()
        return score

    def test_on_video(self, clf):
        #print clf.coef_
        self.tester.initialize(clf)
        self.tester.test_on_video()
    
    def test_on_descriptors(self, clf, descList, trueLabels):
        #numFramesPerGesture = trueLabels.count(1)
        #descList = descList[:numFramesPerGesture*self.numGestures]
        #trueLabels = trueLabels[:numFramesPerGesture*self.numGestures]
        self.tester.initialize(clf)
        testLabels = self.tester.test_on_descriptors(descList)
        matchList = [i for i, j in zip(trueLabels, testLabels) if i == j]
        score = float(len(matchList))/len(trueLabels)
        return score
開發者ID:arpitgit,項目名稱:Talk2dHand,代碼行數:51,代碼來源:recognizer.py


注:本文中的tester.Tester.test_on_descriptors方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。