Skip to main content

First Step to Open CV (Open Computer Vision Library) Part 1



Introduction 


Hello , I am going to setup the Open CV on windows OS. Open CV is in under open-source BSD license. Originally developed by Intel and this is supports the deep learning frameworks like TensorFlow.

OpenCV's application areas include:
  • 2D and 3D feature toolkits
  • Egomotion estimation
  • Facial recognition system
  • Gesture recognition
  • Human–computer interaction (HCI)
  • Mobile robotics
  • Motion understanding
  • Object identification
  • Segmentation and recognition
  • Stereopsis stereo vision: depth perception from 2 cameras
  • Structure from motion (SFM)
  • Motion tracking
  • Augmented reality

It is written by mainly C++ interface and supported C++,python,java even android package,Matlab,C# for development. Therefore this tutorial I am going to use python language.


Installations

  • If you haven't already installed python get it here (My version is 2.7) and install it.
  • Then Download and install OpenCV here (My version is Open CV 2) 
Configure system variable  
 
  • Open python installed folder and copy the path (for ex C:\Python27)
  • Then Run-> type systempropertiesadvanced
  • open Environment variable -> User variable .....->path->paste the python installed path and Scripts path.(you can see it below)
 

Numpy install

"numpy" is a scientific and mathematical package and which is required to run opencv package.
  • open the CMD then type pip install numpy  (Make sure you have connected to the internet)
(I have already installed )



Make the link between python and opencv package

  • Go to this path opencv\build\python\2.7\x64 then copy cv2.pyd file
  • paste cv2.pyd into the Python27\Lib\site-packages folder

Test

  •  Open the python IDE and type import numpy and import cv2 to verify whether packages work or not. if any error is not displayed,  you are done.



First Program - Face and Eye Detection



Then I load my pyscript IDE , you can simply use python default IDE or any python IDE. I will explain this code segment in next part broadly.

import numpy as np
import cv2 as cv
face_cascade = cv.CascadeClassifier('haarcascade_frontalface_default.xml')
eye_cascade = cv.CascadeClassifier('haarcascade_eye.xml')
img = cv.imread('praneeth.png')
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)

faces = face_cascade.detectMultiScale(gray, 1.3, 5)
for (x,y,w,h) in faces:
    cv.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)
    roi_gray = gray[y:y+h, x:x+w]
    roi_color = img[y:y+h, x:x+w]
    eyes = eye_cascade.detectMultiScale(roi_gray)
    for (ex,ey,ew,eh) in eyes:
        cv.rectangle(roi_color,(ex,ey),(ex+ew,ey+eh),(0,255,0),2)
cv.imshow('img',img)
cv.waitKey(0)
cv.destroyAllWindows()


output





References
  • https://opencv.org
  • https://en.wikipedia.org/wiki/OpenCV
  • https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRyp5yAZXk4rDv5DELPPv3ZqhEAUMJJIFw1m-sKd0cpwDfDQS_J
  • https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRhLXSKHikcgnn1rhnVzw194t2Os8TUd6139jkFTn9v3NeZuAVY

Comments

  1. Aftershokz titanium - TITanium Art
    We created a titanium pipe beautiful ford focus titanium aftershokz titanium inspired design that titanium pots and pans uses the most exquisite tools titanium body armor of the best designers titanium tv alternative in the field.

    ReplyDelete

Post a Comment

Popular posts from this blog

Alternative FOSS Software for Popular Premium Software

In the present software has become more expensive than hardware parts, normally  we can buy average laptop under $500 but we have to spend nearly $200 just only for operating system. We all know operating system cannot fulfill all our computerized needs, so we have to buy other software too. Most of people used to use popular software because they can easily find tutorials for popular software and the developers of those software invest more money for their advertising.   A considerable amount of computer users do not pay for their software, they use cracks, patches and different kind of technologies to use premium software without paying. Most of those cracks and patches are not 100% clean they comes with spyware , adware etc... We can use open source software instead of using cracked premium software. Here are some best alternative software for popular premium software.   Ardour Ardour is good alternative for audio recording and editing software

Introduction To Linux Shell Scripts

I hope everyone heard about Linux Operating System before. Like other Operating Systems Linux also is made of many components. But here to get an Introduction to the Linux Shell Scripts, we need to know about its major/important components Kernel and Shell . We studied that Operating System is a software that manages computer Harware and provide an interface between Computer Hardware and Users/Softwares. Kernal is the component/program responsible for first task of an OS, that is managing computer Hardware. And Shell is the component/program responsible to provide the interface for the users/softwares with hardware. We can graphically get an idea of it as shown in following Image. Kernal and Shell of Linux OS Let's see about Linux Shell more in details. A shell is program which acts like an interpreter. It convert human readable commands received from input devices into something which kernel can understand. The shell starts to run when a user logs in or pr

What is Blockchain Technology ? An Introduction for Beginners

You all may have know or have heard about Bitcoin or other cryptocurrencies names. Those all digital currencies are reference to Blockchain  Technology. Simply, Blockchain is a critical element of cryptocurrencies. Because without Blockchain, Bitcoin or other cryptocurrencies would not exist. Cryptocurrencies was a concept of the domain of cryptography and data structure in computer science. Merkle tree or hash tree is the primitive form of the Blockchain. Ralph Merkle introduced this data structure in 1979. A series of data records (a secured chain of blocks) was created using this Merkle tree and each connected to the one before it.  When we create a new record in this chain, that record would contain the history of the entire chain and that's how the Blockchain was created.  Distributed blockchain was intoduced by Satoshi Nakamato in 2008 and this was the backbone of Bitcoin. Let's try to undersatnd how blockchain works. Blockchain always keeps a record of

What is A-Frame.io

What is aframe?? Before i get this i like to ask from you, Did you ever have get a virtual reality? Someones are Yes! or Not!, Do you like to get that experience? So here it is. A-Frame is a web framework for building virtual reality (VR) experience. This web frame is an open source webframe work who can develop many things. It is primary maintained by Mozilla and WebVR community. But originally from Mozilla. A-Frame was developed to be an easy but powerful and easy way to develop VR content. As an open source project, A-Frame has grown to be one of the largest and most welcoming VR communities. A-Frame is based on top of HTML, simple to get started. But A-Frame is not just 3D scene graph or markup language. It is an entity component system framework for three.js  where developers can create 3D WebVR  scenes using HTML.  Nowadays HTML provides a familiar tool for web developers and designers while incorporating a popular game development pattern used by Game engines such as U

What is open source?

The term "open source" refers to something people can modify and share because its design is publicly accessible. The term originated in the context of software development to designate a specific approach to creating computer programs. Today, however, "open source" designates a broader set of values—what we call "the open source way." Open source projects, products, or initiatives embrace and celebrate principles of open exchange, collaborative participation, rapid prototyping, transparency, meritocracy, and community-oriented development. What is open source software? Open source software is software with source code that anyone can inspect, modify, and enhance. "Source code" is the part of software that most computer users don't ever see; it's the code computer programmers can manipulate to change how a piece of software—a "program" or "application"—works. Programmers who have access to a computer progr

Getting started with Git.

What is Git? Git is a version control system (managing changes of documents) for tracking changes in computer files and coordinating work on those files among multiple people. It is primarily used for source code management in software development, but it can be used to keep track of changes in any set of files. It is used to keep track of revisions of the work done and also it allow a developer or developing team to work together on a project. Git was created by Linus Torvalds who was a Finnish-American software engineer in 2005 for development of the Linux kernel which is  is an open-source monolithic (operating system architecture) Unix-like computer operating system kernel. The Three Stages Git has three main states that your files can reside in they are committed, modified, and staged: Committed means that the data is safely stored in your local database. Modified means that you have changed the file but have not committed it to your database yet.