SlideShare a Scribd company logo
1 of 7
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 don’t
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

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.pptxSamridhGarg
 
Pattern matching presentation
Pattern matching presentationPattern matching presentation
Pattern matching presentationMichael Dimmitt
 
Python for Computer Vision - Revision
Python for Computer Vision - RevisionPython for Computer Vision - Revision
Python for Computer Vision - RevisionAhmed Gad
 
Inception V3 Image Processing .pptx
Inception V3 Image Processing .pptxInception V3 Image Processing .pptx
Inception V3 Image Processing .pptxMahmoudMohamedAbdelb
 
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 ReviewJunyaup Kim
 
Deep Learning on iOS #360iDev
Deep Learning on iOS #360iDevDeep Learning on iOS #360iDev
Deep Learning on iOS #360iDevShuichi 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 SageMakerMatt McDonnell
 

Similar to Computer vision (13)

Introduction to OOP in Python
Introduction to OOP in PythonIntroduction to OOP in Python
Introduction to OOP in Python
 
Apple Machine Learning
Apple Machine LearningApple Machine Learning
Apple Machine Learning
 
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
 
Pattern matching presentation
Pattern matching presentationPattern matching presentation
Pattern matching presentation
 
Python for Computer Vision - Revision
Python for Computer Vision - RevisionPython for Computer Vision - Revision
Python for Computer Vision - Revision
 
Deep Learning.pptx
Deep Learning.pptxDeep Learning.pptx
Deep Learning.pptx
 
Inception V3 Image Processing .pptx
Inception V3 Image Processing .pptxInception V3 Image Processing .pptx
Inception V3 Image Processing .pptx
 
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
 
cnn ppt.pptx
cnn ppt.pptxcnn ppt.pptx
cnn ppt.pptx
 
ACM init()- Day 4
ACM init()- Day 4ACM init()- Day 4
ACM init()- Day 4
 
Deep Learning on iOS #360iDev
Deep Learning on iOS #360iDevDeep Learning on iOS #360iDev
Deep Learning on iOS #360iDev
 
Meetup
MeetupMeetup
Meetup
 
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
 

Recently uploaded

OpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCAOpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCAShane Coughlan
 
Evolving Data Governance for the Real-time Streaming and AI Era
Evolving Data Governance for the Real-time Streaming and AI EraEvolving Data Governance for the Real-time Streaming and AI Era
Evolving Data Governance for the Real-time Streaming and AI Eraconfluent
 
BusinessGPT - Security and Governance for Generative AI
BusinessGPT  - Security and Governance for Generative AIBusinessGPT  - Security and Governance for Generative AI
BusinessGPT - Security and Governance for Generative AIAGATSoftware
 
A Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdfA Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdfICS
 
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit MilanWorkshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit MilanNeo4j
 
CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...
CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...
CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...Neo4j
 
Effective Strategies for Wix's Scaling challenges - GeeCon
Effective Strategies for Wix's Scaling challenges - GeeConEffective Strategies for Wix's Scaling challenges - GeeCon
Effective Strategies for Wix's Scaling challenges - GeeConNatan Silnitsky
 
The mythical technical debt. (Brooke, please, forgive me)
The mythical technical debt. (Brooke, please, forgive me)The mythical technical debt. (Brooke, please, forgive me)
The mythical technical debt. (Brooke, please, forgive me)Roberto Bettazzoni
 
Lessons Learned from Building a Serverless Notifications System.pdf
Lessons Learned from Building a Serverless Notifications System.pdfLessons Learned from Building a Serverless Notifications System.pdf
Lessons Learned from Building a Serverless Notifications System.pdfSrushith Repakula
 
Test Automation Design Patterns_ A Comprehensive Guide.pdf
Test Automation Design Patterns_ A Comprehensive Guide.pdfTest Automation Design Patterns_ A Comprehensive Guide.pdf
Test Automation Design Patterns_ A Comprehensive Guide.pdfkalichargn70th171
 
Auto Affiliate AI Earns First Commission in 3 Hours..pdf
Auto Affiliate  AI Earns First Commission in 3 Hours..pdfAuto Affiliate  AI Earns First Commission in 3 Hours..pdf
Auto Affiliate AI Earns First Commission in 3 Hours..pdfSelfMade bd
 
From Theory to Practice: Utilizing SpiraPlan's REST API
From Theory to Practice: Utilizing SpiraPlan's REST APIFrom Theory to Practice: Utilizing SpiraPlan's REST API
From Theory to Practice: Utilizing SpiraPlan's REST APIInflectra
 
GraphSummit Milan - Visione e roadmap del prodotto Neo4j
GraphSummit Milan - Visione e roadmap del prodotto Neo4jGraphSummit Milan - Visione e roadmap del prodotto Neo4j
GraphSummit Milan - Visione e roadmap del prodotto Neo4jNeo4j
 
[GRCPP] Introduction to concepts (C++20)
[GRCPP] Introduction to concepts (C++20)[GRCPP] Introduction to concepts (C++20)
[GRCPP] Introduction to concepts (C++20)Dimitrios Platis
 
Novo Nordisk: When Knowledge Graphs meet LLMs
Novo Nordisk: When Knowledge Graphs meet LLMsNovo Nordisk: When Knowledge Graphs meet LLMs
Novo Nordisk: When Knowledge Graphs meet LLMsNeo4j
 
Transformer Neural Network Use Cases with Links
Transformer Neural Network Use Cases with LinksTransformer Neural Network Use Cases with Links
Transformer Neural Network Use Cases with LinksJinanKordab
 
Alluxio Monthly Webinar | Simplify Data Access for AI in Multi-Cloud
Alluxio Monthly Webinar | Simplify Data Access for AI in Multi-CloudAlluxio Monthly Webinar | Simplify Data Access for AI in Multi-Cloud
Alluxio Monthly Webinar | Simplify Data Access for AI in Multi-CloudAlluxio, Inc.
 

Recently uploaded (20)

OpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCAOpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCA
 
Evolving Data Governance for the Real-time Streaming and AI Era
Evolving Data Governance for the Real-time Streaming and AI EraEvolving Data Governance for the Real-time Streaming and AI Era
Evolving Data Governance for the Real-time Streaming and AI Era
 
BusinessGPT - Security and Governance for Generative AI
BusinessGPT  - Security and Governance for Generative AIBusinessGPT  - Security and Governance for Generative AI
BusinessGPT - Security and Governance for Generative AI
 
Abortion Clinic In Stanger ](+27832195400*)[ 🏥 Safe Abortion Pills In Stanger...
Abortion Clinic In Stanger ](+27832195400*)[ 🏥 Safe Abortion Pills In Stanger...Abortion Clinic In Stanger ](+27832195400*)[ 🏥 Safe Abortion Pills In Stanger...
Abortion Clinic In Stanger ](+27832195400*)[ 🏥 Safe Abortion Pills In Stanger...
 
A Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdfA Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdf
 
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit MilanWorkshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
 
CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...
CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...
CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...
 
Effective Strategies for Wix's Scaling challenges - GeeCon
Effective Strategies for Wix's Scaling challenges - GeeConEffective Strategies for Wix's Scaling challenges - GeeCon
Effective Strategies for Wix's Scaling challenges - GeeCon
 
The mythical technical debt. (Brooke, please, forgive me)
The mythical technical debt. (Brooke, please, forgive me)The mythical technical debt. (Brooke, please, forgive me)
The mythical technical debt. (Brooke, please, forgive me)
 
Lessons Learned from Building a Serverless Notifications System.pdf
Lessons Learned from Building a Serverless Notifications System.pdfLessons Learned from Building a Serverless Notifications System.pdf
Lessons Learned from Building a Serverless Notifications System.pdf
 
Test Automation Design Patterns_ A Comprehensive Guide.pdf
Test Automation Design Patterns_ A Comprehensive Guide.pdfTest Automation Design Patterns_ A Comprehensive Guide.pdf
Test Automation Design Patterns_ A Comprehensive Guide.pdf
 
Auto Affiliate AI Earns First Commission in 3 Hours..pdf
Auto Affiliate  AI Earns First Commission in 3 Hours..pdfAuto Affiliate  AI Earns First Commission in 3 Hours..pdf
Auto Affiliate AI Earns First Commission in 3 Hours..pdf
 
From Theory to Practice: Utilizing SpiraPlan's REST API
From Theory to Practice: Utilizing SpiraPlan's REST APIFrom Theory to Practice: Utilizing SpiraPlan's REST API
From Theory to Practice: Utilizing SpiraPlan's REST API
 
GraphSummit Milan - Visione e roadmap del prodotto Neo4j
GraphSummit Milan - Visione e roadmap del prodotto Neo4jGraphSummit Milan - Visione e roadmap del prodotto Neo4j
GraphSummit Milan - Visione e roadmap del prodotto Neo4j
 
[GRCPP] Introduction to concepts (C++20)
[GRCPP] Introduction to concepts (C++20)[GRCPP] Introduction to concepts (C++20)
[GRCPP] Introduction to concepts (C++20)
 
Abortion Clinic In Pongola ](+27832195400*)[ 🏥 Safe Abortion Pills In Pongola...
Abortion Clinic In Pongola ](+27832195400*)[ 🏥 Safe Abortion Pills In Pongola...Abortion Clinic In Pongola ](+27832195400*)[ 🏥 Safe Abortion Pills In Pongola...
Abortion Clinic In Pongola ](+27832195400*)[ 🏥 Safe Abortion Pills In Pongola...
 
Novo Nordisk: When Knowledge Graphs meet LLMs
Novo Nordisk: When Knowledge Graphs meet LLMsNovo Nordisk: When Knowledge Graphs meet LLMs
Novo Nordisk: When Knowledge Graphs meet LLMs
 
Abortion Clinic In Johannesburg ](+27832195400*)[ 🏥 Safe Abortion Pills in Jo...
Abortion Clinic In Johannesburg ](+27832195400*)[ 🏥 Safe Abortion Pills in Jo...Abortion Clinic In Johannesburg ](+27832195400*)[ 🏥 Safe Abortion Pills in Jo...
Abortion Clinic In Johannesburg ](+27832195400*)[ 🏥 Safe Abortion Pills in Jo...
 
Transformer Neural Network Use Cases with Links
Transformer Neural Network Use Cases with LinksTransformer Neural Network Use Cases with Links
Transformer Neural Network Use Cases with Links
 
Alluxio Monthly Webinar | Simplify Data Access for AI in Multi-Cloud
Alluxio Monthly Webinar | Simplify Data Access for AI in Multi-CloudAlluxio Monthly Webinar | Simplify Data Access for AI in Multi-Cloud
Alluxio Monthly Webinar | Simplify Data Access for AI in Multi-Cloud
 

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 don’t 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