- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 184 Articles for OpenCV
354 Views
In this program, we will write an image or save an image to a file using OpenCV.AlgorithmStep 1: Import cv2 Step 2: Read the image using opencv.imread() Step 3: Save the image using opencv.imwrite(filename, image)Example Codeimport cv2 import os image = cv2.imread('testimage.jpg') directory = r'C:\Users\prasa\Desktop' os.chdir(directory) cv2.imwrite('CAMERAMAN.jpg', image)OutputThis program will save the image in the directory as same as the original image directoryExplanationEnsure that you have set the proper directory in order for the program to execute without errors.
2K+ Views
In this article, we will learn how to read and display images using the OpenCV library.OpenCV is a library of programming functions mainly aimed at real time computer vision. Before reading an image, make sure that the image is in the same directory as your program.AlgorithmStep 1: Import OpenCV. Step 2: Read an image using imread(). Step 3: Display the image using imshow().Example Codeimport cv2 as cv image = cv.imread ('ronaldo.jpg') cv.imshow('Cristiano Ronaldo', image)Output
32K+ Views
OpenCV is a Python library that is used to solve computer vision problems. Computer vision include understanding and analyzing digital images by the computer and process the images or provide relevant data after analyzing the image.OpenCV is an open-source library used in machine learning and image processing. It performs tasks such as recognizing handwritten digits, human faces, and objects.To use OpenCV, we need to install it.Step 1 − Make sure Python and pip is preinstalled on your systemType the following commands in command prompt to check is python and pip is installed on your system.To check Pythonpython --versionIf Python is ... Read More
409 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
866 Views
Here, we will learn how to track the eye in OpenCV. After detective the eyes, the tracking is an effortless and straightforward task. We used the circle to enclose the detected eyes. Tracking the center of the circle means tracking the center of eyes. To track the center of the circle, we need two integer variables. This has been done on the first two lines (9th and 10th line) inside the main() function. The name of the integer variables is 'x_axis' and 'y_axis'.In line 42 and 43, the horizontal and vertical coordinate values of the center have been copied to ... Read More
874 Views
Here, we will learn how to detect the eye in OpenCV. We will use haarcascade_eye.xml classifier located in 'C:/opencv/sources/data/haarcascades' to detect the eyes. To detect the eyes, we need to add these headers.The first header is , and it is the header of C++ programming language. Reading writing images and user interface functionalities are defined in 'highgui' header. We need to add 'imgproc' header to enhance image quality, and we also use 'objdetect' header to detect face and eyes.The following program to demonstrate how to detect and track eye in OpenCV.Example#include #include #include #include using namespace cv; using namespace std; ... Read More
257 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
2K+ Views
Detecting face in real-time is similar to detecting a face in still pictures. The only difference is in real-time face detection, and we have to take a video stream of computer. In this program, we used 'VideoCapture()' function. This function captures video from other camera and stores the frames temporarily in matrix assigned to it. Here this function captures video from the default camera and temporarily stores the frames in 'real_time' matrix.The following program detects human faces 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 ... Read More
252 Views
When we want to track the position of the face, it is better to enclose the face with ellipse because an ellipse has a center. This center is also the center point of the detected face. As result, tracking the position of detected face becomes more accurate.The following program tracks the center of detected face and show the position in console window −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 image_with_humanface;//Declaring a matrix to load ... Read More
211 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
To Continue Learning Please Login
Login with Google