Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
OpenCV Essentials
OpenCV Essentials

OpenCV Essentials: Acquire, process, and analyze visual content to build full-fledged imaging applications using OpenCV

eBook
$12.99 $18.99
Paperback
$28.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

OpenCV Essentials

Chapter 2. Something We Look At – Graphical User Interfaces

In this chapter, we will cover the main user interface capabilities included with the OpenCV library. We will start with the user interface functions included in the highgui module. Then, we will deal with the insertion of objects (such as text and geometrical shapes) on the displayed windows to point out some specific characteristics on images. Finally, the chapter addresses the new Qt functions included in OpenCV to enrich the user experience.

Using OpenCV's highgui module

The highgui module has been designed to provide an easy way to visualize the results and try the functionality of developed applications with OpenCV. As we saw in the previous chapter, this module supplies functions to perform the following operations:

  • Reading images and videos from files and live cameras (imread) through a VideoCapture object.
  • Writing images and videos from memory to disk (imwrite) through a VideoWriter object.
  • Creating a window that can display images and video frames (namedWindow and imshow).
  • Fetching and handling events when a key is pressed (waitKey).

Of course, the module contains more functions to enhance the user interaction with the software applications. Some of them will be explained in this chapter. In the following tbContrast code example, we can read an image file and two windows are created: the first one shows the original image and the other is the resulting image after increasing or decreasing the contrast to the original...

Text and drawing

In the previous section, we used a simple user interface to get input values by a trackbar. However, in many applications, the user has to point locations and regions on the image and mark them with text labels. For this purpose, the highgui module provides a set of drawing functions along with mouse event handling.

The drawThings code example shows an easy application to mark positions on an input image. The positions are marked with a red circle and a black text label next to it. The following screenshot displays the window with the input image and the marked positions on it. To mark each position on the image, the user uses has to click the left mouse button over it. In other application, the marked position could be the obtained points or regions from an algorithm applied to the input image.

Next, we show the example code where some pieces of code have been omitted for simplicity, since they are duplicated in other previous examples:

    // (omitted for simplicity)
#define...

Selecting regions

Many computer vision applications require to focus interest inside local regions of the images. In that case, it is a very useful user tool to select the desired regions of interest (ROI). In the drawRs example, we show how to select, with the mouse, rectangular regions in the image to locally increase the contrast inside these regions (as shown in the following screenshot). For better control over region selection, we implement a click-and-drag behavior to reshape the rectangular boundary of each region.

Selecting regions

Output image with increased contrast in some rectangular regions

For the sake of simplicity, only the code corresponding to the function callback for mouse events is shown, since the rest is quite similar in the previous examples. The code is as follows:

void cbMouse(int event, int x, int y, int flags, void* userdata) {

  static Point p1, p2; // Static vars hold values between calls
  static bool p2set = false;

  if (event == EVENT_LBUTTONDOWN) { // Left mouse button pressed...

Using Qt-based functions

While highgui will be sufficient for most purposes, the Qt UI framework (available at http://qt-project.org/) can be leveraged in OpenCV to develop richer user interfaces. A number of OpenCV's user interface functions use the Qt library behind the scenes. In order to use these functions, OpenCV must have been compiled with the WITH_QT option.

Note that Qt is a class and widget library that allows the creation of full-fledged applications with rich, event-driven user interfaces. In this section, however, we will mainly focus on specific Qt-based functions within OpenCV. Programming with Qt is out of the scope of this book.

With Qt support on, windows created with the namedWindow function will automatically look like what is shown in the following screenshot. There is a toolbar with useful functions such as pan, zoom, and save image. Windows also display a status bar at the bottom with the current mouse location and RGB value under that pixel. Right-clicking on...

Summary

In this chapter, we provided a deeper view of the highgui module functionality to enrich the user experience. The main elements supplied by OpenCV to build graphical user interfaces are shown in some code samples. Moreover, we reviewed the new Qt functionality inside OpenCV.

The chapter's examples cover topics such as tbarContrast, tbarContrastCallB, drawThings, drawRs, and propertyDlgButtons.

The next chapter will cover the implementation of the most usual methods used for image processing, such as brightness control, contrast and color conversion, retina filtering, and geometrical transformations.

Left arrow icon Right arrow icon

Description

This book is intended for C++ developers who want to learn how to implement the main techniques of OpenCV and get started with it quickly. Working experience with computer vision / image processing is expected.

What you will learn

  • Explore advanced image processing techniques such as the retina algorithm, morphing, and color transfer
  • Create programs using advanced segmentation tools such as the new connectedComponents and connectedComponentsWithStats functions
  • Use flood filling along with the watershed transform to obtain better segmentations
  • Explore the new powerful KAZE features
  • Use advanced videobased background/foreground segmentation for class BackgroundSubtractor and ECCbased warping
  • Leverage the available object detection frameworks and the new scene text detection functionality
  • Get a grasp of advanced topics such as machine learning and GPU optimization

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Aug 25, 2014
Length: 214 pages
Edition : 1st
Language : English
ISBN-13 : 9781783984244
Category :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Aug 25, 2014
Length: 214 pages
Edition : 1st
Language : English
ISBN-13 : 9781783984244
Category :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 126.97
OpenCV Computer Vision Application Programming Cookbook Second Edition
$48.99
OpenCV Essentials
$28.99
Mastering OpenCV with Practical Computer Vision Projects
$48.99
Total $ 126.97 Stars icon

Table of Contents

9 Chapters
1. Getting Started Chevron down icon Chevron up icon
2. Something We Look At – Graphical User Interfaces Chevron down icon Chevron up icon
3. First Things First – Image Processing Chevron down icon Chevron up icon
4. What's in the Image? Segmentation Chevron down icon Chevron up icon
5. Focusing on the Interesting 2D Features Chevron down icon Chevron up icon
6. Where's Wally? Object Detection Chevron down icon Chevron up icon
7. What Is He Doing? Motion Chevron down icon Chevron up icon
8. Advanced Topics Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.3
(13 Ratings)
5 star 46.2%
4 star 38.5%
3 star 15.4%
2 star 0%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Jack S. Nov 10, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
First things first, OpenCV Essentials is definitely not a book for an image processing/computer vision novice.If you’ve been using OpenCV and programming in C++ for at least a few months and want a resource which you can quickly refer to when you’re delving into some of the deeper functionality of OpenCV, then I can thoroughly recommend this book to you.I’ve been using OpenCV for about one and a half years, and over that time I have witnessed a definite improvement in the documentation available online. However, good examples of some of the deeper functionality are still difficult to come across, and the ability of this book to plug this gap is one of its chief virtues.
Amazon Verified review Amazon
Amazon カスタマー Aug 29, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
ひと昔まえなら貧弱なCPUとあいまって実現不可能な画像処理がOpenCVを使えばいとも簡単に(<-開発経験者にとって)できてしまうことがよく理解できます。サンプルコードと、処理前後の写真を見るだけでも、古いソフトエンジニアには、唸ること間違いなし。英文も難しい言い回しもなく、大きな勘違いもなく、理解できるはずです。Kindleだと辞書で単語調べるのはラクラクですし。
Amazon Verified review Amazon
Yavor Nikolov Sep 28, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I received a copy of this from the publisher, and I am very glad I did. It's a wonderful book for everyone who wants to get fast solid knowledge of OpenCV.I have done Image processing in my University program and if I had the book at that time, the course would be much more easy and interesting primarily because "OpenCV Essentials" delivers all information in a straightforward way supported by lots of examples. The book is perfect for people with basic C++ knowledge who want to dwelve in the deeps of OpenCV with no complications like advanced mathematics and programming. I found it a pleasure to dip into different sections of the book with no previous knowledge of the topic.I would recommend the book to all newcomers in OpenCV.
Amazon Verified review Amazon
Gabriel Humpire Mamani Sep 29, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
A few weeks ago I have been selected by Packt Publishing to review the new book “OpenCV Essentials” by Oscar Deniz Suarez et.al. Thus here is my objective review:This book is for people who have at least basic knowledge in OpenCV and Computer Vision, if you are new in OpenCV maybe this book won’t be the suitable one. Additionally all the examples are in C++ for Visual Studio, I did not like the last restriction, but it was necessary for some examples. This book show some upcoming OpenCV functions for the next release 3.0 (available at this time in Alpha version), and there are a lot of very useful functions.Let’s begin with the main review. First chapters are about OpenCV basic functionalities (load images, brightness, contrast, color spaces, arithmetic and geometrical transforms). For every topic they show the code, explanation and results. The book shows tips in each topic, giving you the opportunity to investigate more about the functionality, and also they usually share links to Scientific Papers, thus, if you have a better idea to improve that function it helps you to do research about it.I found Threshold topic in Chapter 4 (What’s in the Image? Segmentation) very useful and didactic, a lot of developers (also experts) made mistakes in this topic when choosing the type of threshold. Until here, Chapters were about main OpenCV functions, but here on-wards the book becomes better and very useful with content about Pattern Recognition, Classification, also Video Processing. Thus, I will discuss separated every chapter.Chapter 5: Focusing on the Interesting 2D Features: This Chapter is totally based in Keypoints and its variations, the book provide a lot of examples and also the matching between images using Keypoints. Additionally some new OpenCV feature detectors of the new release are explained (KAZE and AKAZE).Chapter 6: Where’s Wally? Object Detection: The main topics are Cascade detectors and Latent SVM. The book shows an example of basic pedestrian detection in a few lines of code using HOG cascade detector. Also, if you need to train your own cascade, you will find a detailed explanation about how to do it.Chapter 7: What is he Doing? Motion: Due to I developed this kind of systems, I particularly liked this Chapter. Topics like Video tracking, Motion and Background subtraction are now included in the new OpenCV 3.0 and certainly will be very useful for everyone who is developing/researching this area. The book does not show the typical Optical Flow, but explains and optimized and faster Lucas-Kanade optical flow instead.Chapter 8: Advanced Topics: If you are interested in Machine learning, Classification, or CUDA GPU programming this Chapter will be very useful too. It shows how to use the Random Forest classifier, one of the best classifiers available in recognition power and efficiency. Also the typical SVM is explained with a simple version of a recognition system.To summarize, if you are using OpenCV for basic image processing certainly you will be more interested in Chapter 1 to 4, and maybe 5. If you need more depth knowledge and want to do complex Pattern Recognition systems you will be interested in Chapter 5 on-wards. The main weak point of this book is about pre-processing image explanation, although authors show some of them, they do not explain the real potential of the pre-processing step for this kind of systems. In all my experience I used a lot of pre-processing functions to improve results. Simple functions like erode, dilate and smoothing to avoid noise in images are very useful in all Computer Vision projects. Afterwards, I found this book very useful and recommendable.Overall, this is a must-read book for programmers, researchers, and people eager with basic OpenCV, Computer Vision and C++ knowledge.
Amazon Verified review Amazon
yagyavrat Nov 16, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Book is very good recipe for those who has prior knowledge of opencv, I did my engineering project using opencv so I was already familiar with this topic. Examples given in this book are for visual studio, but in first chapter it also explains how to use QT grphics library and integrating opecv with QT.In 3rd Chapter book covers basic image types, fundamentals of image and data types used to represent an image.In segmentation chapter author explains algorithms with proper examples and pictures which helps alot in understanding segmentaion and it usability in image processing.In Chapter 6 and 7 author describes SVM , Object detection algorithms and then how it works in OpenCV, This is what makes this book unique in its category. I always wanted to know how can I use machine learning algorithms in opencv, I had basic idea of opencv but problem was from where to start. This is a book which answers all those basic questions.We know that number of standard algorithms are already implemented in opencv but how can we use and what prior data is required to use those functions. This book genuinely helps to build concepts in image processing and opencv.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.