本文整理汇总了Python中trainer.Trainer.extract_descriptors_from_video方法的典型用法代码示例。如果您正苦于以下问题:Python Trainer.extract_descriptors_from_video方法的具体用法?Python Trainer.extract_descriptors_from_video怎么用?Python Trainer.extract_descriptors_from_video使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trainer.Trainer
的用法示例。
在下文中一共展示了Trainer.extract_descriptors_from_video方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Recognizer
# 需要导入模块: from trainer import Trainer [as 别名]
# 或者: from trainer.Trainer import extract_descriptors_from_video [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