Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Computer Vision with OpenCV 3 and Qt5

You're reading from   Computer Vision with OpenCV 3 and Qt5 Build visually appealing, multithreaded, cross-platform computer vision applications

Arrow left icon
Product type Paperback
Published in Jan 2018
Publisher Packt
ISBN-13 9781788472395
Length 486 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Amin Ahmadi Tazehkandi Amin Ahmadi Tazehkandi
Author Profile Icon Amin Ahmadi Tazehkandi
Amin Ahmadi Tazehkandi
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. Introduction to OpenCV and Qt 2. Creating Our First Qt and OpenCV Project FREE CHAPTER 3. Creating a Comprehensive Qt+OpenCV Project 4. Mat and QImage 5. The Graphics View Framework 6. Image Processing in OpenCV 7. Features and Descriptors 8. Multithreading 9. Video Analysis 10. Debugging and Testing 11. Linking and Deployment 12. Qt Quick Applications 13. Other Books You May Enjoy

Introduction to Qt

You have heard about it or maybe even used it without knowing it. It's the foundation of many world famous commercial and open source applications, such as VLC Player, Calibre, and so many more. The Qt Framework is used by a majority of the so-called Fortune 500 companies, and we can't even begin to define how widely used and popular it is among the many application development teams and companies in the world. So, we'll start with an introduction and take it from there.

Let's first go through a brief introduction to the Qt Framework to get us on our feet. Nothing can make you feel more comfortable with a framework than having a clear picture of the whole thing in your mind. So, here we go, currently built and managed by The Qt Company, Qt Framework is an open source application development framework that is widely used to create visually rich and cross-platform applications that can be run on different operating systems or devices with very little or no effort at all. To break it down further, open source is the most obvious part of it. It means you can access all of the source code for Qt. By visually rich, we mean enough resources and capabilities are present in Qt Framework to write very beautiful applications. As for the last part, cross-platform, this basically means that, if you develop an application using Qt Framework modules and classes for Microsoft Windows operating system, for instance, then it can be compiled and built for macOS or Linux exactly as it is, without changing a single line of code (almost), provided that you don't use any non-Qt or platform-specific libraries in your application.

At the time of writing this book, Qt framework (or simply Qt from here on) is at version 5.9.X and it contains many modules for almost any purpose in developing applications. Qt divides those modules into these four main categories:

  • Qt Essentials
  • Qt Add-Ons
  • Value-Add Modules
  • Technology Preview Modules

Let's see what they are and what they include since we'll be dealing with them a lot throughout this book.

Qt Essentials

These are the modules promised by Qt to be available on all supported platforms. They are basically the foundation of Qt and they contain the majority of the classes that are used by almost all Qt applications. Qt Essential modules include all of the general-purpose modules and classes. Pay real attention to the words general-purpose, since it's exactly what these modules are used for. The following is a brief list for a quick study of the existing modules and for later reference purposes:

Module

Description

Qt Core

These are core non-graphical classes used by other modules.

Qt GUI

These are base classes for graphical user interface (GUI) components. These include OpenGL.

Qt Multimedia

These are classes for audio, video, radio, and camera functionality.

Qt Multimedia Widgets

These are widget-based classes to implement multimedia functionality.

Qt Network

These are classes to make network programming easier and more portable.

Qt QML

These are classes for QML and JavaScript languages.

Qt Quick

This is a declarative framework to build highly dynamic applications with custom user interfaces.

Qt Quick Controls

These are reusable Qt Quick based UI controls to create classic desktop-style user interfaces.

Qt Quick Dialogs

These are types to create and interact with system dialogs from a Qt Quick application.

Qt Quick Layouts

These layouts are items that are used to arrange Qt Quick 2 based items in the user interface.

Qt SQL

These are classes for database integration using SQL.

Qt Test

These are classes for unit testing Qt applications and libraries.

Qt Widgets

These are classes to extend Qt GUI with C++ widgets.

 

For more information, refer to http://doc.qt.io/qt-5/qtmodules.html.

Note that it's not possible and perhaps not a good idea to cover all modules and all classes in this book, and, for the most part we will stick to whatever module and class we require; however, by the end of the book you'll feel comfortable enough exploring all the numerous and powerful modules and classes within Qt by yourself. You'll learn how to include a module and class in your projects in the upcoming chapters, so for now, let's not bother with too much detail and just focus on having a picture of what Qt really is and what it contains in our minds.

Qt Add-Ons

These modules may or may not be available on all platforms. This means they are used for developing specific capabilities as opposed to the general-purpose nature of Qt Essentials. A few examples of these type of modules are Qt 3D, Qt Print Support, Qt WebEngine, Qt Bluetooth, and many more. You can always refer to the Qt documentation for a complete list of these modules, and in fact, they are too many to be just listed here. For the most part, you can get a brief idea of what a module is used for by just looking.

For more information on this you can refer to http://doc.qt.io/qt-5/qtmodules.html.

Value-Add Modules

These modules offer additional capabilities and are offered with a commercial license from Qt. Yes, you guessed it right, these are the modules that are only available in a paid version of Qt and are not offered in the open source and free version of the Qt, but they're mostly aimed to help with very specific tasks that we don't need at all for the purpose of this book. You can get a list using the Qt documentation pages.

