SlideShare une entreprise Scribd logo
1  sur  35
Télécharger pour lire hors ligne
@DylanSeychell
Introduction to
Computer Vision
using OpenCV
Dylan Seychell
I am Dylan Seychell
Academic and Software Engineer
AI, UX and Computer Vision
@DylanSeychell
Hello!
2
@DylanSeychell
Presentation Overview
What is Computer Vision?
What is OpenCV?
Workshop:
Image Acquisition
Image Processing
Image Analysis/Understanding
3
Computer Vision
Making computers get a high-level
understanding from images and videos.
4
@DylanSeychell
Stages of Computer Vision
5
Acquisition UnderstandingProcessing
Covered in this session
@DylanSeychell
OpenCV - enabling computer vision
Open Source Computer Vision library
Cross-platform
Free for use under open source BSD license
Can be easily used with Java, Python, C and C++
Supports Machine Learning libraries such as
TensorFlow and Caffe.
https://opencv.org
6
@DylanSeychell
This Session:
We’ll be using OpenCV with Python
New to Python? Check these slides
https://www.slideshare.net/dylsey/introduction-to-python-80851217
7
@DylanSeychell
CodeLab Part 1: Acquisition of Image Data
8
@DylanSeychell
Test the library:
In terminal/CMD type python
>>> import cv2
>>>
9
@DylanSeychell
Importing an image
Create a Python module and write the following code:
import cv2
img = cv2.imread('duomo.jpg',1)
cv2.imshow("Output Window", img)
cv2.waitKey()
This code imports an image and outputs it to a window and waits for any user
keyboard input to terminate.
10
@DylanSeychell
cv2.imread() function
This function is used to load an image and store it into a variable
img = cv2.imread('duomo.jpg',1)
This function accepts 2 parameters:
1. The filename of the image
2. Colour Approach:
a. 1: Colour, neglecting transparency
b. 0: Greyscale
c. -1: Colour together with the alpha channel
11
@DylanSeychell
Different output for different imread() arguments
12
img = cv2.imread('duomo.jpg',1) img = cv2.imread('duomo.jpg',0)
@DylanSeychell
cv2.imshow() function
This function is used to display an image in a window.
cv2.imshow("Output Window", img)
This function accepts 2 parameters:
1. The name of the output window
2. The image to be displayed in the output window
NB 1: The window automatically fits the image size.
NB 2: Matplotlib can be used as an alternative
13
@DylanSeychell
cv2.waitKey() function
This is a keyboard binding function
cv2.waitKey()
A single argument value in milliseconds:
1. 0 or no argument: wait indefinitely for keyboard interrupt
2. Any other value: display the window for the duration of that value in ms
This function returns the ASCII value of the key pressed and if stored in a
variable, it can be used to perform subsequent logical operations.
14
@DylanSeychell
Using the webcam feed
cap = cv2.VideoCapture(0)
while(True):
# Capture frame-by-frame
ret, frame = cap.read()
# Our operations on the frame come here
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
# Display the resulting frame
cv2.imshow('frame',gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# When everything done, release the capture
cap.release()
15
@DylanSeychell
cv2.VideoCapture() Object
The video capture object allows us to manipulate captured frames from a
camera.
cap = cv2.VideoCapture(0)
The argument is either the video filename or camera index, 0 for webcam.
Allows the handling of each frame.
After being used, the capture has to be released:
cap.release()
16
@DylanSeychell
Importing a video
cap = cv2.VideoCapture('vtest.avi')
while(cap.isOpened()): #returns true when there is another frame to process
ret, frame = cap.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imshow('frame',gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
17
@DylanSeychell
CodeLab Part 2: Image Processing
18
@DylanSeychell
Create a new module and initialise it
import cv2
img = cv2.imread('duomo.jpg',0)
##Our Image Processing code goes here
cv2.imshow("Output Window", img)
cv2.waitKey()
19
@DylanSeychell
Image Type
Try printing these values:
print (type(img))
This will return <type 'numpy.ndarray'>
Therefore, we’d deal with a numpy array
20
@DylanSeychell
Image Shape
Try printing these values:
img = cv2.imread('duomo.jpg',0)
print (type(img))
print (img)
[[22 22 22 ..., 23 23 24]
[22 22 22 ..., 23 23 23]
[22 22 22 ..., 23 23 23]
...,
[13 13 13 ..., 5 6 6]
[13 13 13 ..., 11 11 10]
[13 13 13 ..., 12 12 10]]
21
Greyscale
@DylanSeychell
Try the same thing with a coloured image
22
@DylanSeychell
Slicing Image Channels (Colours)
Load a coloured image and set unwanted channels to zero
img = cv2.imread("duomo.jpg", 1)
img[:,:,2] = 0 #red
img[:,:,1] = 0 #green
img[:,:,0] #blue
cv2.imshow("Output", img) #returns the blue channel
23
@DylanSeychell
Slicing by colour channel.
24
img[:,:,2] = 0 #red
img[:,:,1] = 0 #green
img[:,:,0] #blue
img[:,:,2] #red
img[:,:,1] = 0 #green
img[:,:,0] = 0 #blue
img[:,:,2] = 0 #red
img[:,:,1] #green
img[:,:,0] = 0 #blue
@DylanSeychell
Blurring images in OpenCV
The blur function using average values
blur = cv2.blur(img,(5,5))
This method accepts 2 arguments:
1. The source image
2. A tuple with the size of the box filter
25
@DylanSeychell
Simple blurring using OpenCV.
26
blur = cv2.blur(img,(10,10)) blur = cv2.blur(img,(5,5))
@DylanSeychell
Detecting Edges
Using Canny edge detection:
● Removes the noise using a Gaussian Filter
● Finds intensity gradient of the image
● Non-maximum suppression (remove unwanted pixels)
● Hysteresis Thresholding (difference between min and max values)
27
@DylanSeychell
Canny Edge Detection in OpenCV
edges = cv2.Canny(img,100,200)
This method accepts 3 arguments:
1. The source image
2. Min value
3. Max value
28
@DylanSeychell
Different minVal and maxVal values
29
edges = cv2.Canny(img,50,60) edges = cv2.Canny(img,150,300)
@DylanSeychell
Choosing a region of interest
An inbuilt function to select a region of interest:
fromCenter = False
r = cv2.selectROI(img, fromCenter)
Arguments:
1. The source image
2. Flag to choose the origin of the bounding box
30
@DylanSeychell
Using the resultant RoI
Save the resultant RoI into another image
r = cv2.selectROI(img, fromCenter)
imCropT = img[int(r[1]):int(r[1]+r[3]), int(r[0]):int(r[0]+r[2])]
Cropping the image using Numpy array slicing in the form:
crop= img[yoffset:-yoffset, xoffset:-xoffset]
31
@DylanSeychell
Selecting a RoI and displaying it
32
r = cv2.selectROI(img, fromCenter)
imCropT = img[int(r[1]):int(r[1]+r[3]),
int(r[0]):int(r[0]+r[2])]
cv2.imshow("Cropped", imCropT)
@DylanSeychell
Part 3: Analysis
This is a specialised field also known as Artificial
Vision. More resources related to this field will follow.
33
@DylanSeychell
Merging Computer Vision and AI.
34
Image to TextObject Detection & Classification
@DylanSeychell
Thank you!
35

Contenu connexe

Tendances

openCV with python
openCV with pythonopenCV with python
openCV with pythonWei-Wen Hsu
 
OpenCV 3.0 - Latest news and the Roadmap
OpenCV 3.0 - Latest news and the RoadmapOpenCV 3.0 - Latest news and the Roadmap
OpenCV 3.0 - Latest news and the RoadmapEugene Khvedchenya
 
Object detection with deep learning
Object detection with deep learningObject detection with deep learning
Object detection with deep learningSushant Shrivastava
 
[PR12] You Only Look Once (YOLO): Unified Real-Time Object Detection
[PR12] You Only Look Once (YOLO): Unified Real-Time Object Detection[PR12] You Only Look Once (YOLO): Unified Real-Time Object Detection
[PR12] You Only Look Once (YOLO): Unified Real-Time Object DetectionTaegyun Jeon
 
Support Vector Machines Simply
Support Vector Machines SimplySupport Vector Machines Simply
Support Vector Machines SimplyEmad Nabil
 
Semantic segmentation with Convolutional Neural Network Approaches
Semantic segmentation with Convolutional Neural Network ApproachesSemantic segmentation with Convolutional Neural Network Approaches
Semantic segmentation with Convolutional Neural Network ApproachesFellowship at Vodafone FutureLab
 
Convolutional Neural Network Models - Deep Learning
Convolutional Neural Network Models - Deep LearningConvolutional Neural Network Models - Deep Learning
Convolutional Neural Network Models - Deep LearningMohamed Loey
 
Introduction to object detection
Introduction to object detectionIntroduction to object detection
Introduction to object detectionBrodmann17
 
[232] TensorRT를 활용한 딥러닝 Inference 최적화
[232] TensorRT를 활용한 딥러닝 Inference 최적화[232] TensorRT를 활용한 딥러닝 Inference 최적화
[232] TensorRT를 활용한 딥러닝 Inference 최적화NAVER D2
 
Convolutional Neural Networks (CNN)
Convolutional Neural Networks (CNN)Convolutional Neural Networks (CNN)
Convolutional Neural Networks (CNN)Gaurav Mittal
 
Mask-RCNN for Instance Segmentation
Mask-RCNN for Instance SegmentationMask-RCNN for Instance Segmentation
Mask-RCNN for Instance SegmentationDat Nguyen
 
Introduction to CNN
Introduction to CNNIntroduction to CNN
Introduction to CNNShuai Zhang
 
An Introduction to Computer Vision
An Introduction to Computer VisionAn Introduction to Computer Vision
An Introduction to Computer Visionguestd1b1b5
 

Tendances (20)

openCV with python
openCV with pythonopenCV with python
openCV with python
 
OpenCV 3.0 - Latest news and the Roadmap
OpenCV 3.0 - Latest news and the RoadmapOpenCV 3.0 - Latest news and the Roadmap
OpenCV 3.0 - Latest news and the Roadmap
 
Object detection with deep learning
Object detection with deep learningObject detection with deep learning
Object detection with deep learning
 
[PR12] You Only Look Once (YOLO): Unified Real-Time Object Detection
[PR12] You Only Look Once (YOLO): Unified Real-Time Object Detection[PR12] You Only Look Once (YOLO): Unified Real-Time Object Detection
[PR12] You Only Look Once (YOLO): Unified Real-Time Object Detection
 
Yolo
YoloYolo
Yolo
 
OpenCV
OpenCVOpenCV
OpenCV
 
Support Vector Machines Simply
Support Vector Machines SimplySupport Vector Machines Simply
Support Vector Machines Simply
 
SSD: Single Shot MultiBox Detector (UPC Reading Group)
SSD: Single Shot MultiBox Detector (UPC Reading Group)SSD: Single Shot MultiBox Detector (UPC Reading Group)
SSD: Single Shot MultiBox Detector (UPC Reading Group)
 
Computer vision
Computer vision Computer vision
Computer vision
 
Python Open CV
Python Open CVPython Open CV
Python Open CV
 
Semantic segmentation with Convolutional Neural Network Approaches
Semantic segmentation with Convolutional Neural Network ApproachesSemantic segmentation with Convolutional Neural Network Approaches
Semantic segmentation with Convolutional Neural Network Approaches
 
Convolutional Neural Network Models - Deep Learning
Convolutional Neural Network Models - Deep LearningConvolutional Neural Network Models - Deep Learning
Convolutional Neural Network Models - Deep Learning
 
Yolo
YoloYolo
Yolo
 
Introduction to object detection
Introduction to object detectionIntroduction to object detection
Introduction to object detection
 
[232] TensorRT를 활용한 딥러닝 Inference 최적화
[232] TensorRT를 활용한 딥러닝 Inference 최적화[232] TensorRT를 활용한 딥러닝 Inference 최적화
[232] TensorRT를 활용한 딥러닝 Inference 최적화
 
Convolutional Neural Networks (CNN)
Convolutional Neural Networks (CNN)Convolutional Neural Networks (CNN)
Convolutional Neural Networks (CNN)
 
Cnn
CnnCnn
Cnn
 
Mask-RCNN for Instance Segmentation
Mask-RCNN for Instance SegmentationMask-RCNN for Instance Segmentation
Mask-RCNN for Instance Segmentation
 
Introduction to CNN
Introduction to CNNIntroduction to CNN
Introduction to CNN
 
An Introduction to Computer Vision
An Introduction to Computer VisionAn Introduction to Computer Vision
An Introduction to Computer Vision
 

Similaire à Introduction to Computer Vision using OpenCV

Intro_OpenCV.ppt
Intro_OpenCV.pptIntro_OpenCV.ppt
Intro_OpenCV.pptRithikRaj25
 
CE344L-200365-Lab5.pdf
CE344L-200365-Lab5.pdfCE344L-200365-Lab5.pdf
CE344L-200365-Lab5.pdfUmarMustafa13
 
Image processing for robotics
Image processing for roboticsImage processing for robotics
Image processing for roboticsSALAAMCHAUS
 
downsampling and upsampling of an image using pyramids (pyr up and pyrdown me...
downsampling and upsampling of an image using pyramids (pyr up and pyrdown me...downsampling and upsampling of an image using pyramids (pyr up and pyrdown me...
downsampling and upsampling of an image using pyramids (pyr up and pyrdown me...Saeed Ullah
 
Introduction to OpenCV (with Java)
Introduction to OpenCV (with Java)Introduction to OpenCV (with Java)
Introduction to OpenCV (with Java)Luigi De Russis
 
Open Cv 2005 Q4 Tutorial
Open Cv 2005 Q4 TutorialOpen Cv 2005 Q4 Tutorial
Open Cv 2005 Q4 Tutorialantiw
 
Color Detection & Segmentation based Invisible Cloak
Color Detection & Segmentation based Invisible CloakColor Detection & Segmentation based Invisible Cloak
Color Detection & Segmentation based Invisible CloakAviral Chaurasia
 
"The OpenCV Open Source Computer Vision Library: Latest Developments," a Pres...
"The OpenCV Open Source Computer Vision Library: Latest Developments," a Pres..."The OpenCV Open Source Computer Vision Library: Latest Developments," a Pres...
"The OpenCV Open Source Computer Vision Library: Latest Developments," a Pres...Edge AI and Vision Alliance
 
Python image processing_Python image processing.pptx
Python image processing_Python image processing.pptxPython image processing_Python image processing.pptx
Python image processing_Python image processing.pptxshashikant484397
 
aip basic open cv example
aip basic open cv exampleaip basic open cv example
aip basic open cv exampleSaeed Ullah
 
Open CV - 電腦怎麼看世界
Open CV - 電腦怎麼看世界Open CV - 電腦怎麼看世界
Open CV - 電腦怎麼看世界Tech Podcast Night
 
AIML4 CNN lab256 1hr (111-1).pdf
AIML4 CNN lab256 1hr (111-1).pdfAIML4 CNN lab256 1hr (111-1).pdf
AIML4 CNN lab256 1hr (111-1).pdfssuserb4d806
 
"Quantum" performance effects
"Quantum" performance effects"Quantum" performance effects
"Quantum" performance effectsSergey Kuksenko
 
Week2- Deep Learning Intuition.pptx
Week2- Deep Learning Intuition.pptxWeek2- Deep Learning Intuition.pptx
Week2- Deep Learning Intuition.pptxfahmi324663
 
Kinect v1+Processing workshot fabcafe_taipei
Kinect v1+Processing workshot fabcafe_taipeiKinect v1+Processing workshot fabcafe_taipei
Kinect v1+Processing workshot fabcafe_taipeiMao Wu
 
CE344L-200365-Lab6.pdf
CE344L-200365-Lab6.pdfCE344L-200365-Lab6.pdf
CE344L-200365-Lab6.pdfUmarMustafa13
 

Similaire à Introduction to Computer Vision using OpenCV (20)

Intro_OpenCV.ppt
Intro_OpenCV.pptIntro_OpenCV.ppt
Intro_OpenCV.ppt
 
CE344L-200365-Lab5.pdf
CE344L-200365-Lab5.pdfCE344L-200365-Lab5.pdf
CE344L-200365-Lab5.pdf
 
Image processing for robotics
Image processing for roboticsImage processing for robotics
Image processing for robotics
 
downsampling and upsampling of an image using pyramids (pyr up and pyrdown me...
downsampling and upsampling of an image using pyramids (pyr up and pyrdown me...downsampling and upsampling of an image using pyramids (pyr up and pyrdown me...
downsampling and upsampling of an image using pyramids (pyr up and pyrdown me...
 
Introduction to OpenCV (with Java)
Introduction to OpenCV (with Java)Introduction to OpenCV (with Java)
Introduction to OpenCV (with Java)
 
Open Cv 2005 Q4 Tutorial
Open Cv 2005 Q4 TutorialOpen Cv 2005 Q4 Tutorial
Open Cv 2005 Q4 Tutorial
 
OpenCV+Android.pptx
OpenCV+Android.pptxOpenCV+Android.pptx
OpenCV+Android.pptx
 
Color Detection & Segmentation based Invisible Cloak
Color Detection & Segmentation based Invisible CloakColor Detection & Segmentation based Invisible Cloak
Color Detection & Segmentation based Invisible Cloak
 
"The OpenCV Open Source Computer Vision Library: Latest Developments," a Pres...
"The OpenCV Open Source Computer Vision Library: Latest Developments," a Pres..."The OpenCV Open Source Computer Vision Library: Latest Developments," a Pres...
"The OpenCV Open Source Computer Vision Library: Latest Developments," a Pres...
 
Python image processing_Python image processing.pptx
Python image processing_Python image processing.pptxPython image processing_Python image processing.pptx
Python image processing_Python image processing.pptx
 
aip basic open cv example
aip basic open cv exampleaip basic open cv example
aip basic open cv example
 
Log polar coordinates
Log polar coordinatesLog polar coordinates
Log polar coordinates
 
Open CV - 電腦怎麼看世界
Open CV - 電腦怎麼看世界Open CV - 電腦怎麼看世界
Open CV - 電腦怎麼看世界
 
AIML4 CNN lab256 1hr (111-1).pdf
AIML4 CNN lab256 1hr (111-1).pdfAIML4 CNN lab256 1hr (111-1).pdf
AIML4 CNN lab256 1hr (111-1).pdf
 
Python OpenCV Real Time projects
Python OpenCV Real Time projectsPython OpenCV Real Time projects
Python OpenCV Real Time projects
 
"Quantum" performance effects
"Quantum" performance effects"Quantum" performance effects
"Quantum" performance effects
 
Week2- Deep Learning Intuition.pptx
Week2- Deep Learning Intuition.pptxWeek2- Deep Learning Intuition.pptx
Week2- Deep Learning Intuition.pptx
 
MAJOR PROJECT
MAJOR PROJECT MAJOR PROJECT
MAJOR PROJECT
 
Kinect v1+Processing workshot fabcafe_taipei
Kinect v1+Processing workshot fabcafe_taipeiKinect v1+Processing workshot fabcafe_taipei
Kinect v1+Processing workshot fabcafe_taipei
 
CE344L-200365-Lab6.pdf
CE344L-200365-Lab6.pdfCE344L-200365-Lab6.pdf
CE344L-200365-Lab6.pdf
 

Dernier

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 

Dernier (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

Introduction to Computer Vision using OpenCV

  • 2. I am Dylan Seychell Academic and Software Engineer AI, UX and Computer Vision @DylanSeychell Hello! 2
  • 3. @DylanSeychell Presentation Overview What is Computer Vision? What is OpenCV? Workshop: Image Acquisition Image Processing Image Analysis/Understanding 3
  • 4. Computer Vision Making computers get a high-level understanding from images and videos. 4
  • 5. @DylanSeychell Stages of Computer Vision 5 Acquisition UnderstandingProcessing Covered in this session
  • 6. @DylanSeychell OpenCV - enabling computer vision Open Source Computer Vision library Cross-platform Free for use under open source BSD license Can be easily used with Java, Python, C and C++ Supports Machine Learning libraries such as TensorFlow and Caffe. https://opencv.org 6
  • 7. @DylanSeychell This Session: We’ll be using OpenCV with Python New to Python? Check these slides https://www.slideshare.net/dylsey/introduction-to-python-80851217 7
  • 8. @DylanSeychell CodeLab Part 1: Acquisition of Image Data 8
  • 9. @DylanSeychell Test the library: In terminal/CMD type python >>> import cv2 >>> 9
  • 10. @DylanSeychell Importing an image Create a Python module and write the following code: import cv2 img = cv2.imread('duomo.jpg',1) cv2.imshow("Output Window", img) cv2.waitKey() This code imports an image and outputs it to a window and waits for any user keyboard input to terminate. 10
  • 11. @DylanSeychell cv2.imread() function This function is used to load an image and store it into a variable img = cv2.imread('duomo.jpg',1) This function accepts 2 parameters: 1. The filename of the image 2. Colour Approach: a. 1: Colour, neglecting transparency b. 0: Greyscale c. -1: Colour together with the alpha channel 11
  • 12. @DylanSeychell Different output for different imread() arguments 12 img = cv2.imread('duomo.jpg',1) img = cv2.imread('duomo.jpg',0)
  • 13. @DylanSeychell cv2.imshow() function This function is used to display an image in a window. cv2.imshow("Output Window", img) This function accepts 2 parameters: 1. The name of the output window 2. The image to be displayed in the output window NB 1: The window automatically fits the image size. NB 2: Matplotlib can be used as an alternative 13
  • 14. @DylanSeychell cv2.waitKey() function This is a keyboard binding function cv2.waitKey() A single argument value in milliseconds: 1. 0 or no argument: wait indefinitely for keyboard interrupt 2. Any other value: display the window for the duration of that value in ms This function returns the ASCII value of the key pressed and if stored in a variable, it can be used to perform subsequent logical operations. 14
  • 15. @DylanSeychell Using the webcam feed cap = cv2.VideoCapture(0) while(True): # Capture frame-by-frame ret, frame = cap.read() # Our operations on the frame come here gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) # Display the resulting frame cv2.imshow('frame',gray) if cv2.waitKey(1) & 0xFF == ord('q'): break # When everything done, release the capture cap.release() 15
  • 16. @DylanSeychell cv2.VideoCapture() Object The video capture object allows us to manipulate captured frames from a camera. cap = cv2.VideoCapture(0) The argument is either the video filename or camera index, 0 for webcam. Allows the handling of each frame. After being used, the capture has to be released: cap.release() 16
  • 17. @DylanSeychell Importing a video cap = cv2.VideoCapture('vtest.avi') while(cap.isOpened()): #returns true when there is another frame to process ret, frame = cap.read() gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) cv2.imshow('frame',gray) if cv2.waitKey(1) & 0xFF == ord('q'): break cap.release() 17
  • 18. @DylanSeychell CodeLab Part 2: Image Processing 18
  • 19. @DylanSeychell Create a new module and initialise it import cv2 img = cv2.imread('duomo.jpg',0) ##Our Image Processing code goes here cv2.imshow("Output Window", img) cv2.waitKey() 19
  • 20. @DylanSeychell Image Type Try printing these values: print (type(img)) This will return <type 'numpy.ndarray'> Therefore, we’d deal with a numpy array 20
  • 21. @DylanSeychell Image Shape Try printing these values: img = cv2.imread('duomo.jpg',0) print (type(img)) print (img) [[22 22 22 ..., 23 23 24] [22 22 22 ..., 23 23 23] [22 22 22 ..., 23 23 23] ..., [13 13 13 ..., 5 6 6] [13 13 13 ..., 11 11 10] [13 13 13 ..., 12 12 10]] 21 Greyscale
  • 22. @DylanSeychell Try the same thing with a coloured image 22
  • 23. @DylanSeychell Slicing Image Channels (Colours) Load a coloured image and set unwanted channels to zero img = cv2.imread("duomo.jpg", 1) img[:,:,2] = 0 #red img[:,:,1] = 0 #green img[:,:,0] #blue cv2.imshow("Output", img) #returns the blue channel 23
  • 24. @DylanSeychell Slicing by colour channel. 24 img[:,:,2] = 0 #red img[:,:,1] = 0 #green img[:,:,0] #blue img[:,:,2] #red img[:,:,1] = 0 #green img[:,:,0] = 0 #blue img[:,:,2] = 0 #red img[:,:,1] #green img[:,:,0] = 0 #blue
  • 25. @DylanSeychell Blurring images in OpenCV The blur function using average values blur = cv2.blur(img,(5,5)) This method accepts 2 arguments: 1. The source image 2. A tuple with the size of the box filter 25
  • 26. @DylanSeychell Simple blurring using OpenCV. 26 blur = cv2.blur(img,(10,10)) blur = cv2.blur(img,(5,5))
  • 27. @DylanSeychell Detecting Edges Using Canny edge detection: ● Removes the noise using a Gaussian Filter ● Finds intensity gradient of the image ● Non-maximum suppression (remove unwanted pixels) ● Hysteresis Thresholding (difference between min and max values) 27
  • 28. @DylanSeychell Canny Edge Detection in OpenCV edges = cv2.Canny(img,100,200) This method accepts 3 arguments: 1. The source image 2. Min value 3. Max value 28
  • 29. @DylanSeychell Different minVal and maxVal values 29 edges = cv2.Canny(img,50,60) edges = cv2.Canny(img,150,300)
  • 30. @DylanSeychell Choosing a region of interest An inbuilt function to select a region of interest: fromCenter = False r = cv2.selectROI(img, fromCenter) Arguments: 1. The source image 2. Flag to choose the origin of the bounding box 30
  • 31. @DylanSeychell Using the resultant RoI Save the resultant RoI into another image r = cv2.selectROI(img, fromCenter) imCropT = img[int(r[1]):int(r[1]+r[3]), int(r[0]):int(r[0]+r[2])] Cropping the image using Numpy array slicing in the form: crop= img[yoffset:-yoffset, xoffset:-xoffset] 31
  • 32. @DylanSeychell Selecting a RoI and displaying it 32 r = cv2.selectROI(img, fromCenter) imCropT = img[int(r[1]):int(r[1]+r[3]), int(r[0]):int(r[0]+r[2])] cv2.imshow("Cropped", imCropT)
  • 33. @DylanSeychell Part 3: Analysis This is a specialised field also known as Artificial Vision. More resources related to this field will follow. 33
  • 34. @DylanSeychell Merging Computer Vision and AI. 34 Image to TextObject Detection & Classification