Opencv general problems

Source: Internet
Author: User
Tags image processing library
Document directory
  • How to correctly install opencv?
  • How to quickly get to know opencv?
  • Where can I report the bug of opencv?
  • How to report intel? Ingegrated performance primitives bug?
  • How to join the opencv forum?
  • How can I modify the user group settings so that I no longer receive a large number of emails?
  • Okay. I found that user groups are useless. How do I remove my subscribed email list?
  • When opencv and IPL are used at the same time, a compilation error occurs. How can this problem be solved?
  • Can opencv work on other processors?
  • When I tried to compile the application, I got the error: streams. h didn't find it.
  • After the DirectX SDK is installed, there is still a link error, and the prompt is: undefined or redefined "transinplace" filter class constructors etc.
  • When I try to use cvcam, the program crashes
  • Camshiftdemo can not be run
  • How to register *. Ax (DirectShow filter )?
  • Filter cannot be registered (regsvr32 reports an error)
  • Lkdemo/hmmdemo reports an error during startup and no the view is completely black
  • Cxcore096d. dll or cxcored. Lib seems to be lost
  • When I compile highgui, the error "mil. H is not found" is returned"
  • How to debug DirectShow filter?
  • How to access image elements
  • How to access matrix elements?
  • How to process my own data in opencv
  • How to load and display images
  • How to discover and process outlines
  • How to Use opencv to calibrate the camera
General questions How to correctly install opencv?

Read Installation Guide

How to quickly get to know opencv?

 

  1. Reference example.
  2. 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

    SelectcvsampleProject, compile and run. Read the code and change it as needed.

  3. You can also read the reference manual, which also contains some sample code.
  4. Search for opencv archives in the http://groups.yahoo.com/group/OpenCV and select the topic you are interested in.
  5. Create a new project from scratch or modify the existingCvsample. PairMicrosoft Visual Studio has a ready-made Wizard to create an opencv project.
Where can I report the bug of opencv?

Mail to OpenCV@yahoogroups.com subject: Bug <... your title...>

How to report intel? Ingegrated performance primitives bug?

Mail to developer_support@intel.com


How to join the opencv forum?

E-mail OpenCV-subscribe@yahoogroups.com if you are a member of Yahoo group and have logged in. You can read the Forum content in http://groups.yahoo.com/group/OpenCV.

Note: Shanghai axu Digital Technology Co., Ltd. has set up a Chinese opencv forum where many useful materials can be found.

How can I modify the user group settings so that I no longer receive a large number of emails?

To receive messages in real time or receive a mail abstract only once a day, you can access the http://groups.yahoo.com/mygroups and then change the settings.

Okay. I found that user groups are useless. How do I remove my subscribed email list?

Mail to OpenCV-unsubscribe@yahoogroups.com, subject is[Opencv]

When opencv and IPL are used at the same time, a compilation error occurs. How can this problem be solved?

To be completely independent from IPL (Intel's image processing Library), opencv copies iplimage and other schema variable declarations. Defining have_ipl before the opencv header or placing the statement "# include <IPL. h>" in front of the opencv header file can solve this conflict.

Can opencv work on other processors?

Yes, opencv itself is developed with source code and is very compact on 32-bit platforms. On the other hand, if an Intel processor is used, IPP enables opencv to run faster.

Windows OS problems: When I tried to compile the application, I got the error: streams. h didn't find it.

You need the DirectShow SDK, which is a part of the DirectX SDK.

  1. Download DirectX from msdn.microsoft.com/directx ). If it cannot work properly, consider how highgui uses VFW or mil to capture video sequences.
  2. Install with the example (together with samples .)
  3. Open the project <directxsdkinstallfolder>/samples/C ++/DirectShow/baseclasses. {DSW | SLN }. if you do not have this file, either you have not downloaded the sample file or the path is incorrect.
  4. Compile and build the release and DEBUG Versions
  5. Copy the generated libraries (strmbase. lib and strmbasd. Lib in DirectX 9.x) to the <directxsdkinstallfolder>/lib directory.
  6. Add a path in developer studio:

    <Directxsdkinstallfolder>/include
    <Directxsdkinstallfolder>/samples/C ++/DirectShow/baseclasses

    Go to the include' search path (in tools-> options-> directories-> include files in case of developer Studio 6.0)

    Add <directxsdkinstallfolder>/lib to the library search path (choose tools> Options> directories> library files in case of developer Studio 6.0)

    Note:: Add the added items to the top of the page. Otherwise, a compilation or link error occurs. Developer Studio 6.0 contains some older versions of DirectX header files and library files, which conflict with the new version.

  7. Success!
