際際滷

際際滷Share a Scribd company logo
Computer Vision
Because Artificial Intelligence is the future
What it is
 Applying machine learning in order for a machine to understand a certain image
and its characteristics
 In this example, we want the machine to learn characteristics of a certain bee
(template.jpg) and pick it from a picture of a number of bees.
 Template.jpg is the template we are using to train our model
 We are picking our bee from Bee1.jpg which has a number of bees in it:
Libraries used
 import cv2 #our computer library of choice which is open cv
 import numpy as np #library for mathemitical computation
 from matplotlib import pyplot as plt
 %matplotlib inline #to have our images shown within jupyter using the above line
Reading the image and the template
 image = cv2.imread('Bee1.jpg') #the image from which we are picking the bee
 img = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
 img_copy = img.copy() #making a numpy copy of our original image so we dont
distort it when we are working on it
 template = cv2.imread('template_bee.jpg', 0) # this is the template showing us the
image of the bee we are looking for
 w, h= template.shape[::-1] #image dimensions and python starts counting from 0 and
so the -1
Matching our template with our image
 #Apply template matching using the function matchTemplate
 res = cv2.matchTemplate(img_copy,template,cv2.TM_CCOEFF_NORMED)
 min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res)
 #define the threshold; allowance for error
 threshold = 0.8
 loc = np.where(res >= threshold)
Identifying our bee
 #draw a bounding rectangle
 for pt in zip(*loc[::-1]): #for a certain point in our image
 cv2.rectangle(img_copy,pt,(pt[0]+w,pt[1]+h), (0,255,255),2) #draw our
rectangle
 plt.imshow(img_copy, cmap="gray") #this is plotting our image
Result
Our template:

More Related Content

Similar to Computer vision (20)

Swin_Transformer_Presentation_VITpp.pptx
Swin_Transformer_Presentation_VITpp.pptxSwin_Transformer_Presentation_VITpp.pptx
Swin_Transformer_Presentation_VITpp.pptx
bhaveshagrawal35
46.-Applications-of-AI-Image-Processing.pdf
46.-Applications-of-AI-Image-Processing.pdf46.-Applications-of-AI-Image-Processing.pdf
46.-Applications-of-AI-Image-Processing.pdf
monikag2613
2007 Barcelona Drupalcon Image handling
2007 Barcelona Drupalcon Image handling2007 Barcelona Drupalcon Image handling
2007 Barcelona Drupalcon Image handling
James Walker
YU CS Summer 2021 Project | TensorFlow Street Image Classification and Object...
YU CS Summer 2021 Project | TensorFlow Street Image Classification and Object...YU CS Summer 2021 Project | TensorFlow Street Image Classification and Object...
YU CS Summer 2021 Project | TensorFlow Street Image Classification and Object...
JacobSilbiger1
introductiontooopinpython-171115114144.pdf
introductiontooopinpython-171115114144.pdfintroductiontooopinpython-171115114144.pdf
introductiontooopinpython-171115114144.pdf
AhmedSalama337512
Introduction to OOP in Python
Introduction to OOP in PythonIntroduction to OOP in Python
Introduction to OOP in Python
Aleksander Fabijan
Apple Machine Learning
Apple Machine LearningApple Machine Learning
Apple Machine Learning
Denise Nepraunig
19BCS1815_PresentationAutomatic Number Plate Recognition(ANPR)P.pptx
19BCS1815_PresentationAutomatic Number Plate Recognition(ANPR)P.pptx19BCS1815_PresentationAutomatic Number Plate Recognition(ANPR)P.pptx
19BCS1815_PresentationAutomatic Number Plate Recognition(ANPR)P.pptx
SamridhGarg
Pattern matching presentation
Pattern matching presentationPattern matching presentation
Pattern matching presentation
Michael Dimmitt
image55.pptx it has a detailed explanation on image manipulation
image55.pptx it has a detailed explanation on image manipulationimage55.pptx it has a detailed explanation on image manipulation
image55.pptx it has a detailed explanation on image manipulation
yash07jadhav
Python for Computer Vision - Revision
Python for Computer Vision - RevisionPython for Computer Vision - Revision
Python for Computer Vision - Revision
Ahmed Gad
Deep Learning.pptx
Deep Learning.pptxDeep Learning.pptx
Deep Learning.pptx
Ramya Nellutla
OpenCV In Mobile Technology | Computer Vision on Mobile
OpenCV In Mobile Technology | Computer Vision on MobileOpenCV In Mobile Technology | Computer Vision on Mobile
OpenCV In Mobile Technology | Computer Vision on Mobile
dineshlakhzz
Inception V3 Image Processing .pptx
Inception V3 Image Processing .pptxInception V3 Image Processing .pptx
Inception V3 Image Processing .pptx
MahmoudMohamedAbdelb
Seeing is Not Believing: Camouflage Attacks on Image Scaling Algorithms Review
Seeing is Not Believing: Camouflage Attacks on Image Scaling Algorithms ReviewSeeing is Not Believing: Camouflage Attacks on Image Scaling Algorithms Review
Seeing is Not Believing: Camouflage Attacks on Image Scaling Algorithms Review
Junyaup Kim
cnn ppt.pptx
cnn ppt.pptxcnn ppt.pptx
cnn ppt.pptx
rohithprabhas1
ACM init()- Day 4
ACM init()- Day 4ACM init()- Day 4
ACM init()- Day 4
UCLA Association of Computing Machinery
Deep Learning on iOS #360iDev
Deep Learning on iOS #360iDevDeep Learning on iOS #360iDev
Deep Learning on iOS #360iDev
Shuichi Tsutsumi
Meetup
MeetupMeetup
Meetup
Giovanni Perna
Metadata extraction using Amazon Rekognition and Amazon SageMaker
Metadata extraction using Amazon Rekognition and Amazon SageMakerMetadata extraction using Amazon Rekognition and Amazon SageMaker
Metadata extraction using Amazon Rekognition and Amazon SageMaker
Matt McDonnell
Swin_Transformer_Presentation_VITpp.pptx
Swin_Transformer_Presentation_VITpp.pptxSwin_Transformer_Presentation_VITpp.pptx
Swin_Transformer_Presentation_VITpp.pptx
bhaveshagrawal35
46.-Applications-of-AI-Image-Processing.pdf
46.-Applications-of-AI-Image-Processing.pdf46.-Applications-of-AI-Image-Processing.pdf
46.-Applications-of-AI-Image-Processing.pdf
monikag2613
2007 Barcelona Drupalcon Image handling
2007 Barcelona Drupalcon Image handling2007 Barcelona Drupalcon Image handling
2007 Barcelona Drupalcon Image handling
James Walker
YU CS Summer 2021 Project | TensorFlow Street Image Classification and Object...
YU CS Summer 2021 Project | TensorFlow Street Image Classification and Object...YU CS Summer 2021 Project | TensorFlow Street Image Classification and Object...
YU CS Summer 2021 Project | TensorFlow Street Image Classification and Object...
JacobSilbiger1
introductiontooopinpython-171115114144.pdf
introductiontooopinpython-171115114144.pdfintroductiontooopinpython-171115114144.pdf
introductiontooopinpython-171115114144.pdf
AhmedSalama337512
Introduction to OOP in Python
Introduction to OOP in PythonIntroduction to OOP in Python
Introduction to OOP in Python
Aleksander Fabijan
19BCS1815_PresentationAutomatic Number Plate Recognition(ANPR)P.pptx
19BCS1815_PresentationAutomatic Number Plate Recognition(ANPR)P.pptx19BCS1815_PresentationAutomatic Number Plate Recognition(ANPR)P.pptx
19BCS1815_PresentationAutomatic Number Plate Recognition(ANPR)P.pptx
SamridhGarg
Pattern matching presentation
Pattern matching presentationPattern matching presentation
Pattern matching presentation
Michael Dimmitt
image55.pptx it has a detailed explanation on image manipulation
image55.pptx it has a detailed explanation on image manipulationimage55.pptx it has a detailed explanation on image manipulation
image55.pptx it has a detailed explanation on image manipulation
yash07jadhav
Python for Computer Vision - Revision
Python for Computer Vision - RevisionPython for Computer Vision - Revision
Python for Computer Vision - Revision
Ahmed Gad
OpenCV In Mobile Technology | Computer Vision on Mobile
OpenCV In Mobile Technology | Computer Vision on MobileOpenCV In Mobile Technology | Computer Vision on Mobile
OpenCV In Mobile Technology | Computer Vision on Mobile
dineshlakhzz
Inception V3 Image Processing .pptx
Inception V3 Image Processing .pptxInception V3 Image Processing .pptx
Inception V3 Image Processing .pptx
MahmoudMohamedAbdelb
Seeing is Not Believing: Camouflage Attacks on Image Scaling Algorithms Review
Seeing is Not Believing: Camouflage Attacks on Image Scaling Algorithms ReviewSeeing is Not Believing: Camouflage Attacks on Image Scaling Algorithms Review
Seeing is Not Believing: Camouflage Attacks on Image Scaling Algorithms Review
Junyaup Kim
Deep Learning on iOS #360iDev
Deep Learning on iOS #360iDevDeep Learning on iOS #360iDev
Deep Learning on iOS #360iDev
Shuichi Tsutsumi
Metadata extraction using Amazon Rekognition and Amazon SageMaker
Metadata extraction using Amazon Rekognition and Amazon SageMakerMetadata extraction using Amazon Rekognition and Amazon SageMaker
Metadata extraction using Amazon Rekognition and Amazon SageMaker
Matt McDonnell

