Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get if rendering is complete ? #7

Open
sprokuda opened this issue Feb 9, 2022 · 2 comments
Open

How to get if rendering is complete ? #7

sprokuda opened this issue Feb 9, 2022 · 2 comments

Comments

@sprokuda
Copy link

sprokuda commented Feb 9, 2022

First of all let me thank you for your wonderfull work. I needed some engine to generate 2D shots of 3D scene in offscreen mode. This is being done for pupose to generate some synthetic images for CNN training. Your render passes for this purpose perfect. But there is one question: how to get the rendering is complete before to do a capture ?
For example if to modify code of OffscreenEngineDelegate.cpp for a single image capture with delay like as follows:

OffscreenEngineDelegate::OffscreenEngineDelegate(OffscreenEngine *engine, QLabel *label) :
    engine(engine),
    label(label),
    reply(nullptr)
{
    auto captureDelay = 20;
    QTimer::singleShot(captureDelay, this,[this](){requestRenderCapture();});
}

OffscreenEngineDelegate::~OffscreenEngineDelegate()
{
    delete reply;
}

void OffscreenEngineDelegate::requestRenderCapture()
{
    delete reply;
    reply = engine->getRenderCapture()->requestCapture();
    connect(reply, SIGNAL(completed()), this, SLOT(onImageRendered()));
}

void OffscreenEngineDelegate::onImageRendered()
{
    label->setPixmap(QPixmap::fromImage(reply->image()));
}

the program will capture what is on screen in 20 msec (auto captureDelay = 20;). And on my PC 20 msec is enough to get the image, if this value is less than 20 msec I get image with background only. With more slower hardware such delay has to be bigger as I checked.
This situation rises a question when one may do the capture ? or, in other words, how to get if the rendering is completed ?

@florianblume
Copy link
Owner

Hey @sprokuda, thanks for your issue. Unfortunately, Qt3D doesn't offer this functionality :/ It's what's been bugging me for quite some time, too. Qt3D handles taking screen shots internally and claims in the docs that the render capture node will be executed where it is located (e.g. when you put in a framegraph branch before a branch drawing objects it's supposed to capture the rendering before the objects are drawn). But unfortunately, this is not the case and I've made the same experience as you: You sometimes need two to three capture requests until the full image is rendered. The only thing I can think of is to add a delay that is long enough (maybe like 0.5 sec) since usually time is not of the essence when taking screenshots and everyone can live with 0.5s delay.

Anyways, nice to hear that you are doing machine learning :) Have you checked out my tool called 6D-PAT? It's for annotating 3D models with 3D translation + rotation on 2D images. I thought I'd mention this, maybe it comes in handy at some point.

@sprokuda
Copy link
Author

Der Herr, Vielen Dank, and I'll check 6D-PAT out, it is a very interesting tool...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants