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 & HelpPrograms › GRAB -> RGBA intel mac webcam fix
Page Index Toggle Pages: 1
GRAB -> RGBA intel mac webcam fix (Read 505 times)
GRAB -> RGBA intel mac webcam fix
Apr 25th, 2006, 11:11pm
 
After a little experimentation, it seems this code will accomodate for the color shift present in the new intel macs specifically related to webcam input.

Code:

for (int i=0; i<capture.pixels.length; i++){
       rr = green(capture.pixels[i]);
       gg = red(capture.pixels[i]);
       bb = alpha(capture.pixels[i]);
       aa = blue(capture.pixels[i]);
       capture.pixels[i] = color(rr, gg, bb, aa);
}


So, two questions.
1) is there some bitshifting trickery that will make this happen faster?
2) why the hell is it GRAB -> RGBA?  I thought it was a simple switch of the Alpha from the end to the beginning, but apparently not!

UPDATE-------------------------------------------------
I think i jumped the gun.  The 'B' on the end of GRAB wasnt necessary.  All I needed to do was GRA -> RGB.  I forgot there isn't actually any alpha data coming in from the webcam.  So it probably should have been this instead.

Code:

for (int i=0; i<capture.pixels.length; i++){
       //aa = blue(capture.pixels[i]);
       rr = green(capture.pixels[i]);
       gg = red(capture.pixels[i]);
       bb = alpha(capture.pixels[i]);
       capture.pixels[i] = color(rr, gg, bb);
}
Re: GRAB -> RGBA intel mac webcam fix
Reply #1 - Apr 26th, 2006, 3:25am
 
so the speedy version, if i'm not too sleepy, is:

Code:

for (int i=0; i<capture.pixels.length; i++) {
int p = capture.pixels[i];
capture.pixels[i] = 0xFF000000 | // this may not be necessary
((p << 8) & 0xFF0000) |
((p >> 8) & 0xFF00) |
((p >> 24) & 0xFF);
}
Re: GRAB -> RGBA intel mac webcam fix
Reply #2 - Apr 27th, 2006, 3:21am
 
fwiw, this has just been confirmed as a bug on the qtjava mailing list, so hopefully we'll see a fix in the next rev of quicktime. i'm hesitant to do a hack to work around it in the p5 code since it should get fixed sometime, though maybe we could add a hint() that would temporarily fix things in case it takes apple forever to get it straightened out.
Page Index Toggle Pages: 1