Recently uploaded (20)

A Brief Introduction About Raman Bhaumik
A Brief Introduction About Raman BhaumikA Brief Introduction About Raman Bhaumik
A Brief Introduction About Raman Bhaumik
Raman Bhaumik
Elastic Search Engineer Certification - Virtual
Elastic Search Engineer Certification - VirtualElastic Search Engineer Certification - Virtual
Elastic Search Engineer Certification - Virtual
Gon巽alo Pereira
Metaverse Meetup: Explore Mulesoft MAC Project
Metaverse Meetup: Explore  Mulesoft MAC ProjectMetaverse Meetup: Explore  Mulesoft MAC Project
Metaverse Meetup: Explore Mulesoft MAC Project
GiulioPicchi
Computer Architecture Patterson chapter 1 .ppt
Computer Architecture Patterson chapter 1 .pptComputer Architecture Patterson chapter 1 .ppt
Computer Architecture Patterson chapter 1 .ppt
jaysen110
Drawing Heighways Dragon - Recursive Function Rewrite - From Imperative Styl...
Drawing Heighways Dragon - Recursive Function Rewrite - From Imperative Styl...Drawing Heighways Dragon - Recursive Function Rewrite - From Imperative Styl...
Drawing Heighways Dragon - Recursive Function Rewrite - From Imperative Styl...
Philip Schwarz
Online Software Testing Training Institute in Delhi Ncr
Online Software Testing Training Institute in Delhi NcrOnline Software Testing Training Institute in Delhi Ncr
Online Software Testing Training Institute in Delhi Ncr
Home
Why Every Cables and Wires Manufacturer Needs a Cloud-Based ERP Solutions
Why Every Cables and Wires Manufacturer Needs a Cloud-Based ERP SolutionsWhy Every Cables and Wires Manufacturer Needs a Cloud-Based ERP Solutions
Why Every Cables and Wires Manufacturer Needs a Cloud-Based ERP Solutions
Absolute ERP
SE- Lecture 5 SE for easy understanding.ppt
SE- Lecture 5 SE for easy understanding.pptSE- Lecture 5 SE for easy understanding.ppt
SE- Lecture 5 SE for easy understanding.ppt
theworldimagine985
Wondershare Filmora 14.3.2 Crack + License Key Free Download
Wondershare Filmora 14.3.2 Crack + License Key Free DownloadWondershare Filmora 14.3.2 Crack + License Key Free Download
Wondershare Filmora 14.3.2 Crack + License Key Free Download
arshadkhokher01
Douwan Preactivated Plus Crack 2025-Latest
Douwan Preactivated Plus Crack 2025-LatestDouwan Preactivated Plus Crack 2025-Latest
Douwan Preactivated Plus Crack 2025-Latest
mubeen010khan
AVG Antivirus Crack With Free version Download 2025 [Latest]
AVG Antivirus Crack With Free version Download 2025 [Latest]AVG Antivirus Crack With Free version Download 2025 [Latest]
AVG Antivirus Crack With Free version Download 2025 [Latest]
haroonsaeed605
AnyDesk Pro 3.7.0 Crack License Key Free Download 2025 [Latest]
AnyDesk Pro 3.7.0 Crack License Key Free Download 2025 [Latest]AnyDesk Pro 3.7.0 Crack License Key Free Download 2025 [Latest]
AnyDesk Pro 3.7.0 Crack License Key Free Download 2025 [Latest]
haroonsaeed605
Projects Panama, Valhalla, and Babylon: Java is the New Python v0.9
Projects Panama, Valhalla, and Babylon: Java is the New Python v0.9Projects Panama, Valhalla, and Babylon: Java is the New Python v0.9
Projects Panama, Valhalla, and Babylon: Java is the New Python v0.9
Yann-Ga谷l Gu辿h辿neuc
iTop VPN Latest Version 2025 Crack Free Download
iTop VPN Latest Version 2025 Crack Free DownloadiTop VPN Latest Version 2025 Crack Free Download
iTop VPN Latest Version 2025 Crack Free Download
lr74xqnvuf
AI Agents and More:Build Your AI Assistans
AI Agents and More:Build Your AI AssistansAI Agents and More:Build Your AI Assistans
AI Agents and More:Build Your AI Assistans
HusseinMalikMammadli
Minitool Partition Wizard Crack Free Download
Minitool Partition Wizard Crack Free DownloadMinitool Partition Wizard Crack Free Download
Minitool Partition Wizard Crack Free Download
v3r2eptd2q
Account Cash Flow Statement Report Generate in odoo
Account Cash Flow Statement Report Generate in odooAccount Cash Flow Statement Report Generate in odoo
Account Cash Flow Statement Report Generate in odoo
AxisTechnolabs
EASEUS Partition Master Crack with License Code [Latest]
EASEUS Partition Master Crack with License Code [Latest]EASEUS Partition Master Crack with License Code [Latest]
EASEUS Partition Master Crack with License Code [Latest]
bhagasufyan
LLM Security - Smart to protect, but too smart to be protected
LLM Security - Smart to protect, but too smart to be protectedLLM Security - Smart to protect, but too smart to be protected
LLM Security - Smart to protect, but too smart to be protected
Ivo Andreev
Mastering Software Test Automation: A Comprehensive Guide for Beginners and E...
Mastering Software Test Automation: A Comprehensive Guide for Beginners and E...Mastering Software Test Automation: A Comprehensive Guide for Beginners and E...
Mastering Software Test Automation: A Comprehensive Guide for Beginners and E...
Shubham Joshi
A Brief Introduction About Raman Bhaumik
A Brief Introduction About Raman BhaumikA Brief Introduction About Raman Bhaumik
A Brief Introduction About Raman Bhaumik
Raman Bhaumik
Elastic Search Engineer Certification - Virtual
Elastic Search Engineer Certification - VirtualElastic Search Engineer Certification - Virtual
Elastic Search Engineer Certification - Virtual
Gon巽alo Pereira
Metaverse Meetup: Explore Mulesoft MAC Project
Metaverse Meetup: Explore  Mulesoft MAC ProjectMetaverse Meetup: Explore  Mulesoft MAC Project
Metaverse Meetup: Explore Mulesoft MAC Project
GiulioPicchi
Computer Architecture Patterson chapter 1 .ppt
Computer Architecture Patterson chapter 1 .pptComputer Architecture Patterson chapter 1 .ppt
Computer Architecture Patterson chapter 1 .ppt
jaysen110
Drawing Heighways Dragon - Recursive Function Rewrite - From Imperative Styl...
Drawing Heighways Dragon - Recursive Function Rewrite - From Imperative Styl...Drawing Heighways Dragon - Recursive Function Rewrite - From Imperative Styl...
Drawing Heighways Dragon - Recursive Function Rewrite - From Imperative Styl...
Philip Schwarz
Online Software Testing Training Institute in Delhi Ncr
Online Software Testing Training Institute in Delhi NcrOnline Software Testing Training Institute in Delhi Ncr
Online Software Testing Training Institute in Delhi Ncr
Home
Why Every Cables and Wires Manufacturer Needs a Cloud-Based ERP Solutions
Why Every Cables and Wires Manufacturer Needs a Cloud-Based ERP SolutionsWhy Every Cables and Wires Manufacturer Needs a Cloud-Based ERP Solutions
Why Every Cables and Wires Manufacturer Needs a Cloud-Based ERP Solutions
Absolute ERP
SE- Lecture 5 SE for easy understanding.ppt
SE- Lecture 5 SE for easy understanding.pptSE- Lecture 5 SE for easy understanding.ppt
SE- Lecture 5 SE for easy understanding.ppt
theworldimagine985
Wondershare Filmora 14.3.2 Crack + License Key Free Download
Wondershare Filmora 14.3.2 Crack + License Key Free DownloadWondershare Filmora 14.3.2 Crack + License Key Free Download
Wondershare Filmora 14.3.2 Crack + License Key Free Download
arshadkhokher01
Douwan Preactivated Plus Crack 2025-Latest
Douwan Preactivated Plus Crack 2025-LatestDouwan Preactivated Plus Crack 2025-Latest
Douwan Preactivated Plus Crack 2025-Latest
mubeen010khan
AVG Antivirus Crack With Free version Download 2025 [Latest]
AVG Antivirus Crack With Free version Download 2025 [Latest]AVG Antivirus Crack With Free version Download 2025 [Latest]
AVG Antivirus Crack With Free version Download 2025 [Latest]
haroonsaeed605
AnyDesk Pro 3.7.0 Crack License Key Free Download 2025 [Latest]
AnyDesk Pro 3.7.0 Crack License Key Free Download 2025 [Latest]AnyDesk Pro 3.7.0 Crack License Key Free Download 2025 [Latest]
AnyDesk Pro 3.7.0 Crack License Key Free Download 2025 [Latest]
haroonsaeed605
Projects Panama, Valhalla, and Babylon: Java is the New Python v0.9
Projects Panama, Valhalla, and Babylon: Java is the New Python v0.9Projects Panama, Valhalla, and Babylon: Java is the New Python v0.9
Projects Panama, Valhalla, and Babylon: Java is the New Python v0.9
Yann-Ga谷l Gu辿h辿neuc
iTop VPN Latest Version 2025 Crack Free Download
iTop VPN Latest Version 2025 Crack Free DownloadiTop VPN Latest Version 2025 Crack Free Download
iTop VPN Latest Version 2025 Crack Free Download
lr74xqnvuf
AI Agents and More:Build Your AI Assistans
AI Agents and More:Build Your AI AssistansAI Agents and More:Build Your AI Assistans
AI Agents and More:Build Your AI Assistans
HusseinMalikMammadli
Minitool Partition Wizard Crack Free Download
Minitool Partition Wizard Crack Free DownloadMinitool Partition Wizard Crack Free Download
Minitool Partition Wizard Crack Free Download
v3r2eptd2q
Account Cash Flow Statement Report Generate in odoo
Account Cash Flow Statement Report Generate in odooAccount Cash Flow Statement Report Generate in odoo
Account Cash Flow Statement Report Generate in odoo
AxisTechnolabs
EASEUS Partition Master Crack with License Code [Latest]
EASEUS Partition Master Crack with License Code [Latest]EASEUS Partition Master Crack with License Code [Latest]
EASEUS Partition Master Crack with License Code [Latest]
bhagasufyan
LLM Security - Smart to protect, but too smart to be protected
LLM Security - Smart to protect, but too smart to be protectedLLM Security - Smart to protect, but too smart to be protected
LLM Security - Smart to protect, but too smart to be protected
Ivo Andreev
Mastering Software Test Automation: A Comprehensive Guide for Beginners and E...
Mastering Software Test Automation: A Comprehensive Guide for Beginners and E...Mastering Software Test Automation: A Comprehensive Guide for Beginners and E...
Mastering Software Test Automation: A Comprehensive Guide for Beginners and E...
Shubham Joshi

