OpenCV- a library with sight
OpenCV (Open Source Computer Vision Library) is an open source computer vision and machine learning software library. OpenCV was built to provide a common infrastructure for computer vision applications and to accelerate the use of machine perception in the commercial products. It mainly focuses on image processing, video capture and analysis including features like face detection and object detection.
What is Computer Vision?
Computer vision is the field of computer science that focuses on replicating parts of the complexity of the human vision system and enabling computers to identify and process objects in images and videos in the same way that humans do.
Computer Vision overlaps significantly with the following fields −
Image Processing − It focuses on image manipulation.
Pattern Recognition − It explains various techniques to classify patterns.
Photogrammetry − It is concerned with obtaining accurate measurements from images.
How Does A Computer Read An Image?
Let us consider the following image:
We can figure out that it is an image of the New York skyline. But can a computer find this out all on its own? The answer is no!
The computer reads any image as a range of values between 0 and 255.
For any color image, there are 3 primary channels — red, green and blue.
A matrix is formed for every primary color, and later, these matrices combine to provide a pixel value for the individual R, G, and B colors.
Each element of the matrices provides data pertaining to the intensity of brightness of the pixel.
Consider the following image:
As shown, the size of the image here can be calculated as B x A x 3.
Note: For a black and white image, there is only one single channel.
Computer Vision Vs Image Processing
Image processing deals with image-to-image transformation. The input and output of image processing are both images.
Computer vision is the construction of explicit, meaningful descriptions of physical objects from their image. The output of computer vision is a description or an interpretation of structures in 3D scene.
Fig. 1 shows a clear distinction between Image Processing, Computer Vision and Computer Graphics.
Applications of Computer Vision
Here we have listed down some of major domains where Computer Vision is heavily used.
Robotics Application– Obstacles avoidance, Human Robot Interaction (HRI) − Intelligent robotics to interact with and serve people.
Medicine Application– Classification and detection (e.g. lesion or cells classification and tumor detection), 2D/3D segmentation, 3D human organ reconstruction (MRI or ultrasound)
Industrial Automation Application– Industrial inspection (defect detection), Barcode and package label reading(Fig.3), Object sorting, Surveillance − Detecting certain suspicious activities or behaviors
Transportation Application– Autonomous vehicle, Safety, e.g., driver vigilance monitoring
Features of OpenCV Library
Using OpenCV library, you can –
• Read and write images
• Capture and save videos
• Process images (filter, transform)
• Perform feature detection
• Detect specific objects such as faces, eyes, cars, in the videos or images.
• Analyze the video, i.e., estimate the motion in it, subtract the background, and track objects in it.
OpenCV Library Modules
Following are the main library modules of the OpenCV library:
• Core Functionality– This module covers the basic data structures such as Scalar, Point, Range, etc., that are used to build OpenCV applications. In addition to these, it also includes the multidimensional array Mat, which is used to store the images
• Image Processing– This module covers various image processing operations such as image filtering, geometrical image transformations, color space conversion, histograms, etc.
•Video- This module covers the video analysis concepts such as motion estimation, background subtraction, and object tracking.
• Video I/O– This module explains the video capturing and video codecs using OpenCV library.
• calib3d– This module includes algorithms regarding basic multiple-view geometry algorithms, single and stereo camera calibration, object pose estimation, stereo correspondence and elements of 3D reconstruction.
• features2d– This module includes the concepts of feature detection and description.
• Objdetect– This module includes the detection of objects and instances of the predefined classes such as faces, eyes, mugs, people, cars, etc.
• Highgui– This is an easy-to-use interface with simple UI capabilities.
Why use OpenCV?
OpenCV contains implementations of more than 2500 algorithms. It is freely available for commercial as well as academic purposes. The library has interfaces for multiple languages, including Python, Java, and C++. And the joy doesn’t end there!
Specific– OpenCV was made for image processing. Each function and data structure was designed with the Image Processing coder in mind.
Speedy– In comparison with MATLAB which is built on Java, OpenCV does not waste time in converting it to machine language code and is directly executed as a C/C++ code unlike MATLAB that coverts the code to a JAVA code and then interprets it.
Efficient– Matlab uses just way too much system resources. With OpenCV, you can get away with as little as 10mb RAM for a realtime application.
Cost– openCV is free and does not require any license.
Portability– It can run on any operating system- Windows, Linux, MacOS.
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
OpenCV-Python
OpenCV-Python is a library of Python bindings designed to solve computer vision problems.
Python is a general purpose programming language started by Guido van Rossum that became very popular very quickly, mainly because of its simplicity and code readability. It enables the programmer to express ideas in fewer lines of code without reducing readability.
Compared to languages like C/C++, Python is slower. That said, Python can be easily extended with C/C++, which allows us to write computationally intensive code in C/C++ and create Python wrappers that can be used as Python modules. This gives us two advantages: first, the code is as fast as the original C/C++ code (since it is the actual C++ code working in background) and second, it easier to code in Python than C/C++. OpenCV-Python is a Python wrapper for the original OpenCV C++ implementation.
OpenCV-Python makes use of Numpy, which is a highly optimized library for numerical operations with a MATLAB-style syntax. All the OpenCV array structures are converted to and from Numpy arrays. This also makes it easier to integrate with other libraries that use Numpy such as SciPy and Matplotlib.
The future of OpenCV:
OpenCV has been the go-to library for image processing in the fields of research as well as academia. But the questios is, with Machine learning flourishing so rapidly, what would be the use of OpenCV?
Well, OpenCV includes a statistical machine learning library that contains:
-
- Boosting
- Decision tree learning
- Gradient boosting trees
- Expectation-maximization algorithm
- k-nearest neighbor algorithm
- Naive Bayes classifier
- Artificial neural networks
- Random forest
- Support vector machine (SVM)
This library supports most of the applications of OpenCV that we have seen before. Therefore, does OpenCV have a long future is a debatable question, but image processing will still be blooming somewhere between still trying to align snapchat filters properly, having fully autonomous vehicles on streets and robots being used for medical diagnosis along with specialists in the upcoming decades.
Im very happy to find this web site. I want to to thank you for ones time just for this fantastic read!! I definitely appreciated every part of it and i also have you saved as a favorite to see new information in your blog.