top of page
Search

Introduction to OpenCV

Updated: Aug 23, 2022


Introduction:


OpenCV is the most commonly used, popular, and well-documented Computer Vision library.
It stands stands for Open-Source Computer Vision .It is open-source, which means that one does not require a license to utilize the software.
The area of computer science that deals with image classification, object detection, video processing is called Computer Vision. OpenCV is a programming library for programmers to work with Computer Vision, this library provides more than enough features to implement different tasks like Object Detection, Image segmentation, Image processing.

Computer Vision:

Computer vision refers to a process which enables one to understand images and videos, how they are stored and how they can be manipulated and data retrieved from them. In current time, Computer Vision has an important role to play in self-driving cars, robotics and even in photo correction apps.
Different tasks in Computer Vision -
Object detection: Identifying objects of interest (cats, dogs, cars) in digital images or even videos.
Optical character recognition: Translating images of text that are written or typed into a machine-encoded format
Fingerprint recognition: Using pattern information of the human fingerprint to make a comparison between a fingerprint source and a fingerprint that is a target.

Image Processing:

Image processing refers to the analysis and manipulation of a digitized image, especially in order to improve its quality. By applying Image Processing techniques we can extract useful information that can be used to train a model. Tasks like detecting objects from an image, text recognition , creating AR apps all includes Image Processing.

In order to process the image there are different algorithms and different models we can work on. But for the most convenient and user friendly algorithm or model we currently have is OpenCV.


OpenCv:

OpenCv was originally developed by Intel, and later supported by Willow Garage then Itseez, in turn later acquired by Intel. This cross-platform library is free for both academic and commercial use under the open-source Apache 2 License. It has C++, C, Python, Java and MATLAB interfaces.

OpenCV also supports Windows, Linux, Mac OS, iOS and Android. Initially, the main aim of creating OpenCV was real-time applications for computational efficiency. The well organized documents and bundled with almost all kind of features made it different from other algorithms. Using OpenCV, one can process images and videos to identify objects, faces, or even the handwriting of a human for different Artificial Intelligence and Machine Learning Tasks.



Applications of OpenCV:

There are a huge number of applications that depends on the features of OpenCV library for computer vision tasks.


Face Detection or recognition - Face detection and recognition is a task where the computer has to detect the features of the face to detect the human face from an image or video. This feature detection and underlying facial measurement collection are a key point of OpenCV.


Gesture recognition - Gesture recognition is a task to detect the gesture of an object, the movement detection. This requires a high level module to get the land-marks of the body points and connecting them together to find out those movements. OpenCV provides us with a excellent model for this task called media-pipe.


Augmented Reality - Augmented Reality (AR) is basically an interactive experience of a real-world environment where the objects in the real world get enhanced by computer-generated perceptual information. These tasks need a advanced level of computer vision work that can be achieved with OpenCV module.


Image Segmentation and Recognition - In digital image processing and computer vision, image segmentation is the process of partitioning an image into segments. The segmentation process is to find out the related pixels and classify them. These things helps in self-driving cars for detecting pedestrians and traffics for more better experience.


Object Detection - Object Detection is a technology with computer vision that can detect certain objects from an image. This classification task from an image and detecting certain objects is a main feature of OpenCV.


Object detection with OpenCV

# Import OpenCV module
**import** cv2
from matplotlib **import** pyplot as pltd

imaging = cv2.imread("opencv-od.png")

imaging_gray = cv2.cvtColor(imaging, cv2.COLOR_BGR2GRAY)
imaging_rgb = cv2.cvtColor(imaging, cv2.COLOR_BGR2RGB)

xml_data = cv2.CascadeClassifier('XML-data.xml')
detecting = xml_data.detectMultiScale(imaging_gray,minSize = (30, 30))
amountDetecting = len(detecting)

**if** amountDetecting != 0:
	for (a, b, width, height) in detecting:  
        cv2.rectangle(imaging_rgb, (a, b), # Highlighting detected object with rectangle  
                      (a + height, b + width),   
                      (0, 275, 0), 9)
pltd.subplot(1, 1, 1)  
pltd.imshow(imaging_rgb)  
pltd.show()

Output -

Explanation -

After opening the image in the program, we have imported the cascade classifier XML file into the program. Then, we used the detectMultiScale() function with the imported cascade file to detect the object present in the image or not. We used if condition in the program to check that object is detected or not, and if the object is detected, we have highlighted the detected object part using for loop with cv2 functions. After highlighting the detected object part in the image, we have displayed the processed image using the Alt show() and imshow() function. As we can see in the output, the image with the object detected part as highlighted is shown to us when we run the program.


Conclusion

In this article we have mentioned Computer Vision quite a few times, it is a much more than just computers reading images and that’s beyond the scope of this article. We have an article on how computer vision works and how each and everything is connected to it, link will be given below. For creating deep learning, computer vision projects and understanding more about OpenCv we highly recommend these references below.


Sources :

21 views0 comments

Recent Posts

See All

Comments


bottom of page