Computer vision

  • 1. Computer Vision Because Artificial Intelligence is the future
  • 2. What it is Applying machine learning in order for a machine to understand a certain image and its characteristics In this example, we want the machine to learn characteristics of a certain bee (template.jpg) and pick it from a picture of a number of bees. Template.jpg is the template we are using to train our model We are picking our bee from Bee1.jpg which has a number of bees in it:
  • 3. Libraries used import cv2 #our computer library of choice which is open cv import numpy as np #library for mathemitical computation from matplotlib import pyplot as plt %matplotlib inline #to have our images shown within jupyter using the above line
  • 4. Reading the image and the template image = cv2.imread('Bee1.jpg') #the image from which we are picking the bee img = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY) img_copy = img.copy() #making a numpy copy of our original image so we dont distort it when we are working on it template = cv2.imread('template_bee.jpg', 0) # this is the template showing us the image of the bee we are looking for w, h= template.shape[::-1] #image dimensions and python starts counting from 0 and so the -1
  • 5. Matching our template with our image #Apply template matching using the function matchTemplate res = cv2.matchTemplate(img_copy,template,cv2.TM_CCOEFF_NORMED) min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res) #define the threshold; allowance for error threshold = 0.8 loc = np.where(res >= threshold)
  • 6. Identifying our bee #draw a bounding rectangle for pt in zip(*loc[::-1]): #for a certain point in our image cv2.rectangle(img_copy,pt,(pt[0]+w,pt[1]+h), (0,255,255),2) #draw our rectangle plt.imshow(img_copy, cmap="gray") #this is plotting our image