Book Image

OpenCV Essentials

Book Image

OpenCV Essentials

Overview of this book

Table of Contents (15 chapters)
OpenCV Essentials
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

SVM for classification


The Support Vector Machine (SVM) classifier finds a discriminant function by maximizing the geometrical margin between the classes. Thus, the space is mapped in such a way that the classes are as widely separated as possible. SVM minimizes both the training error and the geometrical margin. Nowadays, this classifier is one of the best classifiers available and has been applied to many real-world problems. The following SVMClassifier sample code performs a classification using the SVM classifier and a dataset of 66 image objects. The dataset is divided into four classes: a training shoe (class 1), a cuddly toy (class 2), a plastic cup (class 3), and a bow (class 4). The following screenshot shows the examples of the four classes. A total of 56 images and 10 images were used for the training and the test sets, respectively. Images in the training set take the following name structure: [1-14].png corresponds to class 1, [15-28].png to class 2, [29-42].png to class 3,...