007 - Summer Training Report
007 - Summer Training Report
•Easy-to-learn:
Python has few keywords, simple structure, and
a clearly defined syntax. This allows the student
to pick up the language quickly.
•Interactive Mode:
Python has support for an interactive mode
which allows interactive testing and debugging of
snippets of code.
•Portable:
Python can run on a wide variety of hardware
platforms and has the same interface on all
platforms.
Python Advantages and Disadvantages
Introduction to Computer Vision
Computer Vision is an interdisciplinary field that deals
with how computers can be made to gain a high-level
understanding from digital images or videos.
The idea here is to automate tasks that the human visual
systems can do. So, a computer should be able to
recognize objects such as that of a face of a human being
or a lamppost or even a statue.
What is Open CV ?
OpenCV is a Python library which is designed to solve
computer vision problems. OpenCV was originally developed in
1999 by Intel but later it was supported by Willow Garage.
OpenCV supports a wide variety of programming languages
such as C++, Python, Java etc. Support for multiple platforms
including Windows, Linux, and MacOS.
OpenCV Python is nothing but a wrapper class for the original
C++ library to be used with Python. Using this, all of the
OpenCV array structures gets converted to/from NumPy arrays.
This makes it easier to integrate it with other libraries which
use NumPy. For example, libraries such as SciPy and Matplotlib.
Features Of Open CV
Cross Platform
Windows, Linux, Mac OS
Portable
iPhone
Android.
Language Support
C/C++
Python
Robot support
OpenCV Overview: > 500 functions
opencv.willowgarage.com
Geometric
Descriptors
Segmentation Camera
Calibration,
Stereo, 3D
Features
Transforms Utilities and
Data Structures
Tracking
Machine
Learning: Fitting
•Detection,
•Recognition
Matrix Math
12
Installation Instructions
• For Mac OS X. Simply install Mac Ports then type
• sudo port install opencv
• Do not use synaptic on Linux to install OpenCV.
• It is version 1.2.
• For Linux and Windows, follow the installation guide at
http://opencv.willowgarage.com/wiki/InstallGuide
• Linux users can come to me for help. I have built it on
Ubuntu dozens of times. I have built it successfully on
Windows once.
• Make sure to read the beginning as it gives you precise
commands to install ffmpeg, libavformat-dev,
libswscale-dev, and other required libraries.
• Follow instructions exactly!!!!!
Image TYPES
• The TYPE is a very important aspect of OpenCV
• Represented as CV_<Datatype>C<# Channels>
• Example Datatypes/ Depths
Pixel types
• PixelTypes shows how the image is represented
in data
– BGR - The default color of imread(). Normal 3 channel color
– HSV - Hue is color, Saturation is amount, Value is lightness. 3
channels
– GRAYSCALE - Gray values, Single channel
• OpenCV requires that images be in BGR or Grayscale in
order to be shown or saved. Otherwise, undesirable effects
may appear.
HELLO WORLD
• Example Code This program will load and show an
//Loads image and displays image
//call by ./a.out image.jpg
//
#include <cv.h>
#include <cvaux.h>
#include <highgui.h>
namedWindow(“Sample Window”);
imshow(“Sample Window”,image);
waitKey(0);
return 0;
}
Image I/O
• OpenCV provides simple and useful • Examples
ways to read and write images. //Read an image
Mat image = imread( <string>, <0 -gray, 1 -BGR>)
//Note 1 is default
• Note that there are many extra
options to these commands which //Write an image
are available on the wiki. imwrite( <string filename> , image );
• Note that there are more options, however this should keep
things simple
• # Detects faces of different sizes in the input image • # De-allocate any associated memory usage
• faces = face_cascade.detectMultiScale(gray, 1.3, 5) • cv2.destroyAllWindows()
Output Of Face Detection Program
Find And Draw Contours
• Contours are defined as the line joining all the
points along the boundary of an image that are
having the same intensity. Contours come
handy in shape analysis, finding the size of the
object of interest, and object detection.
• OpenCV has findContour() function that helps
in extracting the contours from the image. It
works best on binary images, so we should first
apply thresholding techniques, Sobel edges, etc.
Code for finding Countours
• import cv2 • # since findContours alters the image
• import numpy as np • contours, hierarchy = cv2.findContours(edged,
• cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
• # Let's load a simple image with 3 black squares
• image = cv2.imread('C://Users//gfg//shapes.jpg') • cv2.imshow('Canny Edges After Contouring', edged)
• cv2.waitKey(0) • cv2.waitKey(0)
• https://www.geeksforgeeks.org/