【发布时间】:2018-12-22 18:39:32
【问题描述】:
我想根据密度显示温度。
以下是我使用的功能,
def add_heat(heatmap, bbox_list):
for i in range(len(bbox_list)):
rect = trackers[i].get_position()
heatmap[int(rect.left()):int(rect.top()), int(rect.right()):int(rect.bottom())] += 1
return heatmap
def apply_threshold(heatmap, threshold):
# Zero out pixels below the threshold
heatmap[heatmap <= threshold] = 0
# Return thresholded map
cv2.imwrite("heatmap.png",heatmap)
return heatmap
-
add_heat函数将循环遍历跟踪器,并仅在那些特定区域上调整热图以进行阈值处理 - apply_threshold 如果低于特定阈值,会将所有像素转换为零。
我这样称呼它,
heat = np.zeros_like(frame[:, :, 0]).astype(np.float)
heat = add_heat(heat,trackers)
heat = apply_threshold(heat, 80)
heatmap = np.clip(heat, 0, 255)
trackers 包含所有被跟踪的坐标。但是,当我尝试显示最终结果时,它仍然是黑色的。我可以知道我错过了什么吗?
【问题讨论】:
-
请提供适当的最小、完整和可验证的示例。你在哪里/如何加载图像?什么形象?您要导入哪些模块?
-
您的问题听起来很有趣但不清楚。请按照上面的建议添加更多详细信息。
标签: opencv heatmap detection dlib image-thresholding