SlideShare a Scribd company logo
CAMERA VISION
IN PYTHON USINGOPENCV
INTRODUCTION
TO
PresentedBy
Ethi$h Kumar Keerthi
17K65A0501
List of
Contents
 INTRODUCTION
 HISTORY
 INSTALLATION
 READ/OPEN IMAGE
 ACCESS WEB CAM
 TECHNIQUES
 APPLICATIONS
 ALTERNATIVES
INTRODUCTION
OpenCV (Open source computer vision) is a library of programming functions mainly aimed at real-
time computer vision. “Computer Vision is a field of deep learning that enables machines to see,
identify and process images like humans”.
Computer vision is one of the hottest fields in the industry right now. You can expect plenty of job
openings to come up in the next 2-4 years. The question then is – are you ready to take advantage of
these opportunities?
CONT...
Take a moment to ponder this – which applications or products come to your mind when you think of
computer vision? The list is HUGE. We use some of them everyday! Features like unlocking our
phones using face recognition, our smartphone cameras, self-driving cars – computer vision is
everywhere
History
Officially launched in 1999 the OpenCV project was initially an Intel Research initiative to advance
CPU-intensive applications, part of a series of projects including real-time ray tracing and 3D display
walls.The main contributors to the project included a number of optimization experts in Intel Russia,
as well as Intel's Performance Library Team. In the early days of OpenCV, the goals of the project
were described as:
Advance vision research by providing not only open but also optimized code for basic vision
infrastructure. No more reinventing the wheel.
Disseminate vision knowledge by providing a common infrastructure that developers could build on,
so that code would be more readily readable and transferable.
Advance vision-based commercial applications by making portable, performance-optimized code
available for free – with a license that did not require code to be open or free itself.
The first alpha version of OpenCV was released to the public at the IEEE Conference on Computer
Vision and Pattern Recognition in 2000, and five betas were released between 2001 and 2005. The
first 1.0 version was released in 2006. A version 1.1 "pre-release" was released in October 2008.
CONT...
The second major release of the OpenCV was in October 2009. OpenCV 2 includes major changes to
the C++ interface, aiming at easier, more type-safe patterns, new functions, and better
implementations for existing ones in terms of performance (especially on multi-core systems).
Official releases now occur every six months and development is now done by an independent
Russian team supported by commercial corporations.In August 2012, support for OpenCV was taken
over by a non-profit foundation OpenCV.org, which maintains a developer.On May 2016, Intel signed
an agreement to acquire Itseez, a leading developer of OpenCV
OpenCV runs on the following desktop operating systems:
Windows, Linux, macOS, FreeBSD, NetBSD, OpenBSD.
OpenCV runs on the following mobile operating systems: Android, iOS, Maemo,BlackBerry 10. The
user can get official releases from SourceForge or take the latest sources from GitHub.
Before going to our topic first we have to pay our sincere attention to PYTHON 2
So It's time to change our code to PYTHON 3
INSTALLATION
windows
• Python 3+ https://www.python.org/downloads/
• After installing the python and set path and install pip
• After installing pip, Open CMD as Adminstrator
•we need to install Frequently used Libraries before we install opencv : Numpy, Matplotlib, Scipy
• All we need to just type these commands
>>>pip install numpy
>>>pip install matplotlib
>>>pip install scipy
INSTALLATION
• Or try Anaconda (Python 3+ popular libraries) https://www.continuum.io/downloads
• Download latest OpenCV release from sourceforge site and click to extract it
(http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.4.6/OpenCV-2.4.6.0.exe/download)
• Goto opencv/build/python/3.5 folder(your respective version folder).
• Copy cv2.pyd to C:/Python35/lib/site-packeges.
• Open Python IDLE and type following codes in Python terminal.
>>>import cv2
•If cv2 imported successfully than your installation is completed
INSTALLATION
MAC
• Python 3.5 or 3.6 or Anaconda https://www.python.org/downloads/
https://www.continuum.io/downloads
• Frequently used Libraries : Numpy, Matplotlib, Scipy in Terminals : pip3 install –U numpy scipy
matplotlib (for Python 3.X)
• Download openCV http://opencv.org/downloads.html
• Install Xcode https://developer.apple.com/xcode/
• Install Cmake https://cmake.org/download/
• Build openCV for Python http://luigolas.com/blog/2014/09/15/install-opencv3-with- python-3-mac-
osx/
Read/Show Image
• In these we just interact with the opencv by giving
image as input
Code-
import cv2
img = cv2.imread('C:/Users/91741/Desktop/projects
python/seminar ppt/ammababoi.jpg')
cv2.imshow('sample image',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Output
Code
import cv2
import numpy as np
cap = cv2.VideoCapture('chaplin.mp4')
if (cap.isOpened()== False):
print("Error opening video stream or file")
while(cap.isOpened()):
ret, frame = cap.read()
if ret == True:
cv2.imshow('Frame',frame)
if cv2.waitKey(25) & 0xFF == ord('q'):
break
else:
break
cap.release()
cv2.destroyAllWindows()
Read/Show Video
• In these we just interact with the opencv by giving Video as
input
• In these we need to use NUMPY package
ACCESS WEB CAM
• In opencv main component is camera so now we look at the simple code for open webcam using
python code
>>> import cv2
cap = cv2.VideoCapture(0)
if not cap.isOpened():
raise IOError("Cannot open webcam")
while True:
ret, frame = cap.read()
frame = cv2.resize(frame, None, fx=1.5, fy=1.5, interpolation=cv2.INTER_AREA)
cv2.imshow('Input', frame)
c = cv2.waitKey(1)
if c == 27:
break
cap.release()
cv2.destroyAllWindows()
TECHNIQUES AND METHODS
• In opencv we have so many techniques some of them are
 Changing Color Spaces
 Resizing Images
 Image Rotation
 Image Translation
 Simple Image Thresholding
 Adaptive Thresholding
 Image Segmentation (Watershed Algorithm)
 Bitwise Operations
 Edge Detection
 Image Filtering
 Image Contours
Here we discuss about some frequently used methods
CANNY EDGE DETECTION
The Canny edge detector is an edge detection operator that uses a multi-stage algorithm to detect a
wide range of edges in images. It was developed by John F. Canny in 1986. Canny also produced a
computational theory of edge detection explaining why the technique works.
Canny edge detection is a technique to extract useful structural information from different vision
objects and dramatically reduce the amount of data to be processed. It has been widely applied in
various computer vision systems. Canny has found that the requirements for the application of edge
detection on diverse vision systems are relatively similar. Thus, an edge detection solution to address
these requirements can be implemented in a wide range of situations. The general criteria for edge
detection include:
Detection of edge with low error rate, which means that the detection should accurately catch as many
edges shown in the image as possible
CONT...
The edge point detected from the operator should accurately localize on the center of the edge.
A given edge in the image should only be marked once, and where possible, image noise should
not create false edges.
To satisfy these requirements Canny used the calculus of variations – a technique which finds the
function which optimizes a given functional. The optimal function in Canny's detector is described
by the sum of four exponential terms, but it can be approximated by the first derivative of a
Gaussian.
Among the edge detection methods developed so far, Canny edge detection algorithm is one of the
most strictly defined methods that provides good and reliable detection. Owing to its optimality to
meet with the three criteria for edge detection and the simplicity of process for implementation, it
became one of the most popular algorithms for edge detection.
Code For Canny Edge Detection for Image
import cv2
import numpy as np
from matplotlib import pyplot as plt
img = cv2.imread('Brahmi.jpg',0)
edges = cv2.Canny(img,100,200)
plt.subplot(121),plt.imshow(img,cmap = 'gray')
plt.title('Original Image'), plt.xticks([]), plt.yticks([])
plt.subplot(122),plt.imshow(edges,cmap = 'gray')
plt.title('Canny Edge Image'), plt.xticks([]), plt.yticks([])
plt.show()
Output
Code For Canny Edge Detection for Live Video
import cv2
import numpy as np
cap = cv2.VideoCapture(0)
while(1):
frame = cap.read()
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
lower_red = np.array([30,150,50])
upper_red = np.array([255,255,180])
mask = cv2.inRange(hsv, lower_red, upper_red)
res = cv2.bitwise_and(frame,frame, mask= mask)
laplacian = cv2.Laplacian(frame,cv2.CV_64F)
sobelx = cv2.Sobel(frame,cv2.CV_64F,1,0,ksize=5)
sobely = cv2.Sobel(frame,cv2.CV_64F,0,1,ksize=5)
cv2.imshow('Original',frame)
cv2.imshow('Mask',mask)
cv2.imshow('laplacian',laplacian)
cv2.imshow('sobelx',sobelx)
cv2.imshow('sobely',sobely)
k = cv2.waitKey(5) & 0xFF
if k == 27:
break
cv2.destroyAllWindows()
cap.release()
Image Filtering
In order to filter you have a few options.
Generally, you are probably going to convert
your colors to HSV, which is "Hue
Saturation Value." This can help you actually
pinpoint a more specific color, based on hue
and saturation ranges, with a variance of
value, for example. If you wanted, you could
actually produce filters based on BGR
values, but this would be a bit more difficult.
If you're having a hard time visualizing HSV,
don't feel silly, check out the Wikipedia page
on HSV, there is a very useful graphic there
for you to visualize it. Hue for color,
saturation for the strength of the color, and
value for light is how I would best describe
it personally. Now let's hop in.
Code For Image Filtering
import cv2
import numpy as np
cap = cv2.VideoCapture(0)
while(1):
frame = cap.read()
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
lower_red = np.array([30,150,50])
upper_red = np.array([255,255,180])
mask = cv2.inRange(hsv, lower_red, upper_red)
res = cv2.bitwise_and(frame,frame, mask= mask)
cv2.imshow('frame',frame)
cv2.imshow('mask',mask)
cv2.imshow('res',res)
k = cv2.waitKey(5) & 0xFF
if k == 27:
break
cv2.destroyAllWindows()
cap.release()
Output for Image Filtering
APPLICATIONS
OpenCV is being used for a very wide range of applications which include:
• Road Lane Detection Image Processing
• Street view image stitching
• Automated inspection and surveillance
• Robot and driver-less car navigation and control
• Medical image analysis
• Video/image search and retrieval
• Movies - 3D structure from motion
• Interactive art installations
ALTERNATIVES
Like Opencv we have different alternative tools/Libraries some of them are
• SimpleCV
• Accord.NET Framework
• ImageUltimate
• BoofCV
• libdwt
• FastCV Computer Vision
• LeptonicaSharp
END WORDS
OpenCV is truly an all emcompassing library for computer vision tasks. I just tried out all the
above codes on my machine – the best way to learn computer vision is by applying it on your
own. I encourage you to build your own applications and experiment with OpenCV as much as
you can if you intrested.
OpenCV is continually adding new modules for latest algorithms from Machine learning, do
check out their Github repository and get familiar with implementation.
THANK YOU
UR's
Ethi$h Kumar Keerthi

More Related Content

DOCX
Vipul divyanshu documentation on Kinect and Motion Tracking
PDF
J2me Crash Course
PPTX
OSGi Versioning And Testing
PDF
Introduction to OpenCV 3.x (with Java)
PDF
Introduction to TensorFlow and OpenCV libraries
PPTX
PDF
Intel IPP Samples for Windows - error correction
PDF
Image Detection and Count Using Open Computer Vision (Opencv)
Vipul divyanshu documentation on Kinect and Motion Tracking
J2me Crash Course
OSGi Versioning And Testing
Introduction to OpenCV 3.x (with Java)
Introduction to TensorFlow and OpenCV libraries
Intel IPP Samples for Windows - error correction
Image Detection and Count Using Open Computer Vision (Opencv)

Similar to Opencv (20)

PDF
OpenCV (Open source computer vision)
PDF
Automatic License Plate Recognition using OpenCV
PDF
Automatic License Plate Recognition using OpenCV
PPTX
OpenCV+Android.pptx
PDF
Implementation of embedded arm9 platform using qt and open cv for human upper...
PDF
Ijsrdv1 i4049
PDF
License Plate Recognition System using Python and OpenCV
PPTX
502021435-12345678Minor-Project-Ppt.pptx
PDF
An AI Based ATM Intelligent Security System using Open CV and YOLO
PDF
"The OpenCV Open Source Computer Vision Library: What’s New and What’s Coming...
PPTX
OpenCV @ Droidcon 2012
PDF
Starting with OpenCV on i.MX 6 Processors
PPTX
Digit recognizer
PPT
Open Cv – An Introduction To The Vision
DOCX
Kinect installation guide
PPTX
Presentation1.2.pptx
PDF
Matteo Valoriani, Antimo Musone - The Future of Factory - Codemotion Rome 2019
PDF
Monteverdi 2.0 - Remote sensing software for Pleiades images analysis
 
PDF
Ionic debugger
PDF
Machine vision Application
OpenCV (Open source computer vision)
Automatic License Plate Recognition using OpenCV
Automatic License Plate Recognition using OpenCV
OpenCV+Android.pptx
Implementation of embedded arm9 platform using qt and open cv for human upper...
Ijsrdv1 i4049
License Plate Recognition System using Python and OpenCV
502021435-12345678Minor-Project-Ppt.pptx
An AI Based ATM Intelligent Security System using Open CV and YOLO
"The OpenCV Open Source Computer Vision Library: What’s New and What’s Coming...
OpenCV @ Droidcon 2012
Starting with OpenCV on i.MX 6 Processors
Digit recognizer
Open Cv – An Introduction To The Vision
Kinect installation guide
Presentation1.2.pptx
Matteo Valoriani, Antimo Musone - The Future of Factory - Codemotion Rome 2019
Monteverdi 2.0 - Remote sensing software for Pleiades images analysis
 
Ionic debugger
Machine vision Application
Ad

Recently uploaded (20)

PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PDF
737-MAX_SRG.pdf student reference guides
PPTX
UNIT - 3 Total quality Management .pptx
PDF
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
PPTX
Fundamentals of Mechanical Engineering.pptx
PPTX
introduction to high performance computing
PDF
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
PDF
PPT on Performance Review to get promotions
PDF
Exploratory_Data_Analysis_Fundamentals.pdf
PPT
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
PDF
Categorization of Factors Affecting Classification Algorithms Selection
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PDF
Visual Aids for Exploratory Data Analysis.pdf
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
Information Storage and Retrieval Techniques Unit III
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PDF
COURSE DESCRIPTOR OF SURVEYING R24 SYLLABUS
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PPTX
Nature of X-rays, X- Ray Equipment, Fluoroscopy
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
737-MAX_SRG.pdf student reference guides
UNIT - 3 Total quality Management .pptx
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
Fundamentals of Mechanical Engineering.pptx
introduction to high performance computing
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
PPT on Performance Review to get promotions
Exploratory_Data_Analysis_Fundamentals.pdf
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
Categorization of Factors Affecting Classification Algorithms Selection
Automation-in-Manufacturing-Chapter-Introduction.pdf
Visual Aids for Exploratory Data Analysis.pdf
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
UNIT 4 Total Quality Management .pptx
Information Storage and Retrieval Techniques Unit III
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
COURSE DESCRIPTOR OF SURVEYING R24 SYLLABUS
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
Nature of X-rays, X- Ray Equipment, Fluoroscopy
Ad

Opencv

  • 1. CAMERA VISION IN PYTHON USINGOPENCV INTRODUCTION TO PresentedBy Ethi$h Kumar Keerthi 17K65A0501
  • 2. List of Contents  INTRODUCTION  HISTORY  INSTALLATION  READ/OPEN IMAGE  ACCESS WEB CAM  TECHNIQUES  APPLICATIONS  ALTERNATIVES
  • 3. INTRODUCTION OpenCV (Open source computer vision) is a library of programming functions mainly aimed at real- time computer vision. “Computer Vision is a field of deep learning that enables machines to see, identify and process images like humans”. Computer vision is one of the hottest fields in the industry right now. You can expect plenty of job openings to come up in the next 2-4 years. The question then is – are you ready to take advantage of these opportunities?
  • 4. CONT... Take a moment to ponder this – which applications or products come to your mind when you think of computer vision? The list is HUGE. We use some of them everyday! Features like unlocking our phones using face recognition, our smartphone cameras, self-driving cars – computer vision is everywhere
  • 5. History Officially launched in 1999 the OpenCV project was initially an Intel Research initiative to advance CPU-intensive applications, part of a series of projects including real-time ray tracing and 3D display walls.The main contributors to the project included a number of optimization experts in Intel Russia, as well as Intel's Performance Library Team. In the early days of OpenCV, the goals of the project were described as: Advance vision research by providing not only open but also optimized code for basic vision infrastructure. No more reinventing the wheel. Disseminate vision knowledge by providing a common infrastructure that developers could build on, so that code would be more readily readable and transferable. Advance vision-based commercial applications by making portable, performance-optimized code available for free – with a license that did not require code to be open or free itself. The first alpha version of OpenCV was released to the public at the IEEE Conference on Computer Vision and Pattern Recognition in 2000, and five betas were released between 2001 and 2005. The first 1.0 version was released in 2006. A version 1.1 "pre-release" was released in October 2008.
  • 6. CONT... The second major release of the OpenCV was in October 2009. OpenCV 2 includes major changes to the C++ interface, aiming at easier, more type-safe patterns, new functions, and better implementations for existing ones in terms of performance (especially on multi-core systems). Official releases now occur every six months and development is now done by an independent Russian team supported by commercial corporations.In August 2012, support for OpenCV was taken over by a non-profit foundation OpenCV.org, which maintains a developer.On May 2016, Intel signed an agreement to acquire Itseez, a leading developer of OpenCV OpenCV runs on the following desktop operating systems: Windows, Linux, macOS, FreeBSD, NetBSD, OpenBSD. OpenCV runs on the following mobile operating systems: Android, iOS, Maemo,BlackBerry 10. The user can get official releases from SourceForge or take the latest sources from GitHub.
  • 7. Before going to our topic first we have to pay our sincere attention to PYTHON 2 So It's time to change our code to PYTHON 3
  • 8. INSTALLATION windows • Python 3+ https://www.python.org/downloads/ • After installing the python and set path and install pip • After installing pip, Open CMD as Adminstrator •we need to install Frequently used Libraries before we install opencv : Numpy, Matplotlib, Scipy • All we need to just type these commands >>>pip install numpy >>>pip install matplotlib >>>pip install scipy
  • 9. INSTALLATION • Or try Anaconda (Python 3+ popular libraries) https://www.continuum.io/downloads • Download latest OpenCV release from sourceforge site and click to extract it (http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.4.6/OpenCV-2.4.6.0.exe/download) • Goto opencv/build/python/3.5 folder(your respective version folder). • Copy cv2.pyd to C:/Python35/lib/site-packeges. • Open Python IDLE and type following codes in Python terminal. >>>import cv2 •If cv2 imported successfully than your installation is completed
  • 10. INSTALLATION MAC • Python 3.5 or 3.6 or Anaconda https://www.python.org/downloads/ https://www.continuum.io/downloads • Frequently used Libraries : Numpy, Matplotlib, Scipy in Terminals : pip3 install –U numpy scipy matplotlib (for Python 3.X) • Download openCV http://opencv.org/downloads.html • Install Xcode https://developer.apple.com/xcode/ • Install Cmake https://cmake.org/download/ • Build openCV for Python http://luigolas.com/blog/2014/09/15/install-opencv3-with- python-3-mac- osx/
  • 11. Read/Show Image • In these we just interact with the opencv by giving image as input Code- import cv2 img = cv2.imread('C:/Users/91741/Desktop/projects python/seminar ppt/ammababoi.jpg') cv2.imshow('sample image',img) cv2.waitKey(0) cv2.destroyAllWindows() Output
  • 12. Code import cv2 import numpy as np cap = cv2.VideoCapture('chaplin.mp4') if (cap.isOpened()== False): print("Error opening video stream or file") while(cap.isOpened()): ret, frame = cap.read() if ret == True: cv2.imshow('Frame',frame) if cv2.waitKey(25) & 0xFF == ord('q'): break else: break cap.release() cv2.destroyAllWindows() Read/Show Video • In these we just interact with the opencv by giving Video as input • In these we need to use NUMPY package
  • 13. ACCESS WEB CAM • In opencv main component is camera so now we look at the simple code for open webcam using python code >>> import cv2 cap = cv2.VideoCapture(0) if not cap.isOpened(): raise IOError("Cannot open webcam") while True: ret, frame = cap.read() frame = cv2.resize(frame, None, fx=1.5, fy=1.5, interpolation=cv2.INTER_AREA) cv2.imshow('Input', frame) c = cv2.waitKey(1) if c == 27: break cap.release() cv2.destroyAllWindows()
  • 14. TECHNIQUES AND METHODS • In opencv we have so many techniques some of them are  Changing Color Spaces  Resizing Images  Image Rotation  Image Translation  Simple Image Thresholding  Adaptive Thresholding  Image Segmentation (Watershed Algorithm)  Bitwise Operations  Edge Detection  Image Filtering  Image Contours Here we discuss about some frequently used methods
  • 15. CANNY EDGE DETECTION The Canny edge detector is an edge detection operator that uses a multi-stage algorithm to detect a wide range of edges in images. It was developed by John F. Canny in 1986. Canny also produced a computational theory of edge detection explaining why the technique works. Canny edge detection is a technique to extract useful structural information from different vision objects and dramatically reduce the amount of data to be processed. It has been widely applied in various computer vision systems. Canny has found that the requirements for the application of edge detection on diverse vision systems are relatively similar. Thus, an edge detection solution to address these requirements can be implemented in a wide range of situations. The general criteria for edge detection include: Detection of edge with low error rate, which means that the detection should accurately catch as many edges shown in the image as possible
  • 16. CONT... The edge point detected from the operator should accurately localize on the center of the edge. A given edge in the image should only be marked once, and where possible, image noise should not create false edges. To satisfy these requirements Canny used the calculus of variations – a technique which finds the function which optimizes a given functional. The optimal function in Canny's detector is described by the sum of four exponential terms, but it can be approximated by the first derivative of a Gaussian. Among the edge detection methods developed so far, Canny edge detection algorithm is one of the most strictly defined methods that provides good and reliable detection. Owing to its optimality to meet with the three criteria for edge detection and the simplicity of process for implementation, it became one of the most popular algorithms for edge detection.
  • 17. Code For Canny Edge Detection for Image import cv2 import numpy as np from matplotlib import pyplot as plt img = cv2.imread('Brahmi.jpg',0) edges = cv2.Canny(img,100,200) plt.subplot(121),plt.imshow(img,cmap = 'gray') plt.title('Original Image'), plt.xticks([]), plt.yticks([]) plt.subplot(122),plt.imshow(edges,cmap = 'gray') plt.title('Canny Edge Image'), plt.xticks([]), plt.yticks([]) plt.show() Output
  • 18. Code For Canny Edge Detection for Live Video import cv2 import numpy as np cap = cv2.VideoCapture(0) while(1): frame = cap.read() hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) lower_red = np.array([30,150,50]) upper_red = np.array([255,255,180]) mask = cv2.inRange(hsv, lower_red, upper_red) res = cv2.bitwise_and(frame,frame, mask= mask) laplacian = cv2.Laplacian(frame,cv2.CV_64F) sobelx = cv2.Sobel(frame,cv2.CV_64F,1,0,ksize=5) sobely = cv2.Sobel(frame,cv2.CV_64F,0,1,ksize=5) cv2.imshow('Original',frame) cv2.imshow('Mask',mask) cv2.imshow('laplacian',laplacian) cv2.imshow('sobelx',sobelx) cv2.imshow('sobely',sobely) k = cv2.waitKey(5) & 0xFF if k == 27: break cv2.destroyAllWindows() cap.release()
  • 19. Image Filtering In order to filter you have a few options. Generally, you are probably going to convert your colors to HSV, which is "Hue Saturation Value." This can help you actually pinpoint a more specific color, based on hue and saturation ranges, with a variance of value, for example. If you wanted, you could actually produce filters based on BGR values, but this would be a bit more difficult. If you're having a hard time visualizing HSV, don't feel silly, check out the Wikipedia page on HSV, there is a very useful graphic there for you to visualize it. Hue for color, saturation for the strength of the color, and value for light is how I would best describe it personally. Now let's hop in. Code For Image Filtering import cv2 import numpy as np cap = cv2.VideoCapture(0) while(1): frame = cap.read() hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) lower_red = np.array([30,150,50]) upper_red = np.array([255,255,180]) mask = cv2.inRange(hsv, lower_red, upper_red) res = cv2.bitwise_and(frame,frame, mask= mask) cv2.imshow('frame',frame) cv2.imshow('mask',mask) cv2.imshow('res',res) k = cv2.waitKey(5) & 0xFF if k == 27: break cv2.destroyAllWindows() cap.release()
  • 20. Output for Image Filtering
  • 21. APPLICATIONS OpenCV is being used for a very wide range of applications which include: • Road Lane Detection Image Processing • Street view image stitching • Automated inspection and surveillance • Robot and driver-less car navigation and control • Medical image analysis • Video/image search and retrieval • Movies - 3D structure from motion • Interactive art installations
  • 22. ALTERNATIVES Like Opencv we have different alternative tools/Libraries some of them are • SimpleCV • Accord.NET Framework • ImageUltimate • BoofCV • libdwt • FastCV Computer Vision • LeptonicaSharp
  • 23. END WORDS OpenCV is truly an all emcompassing library for computer vision tasks. I just tried out all the above codes on my machine – the best way to learn computer vision is by applying it on your own. I encourage you to build your own applications and experiment with OpenCV as much as you can if you intrested. OpenCV is continually adding new modules for latest algorithms from Machine learning, do check out their Github repository and get familiar with implementation.