After the DirectX SDK is installed, there is still a link error, and the prompt is: undefined or redefined "transinplace" filter class constructors etc.

Read the previous example and pay special attention to the order of searching directories.

When I try to use cvcam, the program crashes

Make sure that proxytrans. Ax and syncfilter. Ax are registered.


How to register *. Ax (DirectShow filter )?

Run the regsvr32.exe file.

Filter cannot be registered (regsvr32 reports an error)

The most likely cause is that some DLLs required by the filter are not in the path. In this case, opencv ensures that <openinstallfolder>/bin is in the path.


Cxcore096d. dll or cxcored. Lib seems to be lost

Cxcore096d. dll is the debug version of cxcore DLL, and cxcored. Lib is the input library of cxcore096d. dll. Open opencv workspace, select "cxcore" as the active project, and select "Win32 debug" configuration. compile and create the library to get bin/cxcore096d. DLL and LIB/cxcored. lib. In the same step, all other opencv components can be generated. AddDIndicates the debug version.

When I compile highgui, the error "mil. H is not found" is returned"

Mil. H is a part of matrox imaging Library (MIL). It provides matrox (or compatible) video capture cards, such as meteor and meteor II.

  • 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 VFW interface, work with Avis and still images.
How to debug DirectShow filter?

 

  • Open the workspace with filter (e.g. opencv. DSW ),
  • Select filter as the active project and create the debug configuration,
  • Register the debug version of the filter (that is, run regsvr32 camshiftd. Ax) (you only need to do it once, and only save the file name of the filter in the registry ),
  • Return to developer studio and start the debugging process (F5 ). under the "do you want to run to debug the module" prompt, select camshiftdemo to use camshift. ax and DirectX SDK Graphical Editor graphedit to debug DirectShow filter.
  • Create a filter graph (camera-> camshift-> Renderer) in graphedit)
  • Save graph (next time you load it easily)
  • Set the breakpoint in the transform method or other locations in the filter.
  • Run filter and...
How to Create a movie studio project to start playing opencv

(Note: This is an application answer)

