movie2serial: copying a portion of the frame before passing to image2data

Status
Not open for further replies.

BuffaloFan32

Well-known member
I modified movie2serial so that it displays an image and then scrolls Google News' RSS feed on top of it. Due to the irregular shape of my LED layout, I have also created a seperate file with a list of the pixels[] I want to get from each frame. I was thinking that I could just tell image2data to get those pixels and output them to my array each time a screenshot is passed to it but I keep getting an 'out of bounds' error. I think this is because the screen shot is being chopped into smaller pieces before being passed. Is this a necessary step? Right now, I only have one Teensy connected to the computer so I assumed there would be no chopping.

I will be adding more Teensy's to the arrangement so I think I need to get this figured out before hand.
 
This is how I changed movie2serial to handle the coordinates. strLines is a list of all the pixels I want to take from the image. I am now passing the whole image to image2data. Now the whole program runs realllllly slow.

void image2data(PImage image, byte[] data) {
//println(numPorts);
int offset = 3;
int mask;
int pixel[] = new int[strLines.length];

for (int i=0; i < strLines.length; i++) {
// fetch 8 pixels from the image, 1 for each pin
pixel = image.pixels[int(strLines)];
pixel = colorWiring(pixel);
println(pixel);
}
// convert 8 pixels to 24 bytes this is it
for (mask = 0x800000; mask != 0; mask >>= 1) {
byte b = 0;
for (int i=0; i < 8; i++) {
if ((pixel & mask) != 0) b |= (1 << i);
}
data[offset++] = b;
//println(b);
}
}

I do not understand why changing the program to process the whole image on every call to image2data would make it run so much more slowly than processing many pieces of the image. I think my problem is coming in after the function tries to convert the colors to bytes as I am not very familiar with that type of code. If there are some sites you can recommend on reading about that, I would appreciate that too.
 
Status
Not open for further replies.
Back
Top