This example requires Qt5 >= 5.9 setup for building.
This example requires Qt5 >= 5.9 setup for building.
You may build it with Ubuntu 18.04's default Qt5 after installing:
- qt5-default
- qtdeclarative5-dev
- qml-module-qtquick2
15 #include <QApplication> 17 #include <QQmlContext> 23 #include <cvb/ui/image_view_item.hpp> 24 #include <cvb/foundation/blob.hpp> 25 #include <cvb/image.hpp> 27 #include "blob_result_model.hpp" 29 int main(
int argc,
char* argv[])
36 Cvb::String path(Cvb::InstallPath() + CVB_LIT(
"tutorial/Foundation/Images/Blob/Microswitch.bmp"));
38 path = Cvb::ExpandPath(path);
43 auto blobResults = Cvb::Foundation::BinarizeAndSearchBlobs(image->Plane(0),
Cvb::ValueRange<int>(0, 62), filter);
45 BlobResultModel blobResultModel(blobResults);
60 context->setContextProperty(
"blobResultModel", &blobResultModel);
67 imageController.
Refresh(std::move(image));
Class to build a filter for the blob search.
Definition: blob.hpp:386
void setSource(const QUrl &url)
static std::unique_ptr< Image > Load(const String &fileName)
Loads an image with the given file name.
Definition: detail_image.hpp:32
void setResizeMode(QQuickView::ResizeMode)
static void Register()
Convenience method to register this type in QML.
Definition: image_view_item.hpp:92
QQmlContext * rootContext() const const
static void Register()
Convenience method to register this type in QML.
Definition: image_view_item.hpp:669
Controller object for the QML image view item.
Definition: image_view_item.hpp:252
void setContextProperty(const QString &name, QObject *value)
void Refresh(const ImagePtr &image, AutoRefresh autoRefresh=AutoRefresh::Off)
Share the image and refresh the view.
Definition: image_view_item.hpp:295
void resize(const QSize &newSize)
QUrl fromLocalFile(const QString &localFile)
void setIcon(const QIcon &icon)
UI definition using QML:
2 import CvbQuick 1.0 as CvbQuick
16 model : blobResultModel
20 imageX : boundingBox.x
21 imageY : boundingBox.y
22 boxWidth : boundingBox.width
23 boxHeight : boundingBox.height
29 model : blobResultModel