Code: Select all
video::IImage* image = driver->createScreenShot();
// next three lines are looped with i and j
captured_image[i][j][0] image->getPixel(i, j).getRed();
captured_image[i][j][1] image->getPixel(i, j).getGreen();
captured_image[i][j][2] image->getPixel(i, j).getBlue();
image->drop();
// do some stuff on captured_image
I have few ideas on how this might be done in an optimal way. The obvious way is to find out how to get the full pixel data from IImage directly instead of getting each color of each pixel individually, I'm not good at c++ but I sense calling getPixel() for each pixel is suboptimal. Any ideas how to do that? The other thought I have is, maybe Irrlicht has it's own function of applying filters (it should not be just standard filters like blur, I should be able to give it any kernel), but then I will still need to return the resulting image that will be indexable the same way captured_image is.
For anyone who's wondering what I'm doing, I want to feed the captured image into convolutional neural network of virtual creature A.I. and train/evolve it.