Skip to content

Docs/Example of of logging jpeg data from C++ #6520

@jleibs

Description

@jleibs

This is not very well documented at the moment.

Would be nice to have something similar to:

#include <rerun.hpp>

#include <fstream>
#include <vector>

int main() {
    const auto rec = rerun::RecordingStream("rerun_example_image");
    rec.spawn().exit_on_failure();

    auto path = "test.jpeg";

    std::ifstream source_file{path, std::ios::binary};
    auto length{std::filesystem::file_size(path)};
    std::vector<uint8_t> jpeg_data(length);

    // Parsing the jpeg header is out of scope
    const int HEIGHT = 300;
    const int WIDTH = 300;

    source_file.read(reinterpret_cast<char*>(jpeg_data.data()), static_cast<long>(length));

    rec.log("image", rerun::Image({HEIGHT, WIDTH, 3}, rerun::TensorBuffer::jpeg(jpeg_data)));
}

though including a helper for parsing the header would certainly make it a lot cleaner.

Metadata

Metadata

Assignees

Labels

examplesIssues relating to the Rerun examplesgood first issueGood for newcomerssdk-cppC/C++ API specific📖 documentationImprovements or additions to documentation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions