PARP Research Group University of Murcia


Hello world

As any other Qt-based application, QVision applications are created inside a Qt project. Qt project files specify the source files and compilation parameters necessary to create any Qt application.

The following is the content of an example Qt project file to create a QVision application from a single C++ source file named example.cpp:

include(/usr/local/QVision/qvproject.pri)
TARGET = example
SOURCES = example.cpp

The file qvproject.pri is itself a Qt project file. It contains the necessary configuration parameters to include QVision classes and functions in the application. Any QVision application's .pro file must include the qvproject.pri file from the QVision install path.

The line TARGET = example assigns the name of the application's executable to example. TARGET is a reserved variable name inside the Qt project files, and the assignation sets the name of the executable, where the compiler will store the application binary code.

The variable SOURCES must contain a space separated list of the source files of the application. In our example, the project will have only one source file, named example.cpp.

We can store the previous project file with the name example.pro, and create the source file example.cpp which will contain the source code of our hello-world application.

Source code for our Hello-world example

We can insert the following code in the example.cpp file formerly described:

#include <iostream>
#include <qvio.h>
#include <qvipp.h>
int main(int argc, char *argv[])
        {
        // Check if the user provided enough command line parameters.
        if (argc < 3)
                {
                std::cout << "Usage: " << argv[0] << " <input image> <output image>" << std::endl;
                return -1;
                }

        // Input and output images
        QVImage<uChar, 3> inputImage, outputImage;

        // Read the input image
        readQVImageFromFile(argv[1], inputImage);

        // Apply Hipass filter
        FilterHipass(inputImage, outputImage);

        // Write output image
        writeQVImageToFile(argv[2], outputImage);
        }

This code reads an input image from an image file specified in the first console command line parameter, and applies a High pass filter which outlines the borders appearing in the image. The resulting image will be stored by the application in the file specified by the second console command line parameter.

Compiling and executing the program

Once the files example.cpp and example.pro are created in the same directory, you can compile the application using the qmake and the make tools:

        # qmake
        # make

This should create the binary executable example. You can execute the application using a command line like the following:

        # ./example lena.png lena-hipass.png

Assuming that an image file named lena.png exists, and contains the following image:

lena.png

The application creates a new image named lena-hipass.png as indicated by the second command line parameter, storing the following image:

lena-hipass.png



QVision framework. PARP research group, copyright 2007, 2008.