Learn OpenCV by Examples
OpenCV simplified for beginners by the use of examples. Learn OpenCV with basic implementation of different algorithms. Please visit LearnOpenCV.com for newer articles.
- Website
- opencvexamples.blogspot.de · all feeds from this site
- Feed URL
https://opencvexamples.blogspot.com/feeds/posts/default
Read it in your FeedListing reader
Or add to: Feedly Inoreader Raw feed
Latest posts
-
Discrete Fourier Transform
The Fourier Transform will decompose an image into its sinus and cosines components. It will transform an image from its spatial domain to its frequency domain. Mathematically a two dimensional images Fourier transform is: Here f is the image value in its spatial domain and F in…
-
Crop elliptical region from image
We know that we can represent image as a matrix, and matrix can not be elliptical. So when you want to crop a elliptical area from an image, then you have to extract the elliptical region and remove rest of the information outside the ellipse. This can be done by AND operation…
-
Calculating absolute values with scaling
void convertScaleAbs (InputArray src, OutputArray dst, double alpha=1, double beta=0) - Scales, calculates absolute values, and converts the result to 8-bit. Parameters: src – input array. dst – output array. alpha – optional scale factor. beta – optional delta added to the…
-
Window management in OpenCV
void namedWindow (const string&winname, int flags=WINDOW_AUTOSIZE ) Parameters: name – Name of the window in the window caption that may be used as a window identifier. flags – Flags of the window. Currently the only supported flag is CV_WINDOW_AUTOSIZE. If this is set, the…
-
Perspective Transform
Mat getPerspectiveTransform (InputArray src, InputArray dst) - Calculates a perspective transform from four pairs of the corresponding points. void warpPerspective (InputArray src, OutputArray dst, InputArray M, Size dsize, int flags=INTER_LINEAR, int borderMode=BORDER_CONSTANT,…
-
Rotate image
void warpAffine (InputArray src, OutputArray dst, InputArray M, Size dsize, int flags=INTER_LINEAR, int borderMode=BORDER_CONSTANT, const Scalar& borderValue=Scalar()) Parameters: src – input image. dst – output image that has the size dsize and the same type as src . M –…
-
CAPTCHA formation in OpenCV
A CAPTCHA (an acronym for "Completely Automated Public Turing test to tell Computers and Humans Apart") is a type of challenge-response test used in computing to determine whether or not the user is human. It protects your website from spam by means of math logic, easily…
-
Histogram Equalization
void equalizeHist (InputArray src, OutputArray dst) Parameters: src – Source 8-bit single channel image. dst – Destination image of the same size and type as src . Example: ---------- #include "opencv2/core/core.hpp" #include "opencv2/highgui/highgui.hpp" #include…
-
Select a region on mouse click
The following program allows the user to select a point on the image and extracts the region around that point, from which it extracts information such as mean and variance of the locality. void setMouseCallback (const string& winname, MouseCallback onMouse, void* userdata=0 ) -…
-
Detect Mouse Clicks and Moves on Image Window
void setMouseCallback (const string& winname, MouseCallback onMouse, void* userdata = 0) This function sets a callback function to be called every time any mouse events occurs in the specified window. Here is the detailed explanation of the each parameters of the above OpenCV…
-
Resize image
void resize (InputArray src, OutputArray dst, Size dsize, double fx=0, double fy=0, int interpolation=INTER_LINEAR ) - The function resize resize s the image src down to or up to the specified size. Parameters: src – input image. dst – output image; it has the size dsize (when…
-
Kalman Filter Implementation (Tracking mouse position)
KalmanFilter:: KalmanFilter (int dynamParams, int measureParams, int controlParams=0, int type=CV_32F) Parameters: dynamParams – Dimensionality of the state. measureParams – Dimensionality of the measurement. controlParams – Dimensionality of the control vector. type – Type of…
-
Face detection using webcam
Example: ---------- #include "opencv2/objdetect/objdetect.hpp" #include "opencv2/highgui/highgui.hpp" #include "opencv2/imgproc/imgproc.hpp" #include using namespace cv; using namespace std; int main() { Mat image; CvCapture* capture; // Read the video stream capture =…
-
Putting a mask on face using OpenCV
This is a example to put a mask on your face. This is a fun application that is meant to be used for entertainment purpose. You might have seen such apps in google hangouts. Steps: Detect face from the input video frame Load the mask and make the white region of the mask…
-
Calculating time taken by the code
How to calculate the time of execution of the code??? Here is a small code to make use of "time.h" for tracking the time of execution. Example 1: ------------ #include ...***...***...***... clock_t start, end; double elapsed; start = clock(); /* Your code */ end = clock();…
-
Faster face detection by varying detectMultiScale function parameters
In example 1, a simple face detection code is provided which runs at 1-2 frames per second. To make it faster, we can modify the parameters to detectMultiScale function to achieve very high frame rate. Example 2 provides the code for minor optimization of code to make it…
-
Bitwise AND, OR, XOR and NOT
void bitwise_and (InputArray src1, InputArray src2, OutputArray dst, InputArray mask=noArray()) Calculates the per-element bit-wise conjunction of two arrays or an array and a scalar. Parameters: src1 – first input array or a scalar. src2 – second input array or a scalar. src –…
-
Histogram Calculation
void calcHist (const Mat* images, int nimages, const int* channels, InputArray mask, OutputArray hist, int dims, const int* histSize, const float** ranges, bool uniform=true, bool accumulate=false ) Calculates a histogram of a set of arrays. Parameters: images – Source arrays.…
-
Split and Merge functions
void split (InputArray m, OutputArrayOfArrays mv) Divides a multi-channel array into several single-channel arrays. Parameters: src – input multi-channel array. mv – output array or vector of arrays; in the first variant of the function the number of arrays must match…
-
Convex Hull
X is a bounded subset of the plane, the convex hull may be visualized as the shape formed by a rubber band stretched around X . The convex hull of a set X of points in the Euclidean plane is the smallest convex set that contains X. when Formally, the convex hull may be defined…