We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpVideo Capture,  Movie Playback,  Vision Libraries › setpixel, or someone who knows video tracking
Page Index Toggle Pages: 1
setpixel, or someone who knows video tracking (Read 1933 times)
setpixel, or someone who knows video tracking
Oct 17th, 2005, 9:23am
 
Hello

I'm trying to get in touch with Charles Forman, or one of the other fellows on Setpixel.com that has done some video tracking / manipulation with particles.

I would greatly appreciate any help or leads.
Thanks Smiley
Re: setpixel, or someone who knows video tracking
Reply #1 - Oct 17th, 2005, 11:04am
 
If you would describe a bit more precisly what you are up to, eventually folks can supply with relevant information, Quite some topics areound that theme have been discussed here.
Re: setpixel, or someone who knows video tracking
Reply #2 - Oct 17th, 2005, 9:09pm
 
Well I'm looking to use an iSight to track motion or outline a person standing in front of it. Then I would like to translate that motion or silhouette into a particle generator, and lastly connect up some serial stuff to control the particles.

I'm cool with serial, and pretty good with particles, but a little iffy on the tracking. I'm guessing it's just comparing an array of pixels to the last one and calculating the change, but I would love to see exactly what's going on.

Re: setpixel, or someone who knows video tracking
Reply #3 - Oct 17th, 2005, 11:29pm
 
2 threads just a few below this one Smiley

http://processing.org/discourse/yabb_beta/YaBB.cgi?board=VideoCamera;action=display;num=1125236456


http://processing.org/discourse/yabb_beta/YaBB.cgi?board=VideoCamera;action=display;num=1126986257

If you want to do some more sophisticated motiontracking and save some performance on processing check out EyesWeb, also discussed here quite a bit
Re: setpixel, or someone who knows video tracking
Reply #4 - Oct 20th, 2005, 6:22pm
 
Heres some code I wrote that compares a video capture frame to the previous and calculates the difference maybe this can help you


import processing.opengl.*;

import processing.video.*;
Capture myCapture;

PImage img;
PImage lastcap;




void setup() {
 size(600, 600,P3D);
// println(1/4);
  println(Capture.list());
 String s = "Logitech QuickCam Pro 4000-WDM";
 myCapture = new Capture(this, s, 200, 200, 30);
 //template is a 200x200 black image;
 img=loadImage("template2.jpg");
 img.format=ARGB;
 lastcap=loadImage("template2.jpg");


}




void draw() {
background(0);
lastcap.copy(myCapture, 0, 0, myCapture.width, myCapture.height, 0, 0, myCapture.width, myCapture.height);

 if(myCapture.available()) {
   // Reads the new frame
   myCapture.read();
 }

findchange();
   


   image(img, 0, 0, width, height);

}



void findchange(){
img.loadPixels();
for (int i=0; i<myCapture.pixels.length; i++){
//int colordiff=abs(int(brightness(lastcap.pixels[i]))-int(brightness(myCapture.pixels[i])));

int bluediff=abs((lastcap.pixels[i]&0xFF)-(myCapture.pixels[i]&0xFF));
int greendiff=abs(((lastcap.pixels[i]>>8)&0xFF)-((myCapture.pixels[i]>>8)&0xFF));
int reddiff=abs(((lastcap.pixels[i]>>16)&0xFF)-((myCapture.pixels[i]>>16)&0xFF));

//if (colordiff > 0){
img.pixels[i]=(220<<24)+(reddiff<<16)+(greendiff<<8)+bluediff;
//}
}
img.updatePixels();
}

Re: setpixel, or someone who knows video tracking
Reply #5 - Oct 20th, 2005, 10:02pm
 
A Quicker method of measuring difference

Quasimondo wrote on May 31st, 2005, 10:13am:
As the size of the camera image is usually the same size as the canvas, there is a lot of optimizations you can apply - get rid of all those multiplications in the first place.

The second, much bigger optimization is to use bitwise XOR (^) instead of abs(a-b) - it also makes the extraction of the rgb values obsolete:

Code:

function dif(int[] img){
for (int i=pixels.length;--i>-1;pixels[i]^=img[i]){}
}

function imgDif(int[] img1,int[] img2){
for (int i=pixels.length;--i>-1;pixels[i]=img1[i]^img2[i]){}
}


Re: setpixel, or someone who knows video tracking
Reply #6 - Oct 21st, 2005, 5:37am
 
Thanks st33d
This looks interesting although I think it produces a differnt effect than the code I posted. I didnt know what XOR was and looked it up, from what I could understand it dosn't calculate difference. I took the code you posted and had to mess with it a little so the alpha channel wouldnt get messed up. I wonder is there a way to use bitwise operators to get difference, am I misunderstanding the XOR?


void imgDif(){
img.loadPixels();
  for (int i=0; i<img.pixels.length;i++){
  img.pixels[i]=(255<<24)+((myCapture.pixels[i]&0xFFFFFF)^(lastcap.pixels[i]&0xFFFFFF));
 
  }
img.updatePixels();
}

Re: setpixel, or someone who knows video tracking
Reply #7 - Oct 22nd, 2005, 6:13am
 
Dylan, why are you importing the OpenGL library?
Any specific reason?

ALthough St33d posted it I think that code is from Quasimondo.

If you're reading this Quasi, could you elaborate on those fucntions?

Re: setpixel, or someone who knows video tracking
Reply #8 - Oct 22nd, 2005, 5:54pm
 
Im using OpenGL because of the performance boost, especially when using larger display windows. I als0 like the way it scales up images. Since analyzing 600*600 pixels is way to much for my computer, I can bring in a 200*200 image from the cam and it won't look pixelated when I diplay it at 600*600.

Re: setpixel, or someone who knows video tracking
Reply #9 - Oct 23rd, 2005, 7:58am
 
Ok cool.
THanks I'm going to try and get something going Smiley
Re: setpixel, or someone who knows video tracking
Reply #10 - Oct 27th, 2005, 3:20am
 
Dylan or anyone, can you explain this function a bit more?

Code:

void findchange(){
img.loadPixels();
for (int i=0; i<myCapture.pixels.length; i++){
//int colordiff=abs(int(brightness(lastcap.pixels[i]))-int(brightness(myCapture.pixels[i])));

int bluediff=abs((lastcap.pixels[i]&0xFF)-(myCapture.pixels[i]&0xFF));
int greendiff=abs(((lastcap.pixels[i]>>8)&0xFF)-((myCapture.pixels[i]>>8)&0xFF));
int reddiff=abs(((lastcap.pixels[i]>>16)&0xFF)-((myCapture.pixels[i]>>16)&0xFF));

//if (colordiff > 0){
img.pixels[i]=(220<<24)+(reddiff<<16)+(greendiff<<8)+bluediff;
//}
}
img.updatePixels();
}


Basically this is creating that halo around the moving images if I gather correctly. What does << do? and &0xFF is Hex colors? or what?

Re: setpixel, or someone who knows video tracking
Reply #11 - Oct 31st, 2005, 6:46pm
 
Hey Pillowhead

you can lots of information on what those symbols If you look up "bitwise operations" in google.

peace
Re: setpixel, or someone who knows video tracking
Reply #12 - Dec 9th, 2005, 2:58pm
 
related to this topic(track pixel change), i'm trying to create an image that captures a complete movement.(much like http://www.phantasian.com/timescape/timescape.htm )

however what i need is the image to record the scene once and then after that only the changing pixels, leaving a residue of the movement.

i'm a complete novice at processing and don't even know where to start...this is in aide of a pre-study for a spatial project.

any help is much appreciated...

thanks
riaan
Page Index Toggle Pages: 1