Skip to content

How to process a QImage...

Dr. Daniel L. Lau edited this page May 21, 2018 · 2 revisions

So now you just want to process a QImage, maybe one you've read from disk. Use this code:

LAUCalTagDialog w((QImage()));
return w.exec();

You can simply replace the empty QImage() with your own QImage(), but if you don't then the following code will be executed inside the constructor of the LAUCalTagDialog:

    if (image.isNull()){
        QSettings settings;
        QString directory = settings.value("LAUCalTagDialog::lastUsedDirectory", QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)).toString();
        QString filename = QFileDialog::getOpenFileName(0, QString("Load image from disk"), directory, QString("*.tif *.tiff *.bmp *.jpg *.jpeg"));
        if (filename.isEmpty() == false) {
            settings.setValue("LAUCalTagDialog::lastUsedDirectory", QFileInfo(filename).absolutePath());
        } else {
            return;
        }
        image = QImage(filename);
    }

This code will load an image from disk and use it in place of the empty QImage. Now if you're happy with the result, just click the OK button to run the following accept() method:

    LAUMemoryObject object = widget->grabImage();
    if (object.save(QString())){
        QDialog::accept();
    }

This code saves the results to a tiff image using XYg format where g is the binarized image and X and Y are the XY coordinates of the caltag pattern.

Clone this wiki locally