To create an opencv-based project under developer studio, follow these steps:

  1. Create an application in developer studio:

    1. Select "file"-> "new..."-> "Projects". It is easier to select "Win32 application" or "Win32 console application"-the latter.
    2. Type A project name and select a storage location
    3. You can create a separate workspace ("create new workspace") for the project, or add a new project to the current workspace ("add to current workspace ").
    4. Click "Next"
    5. Select "An Empty Project" and click "finish", "OK ".

    After the preceding steps, developer studio creates a project directory (by default, the directory name is the project name), <Project Name>. DSP file and <Project Name>. DSW ,. NCB ..., if you create your own workspace.

  2. Add a file to the project:
    • Choose "file"-> "new..."-> "Files ".
    • Select "C ++ source file", type the file name, and click "OK"
    • Add the directory of opencv-related header files # 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) open it in the project directory and add it to the project (right-click the view in the editor and choose "insert file into project"> <your project name> ).

  3. Configuration item:
    • Select "project"-> "Settings..." to activate the project configuration dialog box.
    • Select your project on the left.
    • Adjustment settings are effective for both release and debug configurations:
      • Select "settings for:"-> "all deployments"
      • Select "C/C ++" tab-> "Preprocessor" category-> "Additional include directories :". add a relative path separated by commas. DSP) or absolute path opencv/cxcore/include, opencv/cV/include, opencv/otherlibs/highgui and optional optionally, opencv/cvaux/include.
      • Select "Link" tab-> "input" category-> "Additional library path :". path to join the input Library (cxcore [D]. lib CV [D]. lib hihghui [D]. lib cvaux [D]. lib)
    • Adjust the "debug" Configuration:
      • Select "settings for:"-> "Win32 debug ".
      • Select "Link" tab-> "general" category-> "Object/library modules". Add spaces to separate CVD. Lib, highguid. Lib, and cvauxd. Lib (optionally)
      • You can change the name and location of the output file. For example. the EXE file is placed in the project directory instead of the debug/subdirectory. You can type it in "Link" tab-> "general" category-> "output file name. /<Exe-Name> d.exe
    • Adjust the "release" configuration
      • Select "settings for:"-> "Win32 release ".
      • Choose "Link" tab-> "general" category-> "Object/library modules". Add cv. Lib, highgui. Lib, and cvaux. Lib (optionally) separated by spaces)
  4. Add a property project to Workspace:
    • Select "project"-> "insert project into workspace ".
    • Select opencv/cV/make/cv. DSP.
    • Similarly, for opencv/cvaux/make/cvaux. DSP, opencv/otherlibs/highgui. DSP.
    • Set From attributes:
      • Choose "project"-> "dependencies ..."
      • Select "cxcore" for "CV ",
      • Select "CV", "cxcore" for "cvaux ",
      • Select "cxcore" for "highgui ",
      • For your project, select ALL: "cxcore", "CV", "cvaux", "highgui ".

      Attribute configuration ensures that the opencv library is automatically re-compiled when the source code is changed.

  5. That's all. You can compile and run everything.
Linux problems:

Todo

Technical questions about database usage: How to access image elements

(The coordinate start point starts from 0 relative to the image origin, or the upper left corner (IMG-> origin = ipl_origin_tl) or the lower left corner (IMG-> origin = ipl_origin_bl)

  • Assume that there is an 8-bit 1-channel image I (iplimage * IMG ):

    I(x,y) ~ ((uchar*)(img->imageData + img->widthStep*y))[x]
  • Assume that there is an 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 you increase the brightness of a vertex (100,100) by 30, you can:

    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;
  • Assume that there are 32-bit floating point numbers and 1-channel image I (iplimage * IMG ):
    I(x,y) ~ ((float*)(img->imageData + img->widthStep*y))[x]
  • Now, the general method is as follows: assume there is an N-channel and the image type is T:
    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_elem (IMG, T, Y, x * n + C)

There are also functions for various images (including 4-channel) and matrices (cvget2d, cvset2d), but they are all very slow.

How to access matrix elements?

The method is similar (for columns and rows starting from 0)

  • Real Number Matrix M (cvmat * mat) with 32-bit floating point number ):

    M(i,j) ~ ((float*)(mat->data.ptr + mat->step*i))[j]
  • The complex matrix m (cvmat * mat) with a 64-bit floating point number ):
    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]
  • It has a single-channel matrix and a macro cv_mat_elem (matrix, elemtype, row, col), for example, a real Number Matrix of 32-bit floating-point numbers.
    M(i,j) ~ CV_MAT_ELEM( mat, float, i, j ),

    Assume that the 3x3 unit array is initialized:

    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 process my own data in opencv

You have 300x200 32-bit floating point number image/array, that is, an array with 60000 elements.

int cols = 300, rows = 200;float* myarr = new float[rows*cols];// step 1) initializing CvMat headerCvMat mat = cvMat( rows, cols,                   CV_32FC1, // 32-bit floating-point, single channel type                   myarr // user data pointer (no data is copied)                   );// step 2) using cv functions, e.g. calculating l2 (Frobenius) normdouble norm = cvNorm( &mat, 0, CV_L2 );...delete myarr;

For other information, see cvcreatematheader, cvinitmatheader, cvcreateimageheader, and cvsetdata etc.

How to load and display images
/* usage: prog <image_name> */#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 discover and process outlines

See the demonstration squares

How to Use opencv to calibrate the camera

Todo

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.