cv2.line() function is used to draw a line segment between start point and end point.Create a function draw_line() to wrap the cv2.line() function, and set default values for color, thickness and line_type, when this function is invoked later don’t have to specify these parameters because these default...
Thursday, August 31, 2023
Sunday, August 27, 2023
OpenCV basics continued...Draw Shapes
Now we will use OpenCV functions to draw the following shapes on an empty canvas-LinesRectanglesCirclesEllipsesPolylinesCreate an Empty CanvasSo far, the images we have used are coming from the image files, now we are going to create an empty canvas from numpy library for drawing.numpy is a popular...
Thursday, August 24, 2023
OpenCV basics continued...HSV Color Space and Channels
In addition to the BGR color space, an image can also be represented by HSV (Hue, Saturation, Value) color space, also known as HSB (Hue, Saturation, Brightness), which is a cylindrical color space that describes colors based on three attributes: hue, saturation, and value/brightness, as shown in Figure...
Sunday, August 20, 2023
OpenCV basics continued...BGR Color Space and Channels
A digital image is represented in different color spaces, the color space refers to a specific way of representing colors in an image. It is a three-dimensional model that describes the range of colors that can be displayed or printed. There are several color spaces used in digital imaging, and each...
Friday, August 18, 2023
OpenCV basics continued...Image Fundamentals
PixelsPixels (short for "picture elements") are the smallest units of a digital image. Each pixel represents a tiny point of color that, when combined with other pixels, forms the complete image.Pixels are typically arranged in a grid within a rectangle or square, with each pixel having a specific location...
Monday, August 14, 2023
OpenCV basics continued...Display Webcam
Like displaying videos, a similar technique is used to display webcam. Replace the above Line 6 with cap = cv2.VideoCapture(0), it will load the laptop/desktop’s default webcam and display it.In the previous post the parameter of cv2.VideoCapture() function was the path of the video file, now pass the index of the webcam device as parameter, here 0 is used as the default webcam, it will connect to...
Friday, August 11, 2023
OpenCV basics continued...Load and Display Videos
We were able to load and display an image, now we are going to work with videos, and see how OpenCV can process videos.Open the ShowVideo.py file in PyCharm. If you are not using the Github project, then create a new Python file, and make sure you have a video file available. There is an mp4 video file called “Sample Videos from Windows.mp4” in the Github project, it will be loaded and displayed in...
Monday, August 7, 2023
OpenCV basics continued...
Convert Color Image to GrayscaleAn alternative way to have a grayscale image is to load the original image first, then use cv2.cvtColor() function to convert it to a grayscale image, this way we will have both original and grayscale images available for further processing. This is useful because in...
Friday, August 4, 2023
OpenCV Basics
We'll learn some basic operations supported by OpenCV, such as opening image or video files and displaying them, converting color images to grayscale, or black-white images, connecting to a webcam of a laptop and showing the videos captured by it.1. Load Color Imagescreate a new Python file called...
Tuesday, August 1, 2023
OpenCV
OpenCV is a popular open-source computer vision library that provides a vast range of tools and algorithms for image and video processing. It is originally written in C++, but has interfaces for various programming languages, including Python, Java and so on, it’s a cross-platform library, although this book will focus only on Python. OpenCV is designed to be fast and efficient, making it an ideal...