3

I am trying to implement this:

YouTube link- https://www.youtube.com/watch?v=Qk4V_x6B7jY&t=5s

Blog link- http://www.businessinsider.in/These-Heat-Maps-Show-How-Retailers-Track-You-As-You-Shop/articleshow/29512380.cms

I want to use python and openCV but I am a beginner in openCV and hence, I have no idea How to implement this.

I have some basic idea. I have been able to track motion and draw a rectangle around the moving object and i am saving the co-ordinates of the rectangle in an external csv file. But, i am stuck on plotting heat map part. How to make it so that, over time when people are moving more and more in an area, the color changes from blue(normal movement ) to red (high movement) ? Please help..

sks
  • 197
  • 1
  • 3
  • 14

1 Answers1

12

So the basic idea for plotting a heat map is to visually get some feedback for the probability of a given particular event, You may write your own method which may take probability in range 0-1 and output a color in range (255, 0, 0) - (0, 0, 255). Or Opencv has provision of color-maps. You may be interested in using the COLORMAP_JET:

enter image description here

And Now you have to normalize the probability in range 0-255 instead of 0-1 and the you may use cv2.applyColorMap(input_prob, cv2.COLORMAP_JET) to get the desired output.

ZdaR
  • 22,343
  • 7
  • 66
  • 87
  • I want to be able to update the values. Coz, lets say initially when the movement is minimal color is blue but then when movement increases color should update to red. Now, if i am returning probability after an event then how do i update the values? Can you please explain it in detail? It would be a big help – sks Nov 05 '16 at 10:25
  • So, i think that wont work and cv2.applyColorMap() takes first argument as image file so i think what you have written is wrong.. – sks Nov 05 '16 at 11:46
  • @ZdaR can the input_prob be represented as 3d (3 channels ) array of values between 0 - 1 ? If so it outputs only black image for me , using cv2.imshow() – Darlyn Apr 30 '18 at 16:26
  • You may convert your 3-channel image to a gray-scale image, and then apply this method after normalizing the values in range 0-255 – ZdaR Apr 30 '18 at 18:00