I get massive problems on Delaying Pixels depending on their speed in Windows openframeworks in this Function. Notice that i’ve Paused the Video before working with it.
for(int y = 0; y < h; y++){
for(int x = 0; x < w; x++){
inputMovie.setPosition((int)PixelIndexer[x][y]);
inputMovie.update();
unsigned char *color = inputMovie.getPixels();
ofColor currPixColor;
currPixColor.r = color[x+y*w];
currPixColor.g = color[x+y*w]+1;
currPixColor.b = color[x+y*w]+2;
saveImage.setColor(x+y*w,currPixColor);
}
}
you are doing some heavy things inside this for loop:
setPosition on a movie is advancing to a certain frame
update is updating the pixels of the movie
I don’t know what w x h is but if it was 200 x 200, you’d be doing this 40,000 times inside the for loop. I think this really, really heavy. inputMovie.update() is doing alot, there’s memory moving around, things getting uploaded to the graphics card, etc. It can’t be run 40,000 times (or similar) in realtime.
If you need to access different frames of video at a per pixel level, maybe you can load the whole movie into memory? It will be slow at first to parse out the video to RAM, but then these calculations will be significantly faster and should work in realtime / without delay.
thanks 4 the fast reply. any code tips and suggestions how to do this, it dont have to run in realtime. so what’s the clean solution to this problem ?
My Idea would be to load the Frames of the movie into a vector and then access this vector.
Is this a better solution ?
the easiest might be to make a vector of ofPixels, or something similar. You can also store the data in one large array ( unsigned char pixels[ w * h * nFrames * 3 ]) or in a 2d or 3d array (pixels[nFrames][w*h], pixels[nFrames][w][h]);