This case will introduce histogram calculation and histogram equalization, histogram calculation is very useful, in many cases can be used, not only in the image of the gray value, but also in the image of other features; Image equalization is often used in image preprocessing, it can enhance contrast, Makes the pixel intensity distribution range more widely. 1. Principle
Histogram calculation:
Http://www.opencv.org.cn/opencvdoc/2.3.2/html/doc/tutorials/imgproc/histograms/histogram_calculation/h
The involved functions are as follows:
Vcapture * cvcreatecameracapture (INT index)
The index of the camera to be used. If it is-1, a camera is randomly selected.
This function also returns the capture * pointer.
Iplimage * cvqueryframe (cvcapture * capture)
Function cvqueryframe captures a frame from a camera or video file, decompress the frame, and return the frame.
The Code is as follows:
# Include "stdafx. H "# include
Reference learning
Read a video and save each frame of the video as a PNG image,
Download the code in this article
The first problem to be solved here is to generate a name for the image by Subscript:
This function counts the image frames in the video and outputs the file name, which is saved in PNG format.
Example: f00005.png
String namegenerate (unsigned int framecounter) {unsigned int num = num2str1 (framecounter ). length (); //
Main Code for converting a video into an image:
///
Duanxx
changeImagebluechannel = channels.at (0);//"4" weighted the area at the bottom right of the blue Channel (500,250) of the original image and the logo map, and the resulting mixed results are stored in the Imagebluechannel. Simply speaking, the blue channel of the original is replaced with the logo to replace the blue channel. Addweighted (Imagebluechannel (Rect ( -, -, Logoimage.cols, logoimage.rows)),1.0, Logoimage,0.5,0, Imagebluechannel (Rect ( -, -, Logoimage.cols, logoimage.rows));//"5" to
1#include 2#include 3usingnamespaceStd4usingnamespaceCv5//----------------------Fusion function ——-------6BOOLRoi_addimg ()7{8Mat srcimage = Imread ("3.jpg");9Mat logoimage = Imread ("1.jpg");Ten//detecting whether to read picture data Oneif(!srcimage.data) A{ -cout"no src data" -} theif(!logoimage.data) -{ -cout"No Logo data" -} +//define a mat type and specify ROI area -Mat roiimage = Srcimage (Rect (0,0, logoimage.cols,logoimage.rows)); +//Add Weights A Addweighted (Roiimage,0.7, Logoimage,0.
,//matrix pointer int start_col,//start column. Includes the int end_col//end column. not included);Instance Code#include Output results(4) Cvgetdiag functionIts structurecvmat* Cvgetdiag (///Take out a specific diagonal const cvarr* arr,//target matrix cvmat* submat,//matrix pointer int diag = 0//control scalar, 0 main diagonal, 1 or-1 for 0 adjacent diagonal. And so on);Instance Code#include Output resultsTo be Continued Copyright notice: This article blog original articles, blogs, without con
Operation of matrices and images(1) Cvand functionIts structurevoid Cvand ( //Src1 and SRC2 by Pixel point "bitwise AND operation" Const cvarr* src1,//First Matrix const cvarr* src2,//second matrix cvarr* dst,//result Matrix Const Cvarr * Mask = null;//matrix by the line pixel point and the "switch");Program Examples#include Output Results(2) cvands functionits structurevoid Cvands (//Make SRC1 and value bitwise AND Operation const cvarr* src1,//first matrix cvscalar value,//operation scalar cv
OpenCV Learning Record: filter: Line sketch
Line Filter
The line filter outlines the main contour of an image. The processing process is as follows:Grayscale image Filtering Edge Detection
Binarization
The complete code is as follows:
# Include
# Include
Using namespace cv; using namespace std; void xianTiaoFilter (Mat srcImage); int main () {Mat srcImage = imread ("lena.jpg"); if (! SrcIm
Union: when multiple data requires shared memory or multiple data is only one at a time, you can use the Union1. A consortium is a structure;2. All of his members have an offset of 0 relative to the base address;3. This structure space is large enough to accommodate the most "wide" members;But the size is not only determined by the widest members, but also by considering the individual alignment of each member!4. Its alignment should fit all of its members.C + + and
1. Key functions1. Read in picture imread (picture or position, display format):imread_colorDisplay format: imread_unchanged=-1//8bit,coloror not NBSP;NBSP; imread_grayscale=0//8bit , gray NBSP;NBSP; imread_color =1// color NBSP;NBSP; imread_anydepth=2// anydepth, NBSP; Imread_anycolor = 4//Any color 2. Display Picture imshow (picture name, mat type picture)There are a lot of examples with Namedwindow in it, but I find that there is no problem. Maybe I haven't found it yet
The first thing to say is that the toolkit is very handy and can be extracted. Add the path to this folder in the project.Here are some code exercises:#include The following transpose is used:#include The following example removes a sub-matrix from a matrix (note that the two methods are the same.)The paper that was reproduced is wrong here.。 )#include Here are some operations of the vector:#include Come down and look at the basic assignment situation:#include Here's how to assign the following
The structure of the video file:
Each video fileNatureIsContainer, FileExtensionOnly indicatesContainer format(For exampleAvi, mov, or MKV) andNot the compression format of videos and audios.
There may be many elements in the container, suchVideo Stream,Audio streamsAnd someSubtitle streamAnd so on. These streamsStorage MethodIs corresponding to each streamCodec). Generally, audio streams are likely to be used.MP3 or AAC format for storage. More video formats, usuallyXvid, DivX, h264, or lags (l
number of feature points reduced from 49 to 33 after filtering, and the matching accuracy increased. Of course, you can also use the SIFT operator to perform the above two matching experiments. You only need to replace SurfFeatureDetector with SiftFeatureDetector and replace SurfDescriptorExtractor with SiftDescriptorExtractor.
Expansion
Based on the FLANN matching method, we can further use the perspective transform and spatial ing to find known objects (Target Detection). Specific
Highgui is a graphical user interface module. Including:1, input and output;2, video capture;3, graphics and video decoding code;4, graphics interface and interfaces.Because OPENCV.HPP contains the core, Objdetect, Ingproc, photo, video, featurse2d, calib3d, ML, Highgui, contrib and other modules. General development Lazy#include Namespaces will let you write code simple: using namespace CV, then you can Imread (... Otherwise you will have to c::imread every time (...) )。Mat Class (OPENCV2): Thi
; intR =0, C =0; DoubleINV_R2 =0; Cv_assert (Shape= = Morph_rect | | Shape = = Morph_cross | | Shape = =morph_ellipse); Currently supports three shapes of cell creation: rectangular, cross-shaped, oval; Anchor=Normalizeanchor (anchor, ksize); When the default is -1,-1, calculate anchor; if(Ksize = = Size (1,1))//When a given size of 1, 1 o'clock, indicates a point, which can be represented by a rectangle; shape=Morph_rect; if(Shape = =morph_ellipse)//ellipse; {R= ksize.height/2; C= ksize.widt
Source code: http://download.csdn.net/detail/nuptboyzhb/3961668
New Content in version 1.0.x
Video motion detection
Ø create menu items, learning opencv --> opencvr entry --> video motion detection
The menu items are set as follows:
Create a Class Wizard
ØEdit code
Voidccvmfcview: onmytestsport ()
{
// Todo: add your command handler codehere
// Alt + F8 sort out the code
Cvcapture * capture;
Capture = cvc
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.