2019年11月28日开发手记
巫师笔记 人气:0为了方便后面目标识别的处理,将投影求分类的函数嵌入进fft滤波函数中,共同组成fttmovedetect函数,利用python的切片功能实现投影
代码:
arryAllW[:] = arryAllW[:] + arryH[:] arryAllH[:] = arryAllH[:] + arryL[:]
为在投影中分割多目标区域,引入两个变量:Yindexh 与Yindexl,用于记录分界点的个数,其中分界点由python中的卷积函数求出:
arryAllHH[0, :] = np.convolve(arryAllHH[0, :], conMask, mode='same') # numpy函数中的卷积函数库 arryAllHL[0, :] = np.convolve(arryAllHL[0, :], conMask, mode='same') # numpy函数中的卷积函数库
又引入两个数组:yArryh[:]与yArryl[:] 用于记录分界点的位置,分界点位置的判断由以下语句实现:
for a in range(1, int(High / SteppingH), 1): if arryAllHH[0, a] > 0 and arryAllHH[0, (a - 1)] <= 0: yArryh[0, Yindexh] = a Yindexh = Yindexh + 1 if arryAllHH[0, a] <= 0 and arryAllHH[0, (a - 1)] > 0: yArryh[0, Yindexh] = a - 1 Yindexh = Yindexh + 1 if arryAllHL[0, a] > 0 and arryAllHL[0, (a - 1)] <= 0: yArryl[0, Yindexl] = a Yindexl = Yindexl + 1 if arryAllHL[0, a] <= 0 and arryAllHL[0, (a - 1)] > 0: yArryl[0, Yindexl] = a - 1 Yindexl = Yindexl + 1
接下来根据得到的分界点的数量与位置对运动图像进行分割:
for b in range(0, Yindexl, 2): frameshow = cv2.rectangle(frameshow, (xArryl[0,i]*SteppingW, yArryl[0,b]*SteppingH) , (xArryl[0, i+1]*SteppingW, yArryl[0,b+1]*SteppingH), (200, 10, 140), 6)
多目标检测完成,效果如图:
加载全部内容