Common Vision Blox 15.0
Loading...
Searching...
No Matches
Image Manager/Cvb++/QtImageDisplay

This example program is located in your CVB installation under %CVB%Tutorial/Image Manager/Cvb++/QtImageDisplay.

main.cpp:

// The QtImageDisplay example shows an image in a Qt display. With mouse over the pixel data are shown.
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
#include <iostream>
#include <QApplication>
#include <QIcon>
#include <cvb/image.hpp>
#include <cvb/ui/image_view.hpp>
int main(int argc, char *argv[]) {
try {
QApplication app(argc, argv);
view.setWindowIcon(QIcon(":/qttutorial.png"));
view.SetUploadMode(Cvb::UI::UploadMode::Viewport);
view.SetRenderEngine(Cvb::UI::RenderEngine::OpenGL2);
// load the image
Cvb::ImagePtr image =
Cvb::Image::Load(Cvb::InstallPath() + CVB_LIT("tutorial/ClaraRGB.bmp"));
// refresh the image view
view.Refresh(image);
view.show();
// display pixel data
[&](Cvb::Point2D<int> mousePos, const std::vector<double> &pixelVal) {
// show mouse position and pixel data
Cvb::StringStream titleStream;
titleStream << "(X:" << mousePos.X() << ", Y:" << mousePos.Y()
<< ") (R:" << qFloor(pixelVal[0])
<< ", G:" << qFloor(pixelVal[1])
<< ", B:" << qFloor(pixelVal[2]) << ")";
view.setWindowTitle(Cvb::UI::CvbToQt(titleStream.str()));
});
return app.exec();
} catch (const std::exception &error) {
std::cout << error.what() << std::endl;
}
}
static std::unique_ptr< Image > Load(const String &fileName)
T X() const noexcept
T Y() const noexcept
Cvb::EventCookie RegisterEventMouseMoved(std::function< void(Cvb::Point2D< int >, const std::vector< double > &)> handler)
void SetUploadMode(Cvb::UI::UploadMode uploadMode)
void Refresh(Cvb::UI::RefreshMode refreshMode)
void SetRenderEngine(Cvb::UI::RenderEngine renderEngine)
QString CvbToQt(const Cvb::String &text) noexcept
std::shared_ptr< Image > ImagePtr
std::stringstream StringStream
String InstallPath()