I am busy integrate vuforia with urho3d (only for android by now)
This is so hard for me as a new bee. But I desired to see them working together.
I try to draw vuforia’s camera background in urho3d’s update event listener.
As below:
void Player::Start() {
...
SubscribeToEvent(E_UPDATE, HANDLER(Player, HandleUpdate));
...
}
void Player::HandleUpdate(StringHash eventType, VariantMap& eventData) {
QCAR::State state = QCAR::Renderer::getInstance().begin();
//**
QCAR::CameraDevice& cameraDevice = QCAR::CameraDevice::getInstance();
QCAR::VideoMode videoMode = cameraDevice. getVideoMode(QCAR::CameraDevice::MODE_DEFAULT);
//** Configure the video background
QCAR::VideoBackgroundConfig config;
config.mEnabled = true;
config.mSynchronous = true;
config.mPosition.data[0] = 0.0f;
config.mPosition.data[1] = 0.0f;
config.mSize.data[0] = 720;
config.mSize.data[1] =1280;
QCAR::Renderer::getInstance().setVideoBackgroundConfig(config);
//** dont work, black window, dont't know why
// QCAR::Renderer::getInstance().drawVideoBackground();
//** get frame image
QCAR::State state = QCAR::Renderer::getInstance().begin();
///QCAR::setFrameFormat( QCAR::RGB565, true );
QCAR::setFrameFormat( QCAR::RGB888, true );
QCAR::Frame qcarframe = state.getFrame();
const QCAR::Image *imageRGB888 = NULL;
for(int i=0; i<qcarframe.getNumImages();i++) {
const QCAR::Image *pimg = qcarframe.getImage(i);
if (pimg->getFormat() == QCAR::RGB888) {
imageRGB888 = pimg;
break;
}
}
//** found image, this works!!
if (imageRGB888 != NULL) {
__android_log_print(ANDROID_LOG_INFO, "Player", "found imageRGB888");
const short* pixels = (const short*) imageRGB888->getPixels();
int width = imageRGB888->getWidth();
int height = imageRGB888->getHeight();
int numPixels = width * height;
//*** todo: draw image
__android_log_print(ANDROID_LOG_INFO, "Player","888image size: %d %d", width, height);
}
QCAR::Renderer::getInstance().end();
}
Some explain:
“drawVideoBackground” never working as offical demo, I saw only a black window.
google again and again, I found the camera frame image can be fetched.
So, my current question is:
how to display the buffered image as urho3d’s background? (I wish that no need to modify urho3d’s source code)
By the way, I’d like to see urho3d engine integerate vuforia in future