To create a Qt project you need to write a .pro file. This is like an advanced Makefile file, were you should specify the source and header files, compilation options, libraries, and other stuff, that you will include or use in your project. With this .pro file you can use the qmake program, which is a tool from the Qt library, to create the specific Makefile for the project, that you can use to finaly compile the program, with the Qt binaries linked correctly, and everything properly configured for your machine.
To make a program based on QVision you should create a Qt project file, that at least references to all the source and header files, and includes the project file for QVision qvproject.pri. That file should be located in the install directory of the QVision, and should be included in the .pro file with this line:
include(<path to QVision>/qvproject.pri)
where <path to QVision> should be the absolute path to QVision install directory. For example:
include(/usr/local/QVision.0.0.2/qvproject.pri)
This line includes in the project all the references to the library binaries, and configurations that require the use of the QVision.
In the next section it is shown an example .pro file for a simple QVision project. For futher info about the qmake tool, and the sintax of .pro files you can check the online manual for QMake.
include(/usr/local/QVision.0.0.2/qvproject.pri) TARGET = example # Input SOURCES += example.cpp
If you don't have QVision installed in that directory just change the path in the first line according to what is explained in section QVision projects.
Next, you can create the file example.cpp:
#include <qvmplayercamera/qvmplayercamera.h> #include <qvcore/qvapplication.h> #include <qvgui/qvisioninterface.h> class PlayerWorker: public QVWorker { public: PlayerWorker(QString name): QVWorker(name) { addProperty< QVImage<uChar,1> >("Input image", inputFlag|outputFlag); addProperty< QVImage<uChar,1> >("Output image", outputFlag); } void iterate() { QVImage<uChar,1> image = getPropertyValue< QVImage<uChar,1> >("Input image"); setPropertyValue< QVImage<uChar,1> >("Output image", image); } }; int main(int argc, char *argv[]) { QVApplication app(argc, argv, "Example program for QVision library. Play a video on a canvas window."); QVMPlayerCamera camera("Video"); PlayerWorker worker("Player worker"); camera.link(&worker,"Input image"); QVisionInterface interface; QVImageCanvas imageCanvas("Test image"); imageCanvas.linkProperty(worker,"Output image"); return app.exec(); }
Note that the file example.cpp is referenced in the file example.pro, at the line:
SOURCES += example.cpp
Also note that as it is explained in the previous section The first program, the project file also includes the project file for QVision projects:
include(/usr/local/QVision.0.0.2/qvproject.pri)
If both files are in the same directory, you can compile from that location writting these instructions in the command line:
# qmake # make
This will generate the binary example. Note that the name of the executable was specified in the example.pro file, in the line:
TARGET = example
You can execute the example program with this command line:
# ./example --URL=http://perception.inf.um.es/public_data/videos/misc/minuto.avi
It is just a simple video player, that will show the video in the file pointed by the URL, in a window, with some control widgets.
Beside that interface, the user can set initial values for some properties, through comman line parameters. You can check the properties of the example program with the command line parameter help. Every QVision application recognices that parameter, and shows a list of the usage and main properties that you can set through the command line. The output of the program example when invoqued with that parameter:
# ./example --help
is:
Usage: ./example [OPTIONS] Example program for QVision library. Play a video on a canvas window.
Input parameters for Video: --Rows=[int] (def. 0) .............................. Rows to open the camera. --Cols=[int] (def. 0) ........................... Columns to open the camera. --RealTime=[true,false](def. false) If the camera should be opened in real time mode. --Deinterlaced=[true,false](def. false) If the camera should be opened in deinterlaced mode. --NoLoop=[true,false](def. false) If the camera should be opened in no loop mode. --RGBMEncoder=[true,false](def. false) If the camera should be opened in RGB using mencoder. --URL=[text] ............................ URL of the video source (see doc.).
Input parameters for Player worker: --print stats=[true,false](def. false) Enables realtime stats console output for worker.
You can change the input video source, changing the value for the URL command line parameter, so the example program reads from a video file different than the file minuto.avi, as well as other video input configuration parameters such as the size of the image (parameters Cols and Rows), amongst others.
QVision's command line parameter system will be explained in the section TheGUI, along the graphical interface, but it is best recommended to read the following section of this documentation, Programming with QVision, to understand how to add and use these parameters.