Is it possible to retrieve the pixels of an image using the currently available nodes in the nodes library?
Below is a simple motion sensor sketch but I would like to get the average 2D points of pixels that are not black. If I can do this I could then place a marker on the image and track the moving object in Vuo coordinates.
I would like to access the raw pixels so that I can use their coordinates - clearer below.
For example, in the image below I know the coordinates of every white pixel, and through averaging their x and y positions I can calculate the centre of mass (3,3) . I’d like to perform this method on a thresholded video image so that I can place a marker at the centre of mass of the moving object.
I need to learn to create my own nodes, but at this point I was playing around with readily available ones.
Did you have a look at @scratchpole’s motion detection comp in the composition library? It uses a deprecated node to average lists, but you can at least see a method.
There is a feature request for Tracking blobs, or “finding the image’s centroid”, which is what we think you are asking. One of my teammates created a composition that samples many colors from the image inside a Process List loop, then take the average of the sampled point positions weighted by the brightness at each position.
Implementing the feature request should provide better performance and better resolution, and more advanced region detection.
My iMac broke yesterday just as I started on this…
So here’s my own version based on the grid system.
Method:
Creates a 10x10 grid over the video frames. The grid acts like a CCD sensor.
Loop over the grid, sample the colour at each coordinate and width, and colorise the corresponding grid element with an average colour.
If it is greater than black (0) then obtain the grid(s) coordinate and dimensions
Overlay a rectangle with this position and dimension.
Aimed result: a rectangle which adjusts its size and location in relation to the blob in the video…smoothing filter for rectangle motion not implemented here.
Problems:
Seems to be a glitch in the way the grid are colored - some reddening to the top grids
Interference from 1 causes the resulting green rectangle to jump about a bit
My composition is a bit slow so I;ve had to reduce the video rate.