Skip to content

Code Example: Iterate over Images in a Scene

Simon Fuhrmann edited this page Jul 17, 2015 · 2 revisions

Wiki HomeMVE Developers Guide ▸ Code Example: Iterate over Images in a Scene

#include "mve/scene.h"
#include "mve/view.h"
#include "mve/image.h"

int
main (void)
{
    // Load scene.
    mve::Scene::Ptr scene = mve::Scene::create();
    scene->load_scene("/tmp/myscene/");

    // Iterate over all views.
    mve::Scene::ViewList const& views = scene->get_views();
    for (std::size_t i = 0; i < views.size(); ++i)
    {
        // The list of views can contain "holes".
        if (views[i] == NULL)
            continue;

        // If an image by that name is not available, you get NULL.
        mve::ByteImage::Ptr image = views[i]->get_byte_image("original");
        if (image == NULL)
            continue;

        // Do something with image.
        process_image(image);
    }

    return 0;
}