|
|
@ -105,10 +105,12 @@ if __name__ == '__main__': |
|
|
|
|
|
|
|
# fixed overlap_h |
|
|
|
''' |
|
|
|
|
|
|
|
maxProduct = 0 |
|
|
|
overlaps = 125 |
|
|
|
overlap_w = overlaps |
|
|
|
overlap_h = overlaps |
|
|
|
''' |
|
|
|
product = sum(imgs[0][:,SIZE-overlaps:].astype(np.uint32)*imgs[1][:,:overlaps].astype(np.uint32)) |
|
|
|
product += sum(imgs[2][:,SIZE-overlaps:].astype(np.uint32)*imgs[3][:,:overlaps].astype(np.uint32)) |
|
|
|
product = sum(product) / len(product) |
|
|
@ -120,9 +122,10 @@ if __name__ == '__main__': |
|
|
|
product = sum(product) / len(product) |
|
|
|
maxProduct = product |
|
|
|
maxProduct = (tmp + maxProduct)/2 |
|
|
|
''' |
|
|
|
|
|
|
|
|
|
|
|
if maxProduct > PRODUCTION_THRESHOLD: |
|
|
|
#if maxProduct > PRODUCTION_THRESHOLD: |
|
|
|
if True: |
|
|
|
tmp = np.zeros((SIZE, SIZE*2-overlap_w), dtype=np.uint16) |
|
|
|
tmp[:, :SIZE] = imgs[0] |
|
|
|
tmp[:, -SIZE:] += imgs[1] |
|
|
@ -137,7 +140,10 @@ if __name__ == '__main__': |
|
|
|
merge[:SIZE, :] = tmp |
|
|
|
merge[-SIZE:, :] += tmp2 |
|
|
|
merge[(SIZE-overlap_h):SIZE, :] = merge[(SIZE-overlap_h):SIZE, :]/2 |
|
|
|
|
|
|
|
offset_w = int(overlap_w/2) |
|
|
|
offset_h = int(overlap_h/2) |
|
|
|
out[SIZE*2+offset_h:SIZE*4-overlap_h+offset_h, offset_w: SIZE*2-overlap_w+offset_w] = merge |
|
|
|
''' |
|
|
|
position = [0,0] |
|
|
|
rows,cols = merge.shape |
|
|
|
|
|
|
@ -148,9 +154,6 @@ if __name__ == '__main__': |
|
|
|
position[0] /= sum(sum(merge)) |
|
|
|
position[1] /= sum(sum(merge)) |
|
|
|
|
|
|
|
offset_w = int(overlap_w/2) |
|
|
|
offset_h = int(overlap_h/2) |
|
|
|
out[SIZE*2+offset_h:SIZE*4-overlap_h+offset_h, offset_w: SIZE*2-overlap_w+offset_w] = merge |
|
|
|
pos_w = 1.17*position[0] #distanceBetweenSensors_w/(SIZE-overlap_w)*position[0] |
|
|
|
pos_h = 1.17*position[1] #distanceBetweenSensors_h/(SIZE-overlap_h)*position[1] |
|
|
|
if not hasPos: |
|
|
@ -181,6 +184,7 @@ if __name__ == '__main__': |
|
|
|
path.append(position) |
|
|
|
truePath.append(endPos) |
|
|
|
times.append(frames[0].time) |
|
|
|
''' |
|
|
|
elif hasPos: |
|
|
|
if endTime - startTime > 0: |
|
|
|
print (startPos, endPos) |
|
|
@ -196,6 +200,7 @@ if __name__ == '__main__': |
|
|
|
out = exponential(out, EXPONENTAL_VALUE) |
|
|
|
|
|
|
|
out = cv2.cvtColor(out,cv2.COLOR_GRAY2BGR) |
|
|
|
''' |
|
|
|
if endTime - startTime > MIN_EXIST_TIME: |
|
|
|
speed = ((endPos[0]-startPos[0])**2+(endPos[1]-startPos[1])**2)**0.5/(endTime - startTime) |
|
|
|
cv2.putText(out, f'{speed:.2f}', |
|
|
@ -213,6 +218,7 @@ if __name__ == '__main__': |
|
|
|
hasLastFrame = True |
|
|
|
elif hasLastFrame: |
|
|
|
out[SIZE*2:,:] = lastFrame |
|
|
|
''' |
|
|
|
cv2.imshow('sample', out) |
|
|
|
videoWriter.write(out) |
|
|
|
|
|
|
|