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
Conferences
Free Learning
Arrow right icon
Mastering OpenCV Android Application Programming
Mastering OpenCV Android Application Programming

Mastering OpenCV Android Application Programming: Master the art of implementing computer vision algorithms on Android platforms to build robust and efficient applications

eBook
R$49.99 R$245.99
Paperback
R$306.99
Subscription
Free Trial
Renews at R$50p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Table of content icon View table of contents Preview book icon Preview Book

Mastering OpenCV Android Application Programming

Chapter 1. Applying Effects to Images

Generally, an image contains more information than required for any particular task. For this reason, we need to preprocess the images so that they contain only as much information as required for the application, thereby reducing the computing time needed.

In this chapter, we will learn about the different preprocessing operations, which are as follows:

  • Blurring
  • De-noising
  • Sharpening
  • Erosion and dilation
  • Thresholding and adaptive thresholding

At the end of this chapter, we will see how you can integrate OpenCV into your existing Android applications.

Before we take a look at the various feature detection algorithms and their implementations, let's first build a basic Android application to which we will keep adding feature detection algorithms, as we go through this chapter.

Getting started

When we see an image, we perceive it as colors and objects. However, a computer vision system sees it as a matrix of numbers (see the following image). These numbers are interpreted differently, depending on the color model used. The computer cannot directly detect patterns or objects in the image. The aim of computer vision systems is to interpret this matrix of numbers as an object of a particular type.

Getting started

Representation of a binary image

Setting up OpenCV

OpenCV is the short form of Open Source Computer Vision library. It is the most widely used computer vision library. It is a collection of commonly used functions that perform operations related to computer vision. OpenCV has been natively written in C/C++, but has wrappers for Python, Java, and any JVM language, which is designed to create the Java byte code, such as Scala and Clojure. Since most of the Android app development is done in C++/Java, OpenCV has also been ported as an SDK that developers can use to implement it in their apps and make them vision enabled.

We will now take a look at how to get started with setting up OpenCV for the Android platform, and start our journey. We will use Android Studio as our IDE of choice, but any other IDE should work just as well with slight modifications. Follow these steps in order to get started:

  1. Download Android Studio from https://developer.android.com/sdk/ and OpenCV4Android SDK from http://sourceforge.net/projects/opencvlibrary/files/opencv-android/.
  2. Extract the two files to a known location.
  3. Create a normal Android Project and name it FirstOpenCVApp. Navigate to File | Import.
  4. Select the OpenCV_SDK_location/sdk/java/ directory.
  5. Navigate to Build | Rebuild Project.
  6. Navigate to File | Project Structure.
  7. Add the OpenCV module to your app by selecting the app module in the left column. Click on the green in the dependencies tab, and finally, select the OpenCV module.
  8. You are now ready to use OpenCV in your Android project. It should look like this:
Setting up OpenCV

Storing images in OpenCV

OpenCV stores images as a custom object called Mat. This object stores the information such as rows, columns, data, and so on that can be used to uniquely identify and recreate the image when required. Different images contain different amounts of data. For example, a colored image contains more data than a grayscale version of the same image. This is because a colored image is a 3-channel image when using the RGB model, and a grayscale image is a 1-channel image. The following figures show how 1-channel and multichannel (here, RGB) images are stored (these images are taken from docs.opencv.org).

A 1-channel representation of an image is shown as follows:

Storing images in OpenCV

A grayscale (1-channel) image representation:

A more elaborate form of an image is the RGB representation, which is shown as follows:

Storing images in OpenCV

A RGB (3-channel) image representation

In the grayscale image, the numbers represent the intensity of that particular color. They are represented on a scale of 0-255 when using integer representations, with 0 being pure black and 255 being pure white. If we use a floating point representation, the pixels are represented on a scale of 0-1, with 0 being pure black and 1 being pure white. In an RGB image in OpenCV, the first channel corresponds to blue color, second channel corresponds to green color, and the third channel corresponds to red color. Thus, each channel represents the intensity of any particular color. As we know that red, green, and blue are primary colors, they can be combined in different proportions to generate any color visible to the human eye. The following figure shows the different colors and their respective RGB equivalents in an integer format:

