Hello everyone, just like the title says Im trying to find what is the fastest way of getting access to a FBO’s pixels or a part of the screen, the reason I want to do so is because Im trying to optimise a part of a finger/blob tracking application for optical multitouch that I’m developing, the key features of the app are that its very fast (or at least thats what I’m aiming for) and that you’ll be able to place your webcam facing the screen or table at an angle. Now, in order for it to be able to work properly it must correct the input image’s perspective, this is where the bottleneck of the app is, once the perspective has been adjusted I now need to run the blob finding algorithm on this new perspective corrected image, so far I’ve tried 2 things: draw this image to the screen and then use a texture to grab the part of the screen where the image was drawn, I’m doing this with:
// ofPixels pix and unsigned char *pixels_pointer were previously defined // at this point in the program, the original image has been drawn on the left and the new image on the right textura.loadScreenData(video_width,0,video_width,video_height); textura.readToPixels(pix); pixels_pointer = pix.getPixels();
Just this 3 lines take about 12-15 milliseconds on average to complete while the rest of the program (both what is behind and after these lines) takes 1 millisecond on average (on a 320x240 pixels input image). The other thing I’ve tried is instead of drawing the new image on screen draw it to a FBO then access the FBO pixeles with:
fbo.readToPixels(pix); pixels_pointer = pix.getPixels();
and once again, just those 2 lines take about the same time as when using a texture. My question is why is it so slow? I read somewhere in the forum that this happens when copying between GPU memory and system memory, but my computer has an integrated gpu which means there’s no dedicated video memory(well, there is, but its shared with normal memory), so it shouldn’t be that slow right? Is there any other way of doing this thats faster? I remember there was a ofxFBO addon that had a getPixels() function, did anyone ever get to try it? was it fast? I’ve ran out of options people, thats why Im asking so please openframeworks community help!