示例#1
0
文件: unitTest.py 项目: Fanseling/-1
width = 98
target = {}  # 记录一帧中目标位置,放在track里
target['x'] = X
target['y'] = Y
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(
示例#2
0
文件: tracking.py 项目: Fanseling/-1
#以下是循环和循环要用的变量的初始化了
StanPosition =ut.getPosition(path)                #从标准位置文件中获取目标真实位置
CenterError =[]
blockSorted = []                                  # 块按概率排序的列表,八个块都在里面
targetPosition = []                                        #记录追踪过程中目标位置的序列
targetPosition.append(target)
blockClassifier = []                              # 每个块已训练好的的强分类器(adaboost分类器)
offsetInfo = []                                  # 维护分块的偏移信息,所有示例的值都相同,并且不需要重置
features = []
imaIndex=0
centerErr=[]

for image in images:                              #对于每一帧
    imaIndex+=1
    blocksInfos = []                                  # 维护示例的分块信息,每帧需要重置。第一维是示例,第二维是块
    imaMat = it.image2Mat(imagePath+'/'+image,color)  #图像转矩阵
    inteIma = it.getInteIma(imaMat)                   #积分图
    if image == '0001.jpg':                       #第一帧只学习,不分类,单独拿出来
        originIndex = 0
        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)))                #整个标签


        #上面两个都是二位列表,blocksInfos[0][0][x]是第一个示例的第一个块的起始坐标的x值

        for instance in posBag:                #对于每个正示例分块并存储。这个循环只能干这么点事
            # 分块,第一帧就用target了,没用targetPosition[-1]
            blocksInfo, offsetInfo = it.imageFrag(
                instance['x'], instance['y'], instance['lenth'], instance['width'], 2, 4)