how do i generate a heat map of a detected object based on its position using opencv python

旧城冷巷雨未停 提交于 2019-12-06 13:40:05

Well what you can do here is

1) First define a heatmap as the size of the image

  heatmap = np.zeros_like(img[:,:,0]).astype(np.float)

2) Since you already have the detected object and its position, in the heatmap, add 1 to all pixels in the bounding box of the object.

heatmap[box[0][1]:box[1][1], box[0][0]:box[1][0]] += 1

3) you can than apply thresholding by setting all pixels which are below a threshold value in the heatmap to be 0. You can choose the threshold value to be 1 so that the region inside your bounding box remains in the heatmap

heatmap[heatmap <= threshold] = 0
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!