Common problems and solutions
General problem
Translation: Hunnish, abeer
How to install OpenCV correctly?
Reading installation guide
How to quickly know OpenCV?
Reference sample. Load OpenCV Workspace in Visual Studio:
OpenCV.DSW for Microsoft Visual Studio 6.0 OpenCV.SLN for Miscrosoft Visual Studio .NET 2003 CBUILDERX / OpenCV.BPGR for Borland C Builderx Select CVSample project, compile and run. Read the code and change it according to your own ideas. You can also read the reference manual - some sample code is also included. Search for OpenCV Archives in http://groups.yahoo.com/group/opencv, select the topic you interested. Create a new project from Scratch, or modify existing cvsample. For Microsoft Visual Studio has a ready-made wizard to create an OpenCV project.
Where can I report the BUG of OpenCV?
Send an email to OpenCv@yahoogroups.com Subject: bug <.... your title ...>
How do I report Intel? INGEGRATED Performance Primitives?
Send an email to developer_support@intel.com
How to join the OpenCV Forum?
Email OpenCV-SUBSCRIBE@yahoogroups.com, if you are a member of Yahoo Group and have already logged in. You can read the forum content in http://groups.yahoo.com/group/opencv.
Note: Shanghai Abu Digital Technology Co., Ltd. has set up a Chinese OpenCV Forum that can be found there.
How to modify user group settings make no longer receive a lot of mail?
If you want to receive an email or receive an email one day, you can access http://groups.yahoo.com/mygroups and change the settings.
Ok, I found that the user group is useless. How to retreat the mailing list I subscribe?
Send an email to OpenCV-unsubscribe@yahoogroups.com, the subject subject is [OpenCV]
Compiling errors occur when using OpenCV and IPL simultaneously. how to solve this problem?
In order to completely independently of IPL (Intel's image processing library), OpenCV replicates the declaration of IPLIMAGE and other structural variables. Define Have_IPL in front of the OpenCV header or speak "#include"
"Place the OpenCV header file, you can solve this conflict.
Can OpenCV work under other processors?
Yes, the OpenCV itself is a development source code and is very compact on the 32-bit platform. From another aspect, if an Intel processor is used, then rely on IPP, OpenCV can run faster.
Windows® operating system related issues:
When I try to compile the application, get an error: streams.h has not found it.
You need DirectShow SDK, it is a part of the DirectX SDK.
Download DirectX from msdn.microsoft.com/directX/ (the file is large, but you can only download some). If you don't work properly, consider HIGHGUI to use VFW or MIL to catch video sequences. Take sample installation (TOGETHER with SAMPLES.) Open Project /SampleClas/caSeclasses. (DSW|Sln}. If there is no file, or you have no download sample, or the path is wrong.
Compiling the Release and Debug versions will be generated (in DirectX 9.x, called strmbase.lib and strmbasd.lib) copy to the directory
Under / lib.
Add a path to the developer studio:
/ incrude
/ Samples / C / DirectShow / BaseClasses
To the IncludeS 'search path (in Tools-> Options-> Directories-> include Files in case of development, add)
/ libs in the library search path (in Tools-> Options-> Directories-> Library Files In Case of Developer Studio 6.0)
Note: Add the above-mentioned stuff to the top, otherwise compile or link errors will occur. Because developer Studio 6.0 contains some old version of DirectX header files and library files, they have conflicts with the new version. Datual!
After installing DirectX SDK, there is still a link error, prompt: undefined or redefined "Transinplace" Filter Class Constructors etc.
Read the previous demonstration, pay special attention to the order of the search directory.
When I try to use CVCAM, the program crashes
Make sure to register ProxyTrans.AX and SyncFilter.ax
How to register * .ax (DirectShow Filter)?
Run file regr32.exe
FILTER cannot be registered (Regsvr32 report error)
The most likely reason is that some of the DLLs required by Filter are not in the path, in which case OpenCV ensures
/ bin is in the path.
Cxcore096d.dll or cxcored.lib seems to be lost
Cxcore096d.dll is the debug version of the CXCore DLL, cxcored.lib is the input library of cxcore096d.dll. Open Open OpenCV Workspace, select "cxcore" as Active Project, and select "Win32 Debug" configuration. Compile the establishment library so that bin / cxcore096d.dll and lib / cxcored.lib are obtained. The same steps can generate all other OpenCV components. Plus D represents the Debug version.
When I compile highgui, get the error "MIL.H is not found" Mil.h is a part of Matrox Imaging Library (Mil), providing Matrox (or compatible) video capture card, such as Meteor, Meteor II, etc.
If you have such a framegrabber and MIL installed, add mil / include and mil / lib to the search paths within Developer Studio (submenu Tools-> Options-> Directories). If you do not have MIL, just ignore the error. The file mil.h is only required to build MIL-aware version of highgui "Win32 MIL Debug" or "Win32 MIL Release". Select "Win32 Debug" or "Win32 Release" configuration of highgui (submenu Build-> Set Active Configuration ... ) INSTEAD - THESE VERSIONS OF HIGHGUI CAN STILL BE Used to Grab Video Via VIA VFW Interface, Work with Avis and Still Images. How to debug DirectShow Filter?
Turn on the Workspace (Eg OpenCv.dsw) with Filter, select Filter as an active item, establish a debug configuration, register the Filter's debug version (ie, runregs REGSVR32 CAMSHIFTD.AX (just once, save only Filter in the registry The file name), go back to developer studio and start the debugging process (F5). Under "Do You Want To Run To Debug THE MOD", select CamshiftDemo to debug DirectShow Filter through the Camshift.ax and DirectX SDK Tool Graphhedit Create a Filter map in Graphedit (ie, Camera-> Camshift-> Renderer) Save Graph (next simple load) to set breakpoints in the filter method or other location in Filter. Run Filter, and. . .
How to create a developerstudio project to start playing OpenCV
(Note: This is an application answer)
In order to create an OpenCV-based project under developer studio, follow these steps:
Create a new application in Developer Studio:
Select menu "file" -> "new ..." -> "projects". Select "Win32 Application" or "Win32 Console Application" - the latter is a simpler method. Type the project name and select a storage location to create a separate Workspace ("Create New Workspace"), you can also add new items to the current Workspace ("Add to Current Workspace"). Click "NEXT" Select "An Empty Project", click "Finish", "OK". After the above steps, developer Studio creates a project directory (by default, the directory name is the project name),
.dsp file and
.dsw, .ncb ..., if you create your own workspace. Add file to Project:
Select menu "file" -> "new ..." -> "files". Select "C Source File", type the file name, click "OK" Add OpenCV-related header file directory #include: #include "CV.h "
/ * #inlcude "cvaux.h" // Experimental stuff (if need) * /
#include "highgui.h"
Or you can copy some existing files (such as: OpenCV / Samples / C / Morphology.c) to the project directory, open it, and join the project (right click on the editor -> "Insert File Into Project" ->
).
Configuration item:
Select menu "Project" -> "Settings ..." to activate the project configuration dialog. Select your project on the left. Adjust settings, valid for Release and Debug configuration:
Select "Settings for:" -> "All configurations" Select "C / C " Tab -> "Preprocessor" Category -> "Additional INCLUDE DIRECTORIES:". Add a comma-separated relative path (for file .dsp) or Absolute path OpenCV / CXCORE / include, OpenCV / CV / Include, OpenCV / OtherLibs / Highgui, Optional, OpenCV / CVAUX / include. Select "Link" Tab -> "INPUT" Category -> "Additional Library Path:" Add to the path where the input library is located (Cxcore [D] .lib CV [D] .lib Hihghui [D] .lib CVAUX [D] .lib) Adjusts "Debug" configuration:
Select "SETTINGS for:" -> "Win32 Debug". Select "LINK" Tab -> "General" Category -> "Object / library modules". Add a space separated CVD.Lib, Highguid.lib, CVAUXD.LIB (optionally ) Change the name and location of the output file. If you want to place the generated .exe file in the project directory instead of a debug / subdirectory, you can type in "Link" Tab -> "General" category -> "Output File Name:".
D.exe
Adjust "Release" configuration
Select "Settings for:" -> "Win32 Release". Select "LINK" Tab -> "General" Category -> "Object / library modules". Add a space separated CV.Lib, Highgui.lib, CVAUX.LIB (optionally Add from attribute items to Workspace:
Select menu: "Project" -> "Insert Project Into Workspace". Select OpenCV / CV / Make / Cv.dsp. Similar steps to OpenCV / CVAUX / MAKE / CVAUX.DSP, OpenCV / OtherLibs / Highgui / Highgui.dsp. set From attribute:
Select menu: "Project" -> "dependencies ..." Select "CXCORE" for "CV", select "CVAUX", "cxcore", select "CXCORE" for "HighGUI", to your project, Select all: "cxcore", "cv", "cvaux", "highgui". From the property configuration, it is guaranteed that the OpenCV library is automatically recompiled in the case where the source code is changed. It is so much. You can compile and run everything.
Linux related questions: Todo
Technical issues using libraries:
How to access image elements
(The coordinate start point relative to the image origin image origin starts from 0, or the upper left corner (IMG-> Origin = IPL_ORIGIN_TL) or the upper left corner (IMG-> Origin = IPL_ORIGIN_BL)
It is assumed that there is an 8-bit 1-channel image I (iPlimage * IMG): i (x, y) ~ (uchar *) (IMG-> ImageData IMG-> widthstep * y) [x]
There is a 8-bit 3-channel image I (iPlimage * IMG): i (x, y) blue ~ ((uchar *) (IMG-> ImageData IMG-> Widthstep * Y) [x * 3]
I (x, y) Green ~ (uchar *) (IMG-> ImageData IMG-> widthstep * y) [x * 3 1]
I (x, y) red ~ (uchar *) (IMG-> imageData IMG-> widthstep * y) [x * 3 2]
If the brightness 30 of the point (100, 100) is increased, then it is: CVPOINT PT = {100, 100};
((uchar *) (IMG-> ImageData IMG-> widthstep * pt.y)) [pt.x * 3] = 30;
((uchar *) (IMG-> imageData img-> widthstep * pt.y)) [PT.X * 3 1] = 30;
((uchar *) (IMG-> ImageData IMG-> widthstep * pt.y)) [PT.X * 3 2] = 30;
Or more effective CVPOINT PT = {100,100};
Uchar * TEMP_PTR = & ((Uchar *) (IMG-> ImageData IMG-> Widthstep * Pt.y)) [x * 3];
TEMP_PTR [0] = 30;
TEMP_PTR [1] = 30;
TEMP_PTR [2] = 30;
There is a 32-bit floating point number, 1-channel image I (iPlimage * IMG): i (x, y) ~ ((FLOAT *) (IMG-> ImageData IMG-> widthstep * y) [x]
Now, general method: there is an N-channel, type T. Image: i (x, y) c ~ ((t *) (img-> imagedata img-> widthstep * y) [x * n c ] Or you can use Macro CV_IMAGE_ELEM (Image_Header, ElemType, Y, X_NC)
I (x, y) c ~ cv_image_elex (IMG, T, Y, X * N C)
There are also functions (CVGET2D, CVSET2D) for various images, including 4-channels) and matrices, but they are very slow.
How to access matrix elements?
Method is similar (all columns and rows for 0 starting points)
There is a real matrix M (CVMAT * MAT) of 32-bit floating point number: M (i, j) ~ ((Float *) (MAT-> DATA.PTR MAT-> Step * i)) [J]
A total of 64-bit floating point numbers is a plural matrix M (CVMAT * MAT): RE M (i, j) ~ (Double *) (MAT-> DATA.PTR MAT-> Step * i)) [J * 2 ]
IM M (i, j) ~ ((Double *) (MAT-> DATA.PTR MAT-> Step * i)) [J * 2 1]
There is a single channel matrix, with macro CV_MAT_ELEM (Matrix, ElemType, Row, COL), such as real matrix M (I, J) ~ CV_MAT_ELEM (MAT, FLOAT, I, J) for 32-bit floating point numbers, if initialized 3x3 Unit array: CV_MAT_ELEM (MAT, FLOAT, 0, 0) = 1.f;
CV_MAT_ELEM (MAT, FLOAT, 0, 1) = 0.F;
CV_MAT_ELEM (MAT, FLOAT, 0, 2) = 0.F;
CV_MAT_ELEM (MAT, FLOAT, 1, 0) = 0.F;
CV_MAT_ELEM (MAT, FLOAT, 1, 1) = 1.f;
CV_MAT_ELEM (MAT, FLOAT, 1, 2) = 0.F;
CV_MAT_ELEM (MAT, FLOAT, 2, 0) = 0.F;
CV_MAT_ELEM (MAT, FLOAT, 2, 1) = 0.F;
CV_MAT_ELEM (MAT, FLOAT, 2, 2) = 1.f;
How to handle my own data in OpenCV
Let you have 300x200 32-bit floating point image / array, which is an array of 60000 elements.
INT COLS = 300, ROWS = 200;
Float * myarr = new float [rows * cols];
// step 1) Initializing Cvmat Header
Cvmat Mat = CVMAT (Rows, Cols,
CV_32FC1, // 32-bit floating-point, Single Channel Type
Myarr // User Data Pointer (No Data IS Copie)
);
// Step 2) Using CV Functions, E.G. Calculating L2 (frobenius) NORM
Double Norm = CVNORM (& Mat, 0, CV_L2);
...
Delete myarr;
Other situations are described in the reference manual. See cvcreatematheader, cvinitmatheader, cvcreateImageheader, cvsetdata etc.
How to load and display images
/ * Usage: Prog
* /
#include "cv.h" #include "highgui.h"
INT main (int Argc, char ** argv)
{
IPLIMAGE * IMG;
IF (Argc == 2 && (IMG = CVLoadImage (Argv [1], 1))! = 0)
{
CVNameDwindow ("Image View", 1);
CvShowImage ("Image View", IMG);
CvwaitKey (0); // Very Important, Contains Event Processing Loop Inside
CVDESTROYWINDOW ("Image View");
CVRELEASEIMAGE (& IMG);
Return 0;
}
Return -1;
}
How to find and process outline
Please see the demo Squares
How to calibrate the camera with opencv
Todo
-----------------
敕敕川, 阴 山
It is like a mountain, shrouded four wild
Tiantang, wild, wind, grass, low cows and sheep