I am using OpenCV to capture a video and convert it to an irrlicht texture to be able to display it. The nightsoft guys have a pretty code that shows how to do it. But it gets awefull slow for me with a resolution higher than 352x288, so thats nothing!
code is:
Code: Select all
void CameraInput::repaint( IplImage* frame )
{
// read the pixels directly into the texture
char* texture = (char*)( irr_texture->lock() );
char* ardata = (char*) frame->imageData;
char* final_loc = frame->imageSize + frame->imageData;
switch( irr_texture->getColorFormat() )
{
case ECF_R8G8B8:
while( ardata < final_loc )
{
*texture = *ardata;
texture++; ardata++;
*texture = *ardata;
texture++; ardata++;
*texture = *ardata;
texture++; ardata++;
}
break;
case ECF_A8R8G8B8:
while( ardata < final_loc )
{
// R
*texture = *ardata;
texture++; ardata++;
// G
*texture = *ardata;
texture++; ardata++;
// B
*texture = *ardata;
texture++; ardata++;
// A: skip
texture++;
//cout<<"rgba"<<endl;
}
break;
}
irr_texture->unlock();
}
Thanks