Storing images in OpenCV
Storing images in OpenCV

Now that we have seen how an image is represented in computing terms, we will see how we can modify the pixel values so that they need less computation time when using them for the actual task at hand.

Linear filters in OpenCV

We all like sharp images. Who doesn't, right? However, there is a trade-off that needs to be made. More information means that the image will require more computation time to complete the same task as compared to an image which has less information. So, to solve this problem, we apply blurring operations.

Many of the linear filtering algorithms make use of an array of numbers called a kernel. A kernel can be thought of as a sliding window that passes over each pixel and calculates the output value for that pixel. This can be understood more clearly by taking a look at the following figure (this image of linear filtering/convolution is taken from http://test.virtual-labs.ac.in/labs/cse19/neigh/convolution.jpg):

Linear filters in OpenCV

In the preceding figure, a 3 x 3 kernel is used on a 10 x 10 image.

One of the most general operations used for linear filtering is convolution. The values in a kernel are coefficients for multiplication of the corresponding pixels. The final result is stored in the anchor point, generally, the center of the kernel:

Linear filters in OpenCV

Note

Linear filtering operations are generally not in-place operations, as for each pixel we use the values present in the original image, and not the modified values.

One of the most common uses of linear filtering is to remove the noise. Noise is the random variation in brightness or color information in images. We use blurring operations to reduce the noise in images.

The mean blur method

A mean filter is the simplest form of blurring. It calculates the mean of all the pixels that the given kernel superimposes. The kernel that is used for this kind of operation is a simple Mat that has all its values as 1, that is, each neighboring pixel is given the same weightage.

For this chapter, we will pick an image from the gallery and apply the respective image transformations. For this, we will add basic code. We are assuming that OpenCV4Android SDK has been set up and is running.

We can use the first OpenCV app that we created at the start of the chapter for the purpose of this chapter. At the time of creating the project, the default names will be as shown in the following screenshot:

The mean blur method

Add a new activity by right-clicking on the Java folder and navigate to New | Activity. Then, select Blank Activity. Name the activity MainActivity.java and the XML file activity_main.xml. Go to res/menu/menu_main.xml. Add an item as follows:

<item android:id="@+id/action_load_image"
        android:title="@string/action_load_image"
        android:orderInCategory="1"
        android:showAsAction="ifRoom" />

Since MainActivity is the activity that we will be using to perform our OpenCV specific tasks, we need to instantiate OpenCV. Add this as a global member of MainActivity.java:

private BaseLoaderCallback mOpenCVCallBack = new BaseLoaderCallback(this) {
        @Override
        public void onManagerConnected(int status) {
            switch (status) {
                case LoaderCallbackInterface.SUCCESS:
                    //DO YOUR WORK/STUFF HERE
                    break;
                default:
                    super.onManagerConnected(status);
                    break;
            }
        }
    };
@Override
    protected void onResume() {
        super.onResume();
        OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_10, this,
                mOpenCVCallBack);
    }

This is a callback, which checks whether the OpenCV manager is installed. We need the OpenCV manager app to be installed on the device because it has all of the OpenCV functions defined. If we do not wish to use the OpenCV manager, we can have the functions present natively, but the APK size then increases significantly. If the OpenCV manager is not present, the app redirects the user to the Play Store to download it. The function call in onResume loads OpenCV for use.

Next we will add a button to activity_home.xml:

<Button
            android:id="@+id/bMean"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:text="Mean Blur" />

Then, in HomeActivity.java, we will instantiate this button, and set an onClickListener to this button:

Button bMean = (Button)findViewById(R.id.bMean);
bMean.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent(getApplicationContext(),MainActivity.class);
                i.putExtra("ACTION_MODE", MEAN_BLUR);
                startActivity(i);
            }
        });

Tip

Downloading the example code

You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

In the preceding code, MEAN_BLUR is a constant with value 1 that specifies the type of operation that we want to perform.

Here we have added extra to the activity bundle. This is to differentiate which operation we will be performing.