For more information on this you can refer to http://doc.qt.io/qt-5/qtmodules.html.

Technology Preview Modules

Exactly as their name implies, these modules are the ones that are usually offered in a state that is not guaranteed to work for all cases; they may or may not contain bugs or other issues, and they are simply still in development and are offered as a preview for test and feedback purposes. As soon as a module is developed and becomes mature enough, it becomes available in other categories mentioned before, and it's taken out of the technology preview category. An example of these types of modules, at the moment of writing this book, is Qt Speech, which is a module that is aimed to add support for text-to-speech in Qt applications. It's always a good idea to keep an eye on these modules if you are looking forward to becoming a fully-fledged Qt developer.

For more information on this, you can refer to http://doc.qt.io/qt-5/qtmodules.html.

Platforms supported by Qt

When we are talking about developing applications, the platform can have many different meanings, including the OS type, OS version, Compiler type, Compiler version, and Architecture of the processor (32-bit, 64-bit, Arm, and more). Qt supports many (if not all) of the well-known platforms and is usually quick enough to catch up with new platforms when they are released. The following is the list of platforms supported by Qt at the moment of writing this book (Qt 5.9). Note that you will probably not use all of the platforms mentioned here, but it gives you a sense of how powerful and cross-platform Qt really is:

Platform

Compiler

Notes

Windows

Windows 10 (64-bit)

MSVC 2017, MSVC 2015, MSVC 2013, MinGW 5.3

Windows 10 (32-bit)

MSVC 2017, MSVC 2015, MSVC 2013, MinGW 5.3

Windows 8.1 (64-bit)

MSVC 2017, MSVC 2015, MSVC 2013, MinGW 5.3

Windows 8.1 (32-bit)

MSVC 2017, MSVC 2015, MSVC 2013, MinGW 5.3

Windows 7 (64-bit)

MSVC 2017, MSVC 2015, MSVC 2013, MinGW 5.3

Windows 7 (32-bit)

MSVC 2017, MSVC 2015, MSVC 2013, MinGW 5.3

MinGW-builds gcc 5.3.0 (32-bit)

Linux/X11

openSUSE 42.1 (64-bit)

GCC 4.8.5

Red Hat Enterprise Linux 6.6 (64-bit)

GCC 4.9.1

devtoolset-3

Red Hat Enterprise Linux 7.2 (64-bit)

GCC 5.3.1

devtoolset-4

Ubuntu 16.04 (64-bit)

GCC as provided by Canonical

(Linux 32/64-bit)

GCC 4.8, GCC 4.9, GCC 5.3

macOS

macOS 10.10, 10.11, 10.12

Clang as provided by Apple

Embedded Platforms: Embedded Linux, QNX, INTEGRITY

Embedded Linux

GCC

ARM Cortex-A, Intel boards with GCC-based toolchains

QNX 6.6.0, 7.0 (armv7le and x86)

GCC as provided by QNX

Hosts: RHEL 6.6 (64-bit), RHEL 7.2 (64-bit), Windows 10 (64-bit), Windows 7 (32-bit)

INTEGRITY 11.4.x

As provided by Green Hills INTEGRITY

Hosts: 64-bit Linux

Mobile Platforms: Android, iOS, Universal Windows Platform (UWP)

Universal Windows Platform (UWP) (x86, x86_64, armv7)

MSVC 2017, MSVC 2015

Hosts: Windows 10

iOS 8, 9, 10 (armv7, arm64)

Clang as provided by Apple

macOS 10.10 host

Android (API Level: 16)

GCC as provided by Google, MinGW 5.3

Hosts: RHEL 7.2 (64-bit), macOS 10.12, Windows 7 (64-bit)

 

Reference: http://doc.qt.io/qt-5/supported-platforms.html

As you'll see in the next sections, we'll use the Microsoft Visual C++ 2015 (or from here on, simply MSVC 2015) compiler on Windows since both Qt and OpenCV (which you'll learn about later) highly support it. We'll also use GCC on Linux and Clang on macOS operating systems. All of which are tools that are either free and open source, or they are provided by the operating system provider. Although our main development system will be Windows, we'll cover Linux and macOS operating systems whenever there is a difference between Windows and other versions. So, the default screenshots throughout the book will be that of Windows, with Linux and macOS screenshots provided wherever there's any serious difference between them and not just simply a slight difference between paths, coloring of buttons, and so on.

Qt Creator

Qt Creator is the name of the IDE (Integrated Development Environment) used to develop Qt applications. It's also the IDE that we will use throughout this book to create and build our projects. It is worth noting that Qt applications can be created using any other IDE (such as Visual Studio or Xcode), and Qt Creator is not a requirement to build Qt applications, but it's a lightweight and powerful IDE that comes with the Qt Framework installer by default. So, the biggest advantage it has is easy integration with the Qt framework.

The following is a screenshot of the Qt Creator, which shows the IDE in code editing mode. Details on how to use the Qt Creator will be covered in the next chapter, although we'll give it a try for a couple of tests later on in this chapter too, without going into too much detail about it:

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at ₹800/month. Cancel anytime