OpenCV Articles

Page 8 of 11

Blurring an image using the OpenCV function blur()

Prasad Naik
Prasad Naik
Updated on 25-Mar-2026 486 Views

In this tutorial, we will learn how to blur an image using the OpenCV blur() function. Blurring reduces image noise and detail by averaging pixel values in a neighborhood defined by a kernel. Algorithm Step 1: Import OpenCV and NumPy libraries Step 2: Load the input image Step 3: Define the kernel size for blurring Step 4: Apply the blur() function with image and kernel parameters Step 5: Display or save the blurred result Understanding the blur() Function The cv2.blur() function performs simple box filtering. It takes the average of all pixels in the ...

Read More

Draw a filled polygon using the OpenCV function fillPoly()

Prasad Naik
Prasad Naik
Updated on 25-Mar-2026 8K+ Views

In this tutorial, we will learn how to draw a filled polygon using OpenCV's fillPoly() function. This function fills a polygon defined by a set of vertices with a specified color. Syntax cv2.fillPoly(image, pts, color) Parameters The fillPoly() function accepts the following parameters ? image ? The input image on which to draw the polygon pts ? Array of polygon vertices (points) color ? Fill color of the polygon in BGR format Algorithm Step 1: Import cv2 and numpy Step 2: Define the polygon vertices (endpoints) Step 3: ...

Read More

Mapping CSV to JavaBeans using OpenCSV

Way2Class
Way2Class
Updated on 28-Jul-2023 2K+ Views

CSV files are basically plain text files that stores data in columns separated a comma. OpenCSV is the library that parses these CSV files which are quite difficult to handle otherwise. It is a quite easy to use library that supports several features like reading and writing of CSV files with headers. We will be discussing the mapping of CSV files to JavaBeans via OpenCSV in this article. Additionally. OpenCSV is a tool that aids in this process. Mapping the CSV to JavaBeans The OpenCSV library provides certain classes and mapping strategies to map the CSV files into Java Beans. ...

Read More

How to detect and track the motion of eyeball in OpenCV using C++?

Ginni
Ginni
Updated on 10-Mar-2021 643 Views

Here, we will learn how to detect and track the motion of eyeball in OpenCV.The following program demonstrates to detect the eyeball and track the location.Example#include #include #include #include #include #include using namespace cv; using namespace std; Vec3f eyeBallDetection(Mat& eye, vector& circles) {    vectorsums(circles.size(), 0);    for (int y = 0; y < eye.rows; y++) {       uchar* data = eye.ptr(y);       for (int x = 0; x < eye.cols; x++) {          int pixel_value = static_cast(*data);          for (int i = 0; i < circles.size(); i++) {   ...

Read More

How to track the face in real-time in OpenCV using C++?

Ginni
Ginni
Updated on 10-Mar-2021 440 Views

We will learn how to track the face in real-time in OpenCV. This program is same to the previous program and difference is that we used ellipse instead of rectangle to identify the face and we also used additional 'cout' statement to show the co-ordinate of the face in the console window.The following program to detect human face in real-time −Example#include #include #include //This header includes definition of 'rectangle()' function// #include //This header includes the definition of Cascade Classifier// #include using namespace std; using namespace cv; int main(int argc, char** argv) {    Mat video_stream;//Declaring a matrix hold frames from ...

Read More

How to detect the largest face in OpenCV using C++?

Ginni
Ginni
Updated on 10-Mar-2021 376 Views

We will learn how to detect the largest face only. This topic is same as the previous topic. The only difference is we used an additional 'Rect' structure and a 'for loop' to detect the largest face.The actual format of this function −Mat faceROI = image_with_humanface(maxRect)The maxRect have the area and location information of the largest face located on the image. The line above is cropping the same area stored in maxRect on the same location where the largest face is located on the image and storing in 'faceROI' matrix.The following program detects the largest face from still pictures −Example#include ...

Read More

How to crop the detected faces in OpenCV using C++?

Ginni
Ginni
Updated on 10-Mar-2021 860 Views

We will know how to crop the detected faces in OpenCV. To crop detected faces, we need multiple matrices. The most appropriate way is to use an image array. In this program using the following two lines, we have declared two image matrices −Mat cropped_faces[4];Mat faceROI[4];The first matrix is to store the cropped images, and the second matrix is to define the region of interest. In the detection process, first, the program locates the faces and store them in vectors. In our program, the name of the vector is 'faces' Vectors can contain multiple elements.Using the following two lines, we ...

Read More

How to detect the face in still picture in OpenCV using C++?

Ginni
Ginni
Updated on 10-Mar-2021 811 Views

We detect the faces from the image. To detect the face, we used 'detectMultiScale()' function.The actual format of this function is −SyntaxdetectMultiScale(source matrix, vector, searchScaleFactor, minNeighbours, flags, minfeatureSize)By changing the function arguments, we can control the 'detect.MultiSpace()' function. This function takes the following arguments.Source MatrixIt is the matrix where the face will be detected. In this case, it will the matrix which is keeping the video frames.VectorThe 'detect.MultiScale()' function will be a vector of rectangular type. A rectangle is a vector in OpenCV, and we have to define it as a vector.searchScaleFactorSearch scale factor determines how many different sizes of ...

Read More

How to detect the color using OpenCV in C++?

Ginni
Ginni
Updated on 10-Mar-2021 2K+ Views

We will understand how to detect specific color and track object based on color. Performance of color detection and color detection based tracking system is environment dependent.If you change light of the room or if you change background color, there will be significant effect on color detection.The following program demonstrates how to detect the color using OpenCV in C++.Example#include #include #include using namespace std; using namespace cv; int main(int argc, char** argv) {    VideoCapture video_load(0);//capturing video from default camera//    namedWindow("Adjust");//declaring window to show the image//    int Hue_Lower_Value = 0;//initial hue value(lower)//    int Hue_Lower_Upper_Value = 22;//initial hue ...

Read More

How to rotate a video in OpenCV using C++?

Ginni
Ginni
Updated on 10-Mar-2021 669 Views

Rotating a video is similar to rotate an image. The only difference is instead of load a still picture into an image matrix, we have loaded a video or take video stream from the camera.Here, we are not loading the video but taking a video using the camera. If you want to use a video file, just put the address of the video file properly.The following program demonstrates how to rotate a video in OpenCV using C++.Example#include #include #include using namespace std; using namespace cv; int main(int argc, char* argv[]) {    VideoCapture loadvideo(0);//capture video from default camera//    namedWindow("OriginalVideo");//declaring ...

Read More
Showing 71–80 of 107 articles
« Prev 1 6 7 8 9 10 11 Next »
Advertisements