Open activity_main.xml. Replace everything with this code snippet. This snippet adds two ImageView items: one for the original image and one for the processed image:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" 
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="0.5"
        android:id="@+id/ivImage" />

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="0.5"
        android:id="@+id/ivImageProcessed" />

</LinearLayout>

We need to programmatically link these ImageView items to the ImageView items in Java in our MainActivity.java:

    private final int SELECT_PHOTO = 1;
    private ImageView ivImage, ivImageProcessed;
    Mat src;
    static int ACTION_MODE = 0;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
// Android specific code
ivImage = (ImageView)findViewById(R.id.ivImage);
        ivImageProcessed = (ImageView)findViewById(R.id.ivImageProcessed);
        Intent intent = getIntent();

        if(intent.hasExtra("ACTION_MODE")){
            ACTION_MODE = intent.getIntExtra("ACTION_MODE", 0);
}

Here, the Mat and ImageViews have been made global to the class so that we can use them in other functions, without passing them as parameters. We will use the ACTION_MODE variable to identify the required operation to be performed.

Now we will add the code to load an image from the gallery. For this, we will use the menu button we created earlier. We will load the menu_main.xml file, when you click on the menu button:

@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

Then we will add the listener that will perform the desired action when an action item is selected. We will use Intent.ACTION_PICK to get an image from the gallery:

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();
        if (id == R.id.action_load_image) {
            Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
            photoPickerIntent.setType("image/*");
            startActivityForResult(photoPickerIntent, SELECT_PHOTO);
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

As you can see, we have used startActivityForResult(). This will send the selected image to onActivityResult(). We will use this to get the Bitmap and convert it to an OpenCV Mat. Once the operation is complete, we want to get the image back from the other activity. For this, we make a new function onActivityResult() that gets called when the activity has completed its work, and is returned to the calling activity. Add the following code to onActivityResult():

        switch(requestCode) {
            case SELECT_PHOTO:
                if(resultCode == RESULT_OK){
                    try {
                        //Code to load image into a Bitmap and convert it to a Mat for processing.
            final Uri imageUri = imageReturnedIntent.getData();
            final InputStream imageStream = getContentResolver().openInputStream(imageUri);
            final Bitmap selectedImage = BitmapFactory.decodeStream(imageStream);
                src = new Mat(selectedImage.getHeight(), selectedImage.getWidth(), CvType.CV_8UC4);
                        Utils.bitmapToMat(selectedImage, src);

                        switch (ACTION_MODE){
                            //Add different cases here depending on the required operation
                        }
                            //Code to convert Mat to Bitmap to load in an ImageView. Also load original image in imageView
    
                   } catch (FileNotFoundException e) {
                        e.printStackTrace();
                   }
    }
            break;
  }

To apply mean blur to an image, we use the OpenCV provided function blur(). We have used a 3 x 3 kernel for this purpose:

case HomeActivity.MEAN_BLUR:
Imgproc.blur(src, src, new Size(3,3));
      break;

Now we will set this image in an ImageView to see the results of the operation:

Bitmap processedImage = Bitmap.createBitmap(src.cols(), src.rows(), Bitmap.Config.ARGB_8888);
Utils.matToBitmap(src, processedImage);
ivImage.setImageBitmap(selectedImage);
ivImageProcessed.setImageBitmap(processedImage);
The mean blur method

Original Image (Left) and Image after applying Mean Blur (Right)

The Gaussian blur method

The Gaussian blur is the most commonly used method of blurring. The Gaussian kernel is obtained using the Gaussian function given as follows:

The Gaussian blur method
The Gaussian blur method

The Gaussian Function in one and two dimensions

The anchor pixel is considered to be at (0, 0). As we can see, the pixels closer to the anchor pixel are given a higher weightage than those further away from it. This is generally the ideal scenario, as the nearby pixels should influence the result of a particular pixel more than those further away. The Gaussian kernels of size 3, 5, and 7 are shown in the following figure (image of 'Gaussian kernels' taken from http://www1.adept.com/main/KE/DATA/ACE/AdeptSight_User/ImageProcessing_Operations.html):

The Gaussian blur method

These are the Gaussian kernels of size 3 x 3, 5 x 5 and 7 x 7.

To use the Gaussian blur in your application, OpenCV provides a built-in function called GaussianBlur. We will use this and get the following resulting image. We will add a new case to the same switch block we used earlier. For this code, declare a constant GAUSSIAN_BLUR with value 2:

case HomeActivity.GAUSSIAN_BLUR:
    Imgproc.GaussianBlur(src, src, new Size(3,3), 0);
    break;
The Gaussian blur method

Image after applying Gaussian blur on the original image

The median blur method

One of the common types of noise present in images is called salt-and-pepper noise. In this kind of noise, sparsely occurring black and white pixels are distributed over the image. To remove this type of noise, we use median blur. In this kind of blur, we arrange the pixels covered by our kernel in ascending/descending order, and set the value of the middle element as the final value of the anchor pixel. The advantage of using this type of filtering is that salt-and-pepper noise is sparsely occurring, and so its influence is only over a small number of pixels when averaging their values. Thus, over a bigger area, the number of noise pixels is fewer than the number of pixels that are useful, as shown in the following image:

The median blur method

Example of salt-and-pepper noise

To apply median blur in OpenCV, we use the built-in function medianBlur. As in the previous cases, we have to add a button and add the OnClickListener functions. We will add another case condition for this operation:

case HomeActivity.MEDIAN_BLUR:
    Imgproc.medianBlur(src, src, 3);
    break;
The median blur method

Resulting image after applying median blur

Note

Median blur does not use convolution.

Creating custom kernels

We have seen how different types of kernels affect the image. What if we want to create our own kernels for different applications that aren't natively offered by OpenCV? In this section, we will see how we can achieve just that. We will try to form a sharper image from a given input.

Sharpening can be thought of as a linear filtering operation where the anchor pixel has a high weightage and the surrounding pixels have a low weightage. A kernel satisfying this constraint is shown in the following table:

0

-1

0

-1

5

-1

0

-1

0

We will use this kernel to perform the convolution on our image:

case HomeActivity.SHARPEN:
    Mat kernel = new Mat(3,3,CvType.CV_16SC1); 
          kernel.put(0, 0, 0, -1, 0, -1, 5, -1, 0, -1, 0);

Here we have given the image depth as 16SC1. This means that each pixel in our image contains a 16-bit signed integer (16S) and the image has 1 channel (C1).

Now we will use the filter2D()function, which performs the actual convolution when given the input image and a kernel. We will show the image in an ImageView. We will add another case to the switch block created earlier:

    Imgproc.filter2D(src, src, src.depth(), kernel);
Creating custom kernels

Original image (left) and sharpened image (right)

Morphological operations

Morphological operations are a set of operations that process an image based on the features of the image and a structuring element. These generally work on binary or grayscale images. We will take a look at some basic morphological operations before moving on to more advance ones.

Dilation

Dilation is a method by which the bright regions of an image are expanded. To achieve this, we take a kernel of the desired size and replace the anchor pixel with the maximum value overlapped by the kernel. Dilation can be used to merge objects that might have been broken off.

Dilation

A binary image (left) and the result after applying dilation (right)

To apply this operation, we use the dilate()function. We need to use a kernel to perform dilation. We use the getStructuringElement() OpenCV function to get the required kernel.

OpenCV provides MORPH_RECT, MORPH_CROSS, and MORPH_ELLIPSE as options to create our required kernels:

case HomeActivity.DILATE:
    Mat kernelDilate = Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(3, 3));
    Imgproc.dilate(src, src, kernelDilate);
    break;
Dilation

Original image (left) and dilated image (right)

If we use a rectangular structuring element, the image grows in the shape of a rectangle. Similarly, if we use an elliptical structuring element, the image grows in the shape of an ellipse.

Erosion

Similarly, erosion is a method by which the dark regions of an image are expanded. To achieve this, we take a kernel of the desired size and replace the anchor pixel by the minimum value overlapped by the kernel. Erosion can be used to remove the noise from images.

Erosion

A binary image (left) and the result after applying erosion (right)

To apply this operation, we use the erode() function:

case HomeActivity.ERODE:
    Mat kernelErode = Imgproc.getStructuringElement(Imgproc.MORPH_ELLIPSE, new Size(5, 5));
    Imgproc.erode(src, src, kernelErode);
         break;
Erosion

Original image (left) and eroded image (right)

Note

Erosion and dilation are not inverse operations.

Thresholding

Thresholding is the method of segmenting out sections of an image that we would like to analyze. The value of each pixel is compared to a predefined threshold value and based on this result, we modify the value of the pixel. OpenCV provides five types of thresholding operations.

To perform thresholding, we will use the following code as a template and change the parameters as per the kind of thresholding required. We need to replace THRESH_CONSTANT with the constant for the required method of thresholding:

case HomeActivity.THRESHOLD:
    Imgproc.threshold(src, src, 100, 255, Imgproc.THRESH_CONSTANT);
    break;

Here, 100 is the threshold value and 255 is the maximum value (the value of pure white).

The constants are listed in the following table:

Thresholding Method Name

Thresholding Function

Constant

Binary threshold

Thresholding

THRESH_BINARY

Threshold to zero

Thresholding

THRESH_TOZERO

Truncate

Thresholding

THRESH_TRUNC

Binary threshold, inverted

Thresholding

THRESH_BINARY_INV

Threshold to zero, inverted

Thresholding

THRESH_TOZERO_INV

The following image for thresholding results is taken from http://docs.opencv.org/trunk/d7/d4d/tutorial_py_thresholding.html:

Thresholding

Adaptive thresholding

Setting a global threshold value may not be the best option when performing segmentation. Lighting conditions affect the intensity of pixels. So, to overcome this limitation, we will try to calculate the threshold value for any pixel based on its neighboring pixels.

We will use three parameters to calculate the adaptive threshold of an image:

  1. Adaptive method: The following are the two methods we will use:
    • ADAPTIVE_THRESH_MEAN_C: The threshold value is the mean of the neighboring pixels
    • ADAPTIVE_THRESH_GAUSSIAN_C: The threshold value is the weighted sum of the neighboring pixel values, where weights are Gaussian kernels
  2. Block Size: This is the size of the neighborhood
  3. C: This is the constant that has to be subtracted from the mean/weighted mean calculated for each pixel:
    case HomeActivity.ADAPTIVE_THRESHOLD:
        Imgproc.cvtColor(src, src, Imgproc.COLOR_BGR2GRAY);
        Imgproc.adaptiveThreshold(src, src, 255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C, Imgproc.THRESH_BINARY, 3, 0);
        break;
    Adaptive thresholding

    Original image (left) and image after applying Adaptive thresholding (right)

Here, the resulting image has a lot of noise present. This can be avoided by applying a blurring operation before applying adaptive thresholding, so as to smooth the image.

Summary

In this chapter, we have learnt how to get started with using OpenCV in your Android project. Then we looked at different filters in image processing, especially linear filters, and how they can be implemented on an Android device. These filters will later form the basis of any computer vision application that you try to build. In the following chapters, we will look at more complex image filters, and also see how to extract information from the images in the form of edges, corners, and the like.

Left arrow icon Right arrow icon

Description

If you are a Java and Android developer looking to enhance your skills by learning the latest features of OpenCV Android application programming, then this book is for you.

Who is this book for?

If you are a Java and Android developer looking to enhance your skills by learning the latest features of OpenCV Android application programming, then this book is for you.

What you will learn

  • Understand image processing using OpenCV
  • Detect specific objects in an image or video using various stateoftheart featurematching algorithms such as SIFT, SURF, and ORB
  • Perform image transformations such as changing color, space, resizing, applying filters like Gaussian blur, and likes
  • Use mobile phone cameras to interact with the real world
  • Explore face detection, object detection, and image stitching in OpenCV Android programming
  • Build smarter applications by using machine learning algorithms
  • Learn to debug applications and create optimal custom algorithms by understanding how data is stored internally
Estimated delivery fee Deliver to Brazil

Standard delivery 10 - 13 business days

R$63.95

Premium delivery 3 - 6 business days

R$203.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jul 29, 2015
Length: 216 pages
Edition : 1st
Language : English
ISBN-13 : 9781783988204
Category :
Languages :
Tools :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to Brazil

Standard delivery 10 - 13 business days

R$63.95

Premium delivery 3 - 6 business days

R$203.95
(Includes tracking information)

Product Details

Publication date : Jul 29, 2015
Length: 216 pages
Edition : 1st
Language : English
ISBN-13 : 9781783988204
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
R$50 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
R$500 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 R$25 each
Feature tick icon Exclusive print discounts
R$800 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 R$25 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total R$ 736.97
OpenCV Android Programming By Example
R$183.99
Mastering OpenCV Android Application Programming
R$306.99
OpenCV Computer Vision with Java
R$245.99
Total R$ 736.97 Stars icon
Banner background image

Table of Contents

10 Chapters
1. Applying Effects to Images Chevron down icon Chevron up icon
2. Detecting Basic Features in Images Chevron down icon Chevron up icon
3. Detecting Objects Chevron down icon Chevron up icon
4. Drilling Deeper into Object Detection – Using Cascade Classifiers Chevron down icon Chevron up icon
5. Tracking Objects in Videos Chevron down icon Chevron up icon
6. Working with Image Alignment and Stitching Chevron down icon Chevron up icon
7. Bringing Your Apps to Life with OpenCV Machine Learning Chevron down icon Chevron up icon
8. Troubleshooting and Best Practices Chevron down icon Chevron up icon
9. Developing a Document Scanning App Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.5
(4 Ratings)
5 star 75%
4 star 0%
3 star 25%
2 star 0%
1 star 0%
Carles Sep 04, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is aimed to both mobile app developers who want to improve the graphic functionality to a new level (3d gaming, augmented reality, etc) or to opengl desktop developers who want to extent his projects/products to mobile platforms. Both would benefit from all the know-how inside this book, that goes deep into not only the OpenCV framework fundamentals but also into some math required for creating powerful 2d/3d code and behaviours. A warn for beginners, you should know at least some C/C++ basic coding and some algebra (arrays, matrix and so) to not get lost while reading this book. Otherwise the book is a very useful and deep source of knowledge regarding OpenCV application to develop mobile apps.
Amazon Verified review Amazon
Gabriel Humpire Mamani Sep 24, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I had a chance to read "Mastering OpenCV Android Application Programming" recently on a request of Packt Publishing. I hope to help readers with this review. Let's go, I got my copy from Packt Publishing, where additional formats to download it are available. In my case, I preferred it in Kindle Edition, also they provide me the source code for each chapter to a better understanding of each topic.This book is suitable for people who have at least basic knowledge in Android, OpenCV and Computer Vision, if you are new in Android maybe you should have to learn it before reading this book. Let's begin with the main review. The first chapters are about OpenCV basic concepts (brightness, contrast, color space, arithmetic and geometrical transforms) and how to set OpenCV in your Android project step by step. For every topic, they show the code, explanation and results.Until chapter 5, the content was about main OpenCV functions with Android interactions, but here on-wards the interesting and useful projects are explained such as Image alignment and stitching with notable improvements. Moreover, a Machine Learning chapter explains how to use its potential for Android apps. A nice chapter explains the best practices for Android projects as well for debugging using logcat logs. Finally, an entire chapter dedicated for an Optical Character Recognition is detailed.Afterwards, I found this book very useful and recommendable. Overall, this is a must-read book for Android programmers, and Computer Vision specialists.
Amazon Verified review Amazon
André Aug 18, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is recommended for those who wants to delve into the image processing techniques in the context of mobile applications. The book also provides a valuable examples and guide you step by step over the contents.
Amazon Verified review Amazon
erick lestrange Nov 05, 2017
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
cuatro copypastes de interner que ni siquiera se han molestado en ocultar, formulas que ni siquiera son las que usaras, pocos ejemplos practicos y aplicaciones... casi que sale mejo verse tutoriales en youtube
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 the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela