HELP!!!!

edited August 2015 in How To...

Guys I have a video of a street where the people is walking, etc. I want to graph the movement patterns of the people, not only one person but many of them walking on the street. Then I want to create a heatmap from that information showing the areas with more people walking by. Is it possible to do using Processing?

Answers

  • Assuming the camera's position is fixed, I'd skip the graph (unless you really need it) and go right for the heat map. Then you can just use frame differencing. Here's the example that comes with Processing:

    /**
     * Frame Differencing 
     * by Golan Levin. 
     *
     * Quantify the amount of movement in the video frame using frame-differencing.
     */ 
    
    
    import processing.video.*;
    
    int numPixels;
    int[] previousFrame;
    Capture video;
    
    void setup() {
      size(640, 480);
    
      // This the default video input, see the GettingStartedCapture 
      // example if it creates an error
      video = new Capture(this, width, height);
    
      // Start capturing the images from the camera
      video.start(); 
    
      numPixels = video.width * video.height;
      // Create an array to store the previously captured frame
      previousFrame = new int[numPixels];
      loadPixels();
    }
    
    void draw() {
      if (video.available()) {
        // When using video to manipulate the screen, use video.available() and
        // video.read() inside the draw() method so that it's safe to draw to the screen
        video.read(); // Read the new frame from the camera
        video.loadPixels(); // Make its pixels[] array available
    
        int movementSum = 0; // Amount of movement in the frame
        for (int i = 0; i < numPixels; i++) { // For each pixel in the video frame...
          color currColor = video.pixels[i];
          color prevColor = previousFrame[i];
          // Extract the red, green, and blue components from current pixel
          int currR = (currColor >> 16) & 0xFF; // Like red(), but faster
          int currG = (currColor >> 8) & 0xFF;
          int currB = currColor & 0xFF;
          // Extract red, green, and blue components from previous pixel
          int prevR = (prevColor >> 16) & 0xFF;
          int prevG = (prevColor >> 8) & 0xFF;
          int prevB = prevColor & 0xFF;
          // Compute the difference of the red, green, and blue values
          int diffR = abs(currR - prevR);
          int diffG = abs(currG - prevG);
          int diffB = abs(currB - prevB);
          // Add these differences to the running tally
          movementSum += diffR + diffG + diffB;
          // Render the difference image to the screen
          pixels[i] = color(diffR, diffG, diffB);
          // The following line is much faster, but more confusing to read
          //pixels[i] = 0xff000000 | (diffR << 16) | (diffG << 8) | diffB;
          // Save the current color into the 'previous' buffer
          previousFrame[i] = currColor;
        }
        // To prevent flicker from frames that are all black (no movement),
        // only update the screen if the image has changed.
        if (movementSum > 0) {
          updatePixels();
          println(movementSum); // Print the total amount of movement to the console
        }
      }
    }
    

    Just have detected differences increase the heat of any given pixel.

  • Actually What I need the most are the graph. Show the displacement of an object between point A to point B

  • Please give this thread a better name

  • did you look at OpenCV and so on

    it's a lib

  • edited August 2015

    As said by koogs, you should edit and change the subject: you wrote in all caps, which is seen as shouting, enforced by the multiple exclamation points. And the title is totally useless: nearly everybody ask for help.
    Try to make a more descriptive subject, summarizing your message.

    Also moved the topic.

Sign In or Register to comment.