示例#1
0
文件: unitTest.py 项目: Fanseling/-1
target['lenth'] = lenth
target['width'] = width
targetPosition = []  # 记录追踪过程中目标位置的序列
targetPosition.append(target)
numFeat = 4
numFern = 10
testX = 121
testY = 61
testLenth = 77
testWidth = 93

imaMat = it.image2Mat(imagePath + '/' + "0001.jpg", 1)
inteIma = it.getInteIma(imaMat)


posBag = it.getPosBag(X, Y, lenth, width)  # 正包
lables = list(np.ones(len(posBag)))  # 正包标签
negBag = it.getNegBag(X, Y, lenth, width, 1, 1)  # 负包
lables.extend(np.zeros(len(negBag)))  # 整个标签

offsetInfo = []  # 这个是块偏移信息,放外面
#print(allInstance)
blocksInfos = []        # 每个块的信息,这里一幅图就是一个块。
blockClassifier = []    # 每个块已训练好的的强分类器(adaboost分类器)
blockInfos = posBag.extend(negBag)
blocksInfos.append(blockInfos)  #为了使用以前写的randomFen函数,而这么搞的
randomFerns, dataMats, features = lt.randomFern(
    inteIma, blocksInfos, lables, numFeat, numFern)


示例#2
0
文件: test.py 项目: Fanseling/-1
target['width'] = width
targetPosition = []  #记录追踪过程中目标位置的序列
targetPosition.append(target)
numFeat = 4
numFern = 12
testX = 121
testY = 61
testLenth = 77
testWidth = 93

imaMat = it.image2Mat(imagePath + '/' + "0001.jpg", 1)
inteIma = it.getInteIma(imaMat)

posBag = it.getPosBag(X, Y, lenth, width)  #正包
lables = list(np.ones(len(posBag)))  #正包标签
negBag = it.getNegBag(X, Y, lenth, width, 2, 4)  #负包
lables.extend(np.zeros(len(negBag)))  #整个标签
#负包并不是以整个图片出现的,而是以同一个块的组合出现,使每个块都学习到相同的

offsetInfo = []  #这个是块偏移信息,放外面
#print(allInstance)
blocksInfos = []
blockClassifier = []  # 每个块已训练好的的强分类器(adaboost分类器)

for instance in posBag:  #对于每个正示例分块并存储。这个循环只能干这么点事。
    # 分块,第一帧就用target了,没用targetPosition[-1]
    blocksInfo, offsetInfo = it.imageFrag(instance['x'], instance['y'],
                                          instance['lenth'], instance['width'],
                                          2, 4)
    #blocksInfo记录块的起始位置xy以及块的长宽。offsetInfo记录块相对于图像的偏移信息
    blocksInfos.append(blocksInfo)  #所有示例的偏移信息是一样的,不需要在添加一个列表