开发者

How to make OpenCV work under Windows?

I could not start an OpenCV application under Windows.

Given the following simple OpenCV program:

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>

#include "cv.h"
#include "highgui.h"

char imagename[100] = "sudoku.jpg";

IplImage* img;

int main(int argc, char** argv) {
    cvInitSystem(argc, argv);

    cvNamedWindow("Example4", CV_WINDOW_AUTOSIZE);
    IplImage* img = cvLoadImage(imagename);

    cvShowImage("Example4", img);
    cvWaitKey(0);
    cvDestroyWindow("Example4");
    return (0);
}

I can compile and start using a precompiled OpenCV libraries version 2.2, the referenced image appears in a window. (The compilation did work using netbeans and cygwin or own makefile with 5 lines and minGW). Then I wanted to use C++ function calls in OpenCV but the compilation did not work so based on this answer I have decided to recompile OpenCV following this installation guide and this getting started guide.

Using minGW and CMake OpenCV had been compiled without complaints. I did not use any optional package for opencv compilation.

Unfortunately no program could be started because only a grey window appears and after while the application crashes and the following error 开发者_如何学Gomessage is given by Windows:

Problem signature:
  Problem Event Name:   APPCRASH
  Application Name: main.exe
  Application Version:  0.0.0.0
  Application Timestamp:    4de3a2d9
  Fault Module Name:    libopencv_highgui220.dll
  Fault Module Version: 0.0.0.0
  Fault Module Timestamp:   4dcd07e6
  Exception Code:   c0000005
  Exception Offset: 0002def4
  OS Version:   6.1.7600.2.0.0.256.4
  Locale ID:    1033
  Additional Information 1: 0a9e
  Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
  Additional Information 3: 0a9e
  Additional Information 4: 0a9e372d3b4ad19135b953a78882e789

What could be the problem?

I tried to compile from Netbeans, with my own Makefile and with Cmake-gui and the executives were created without problem. I have included the opencv bin dir in the PATH to make the mentioned libopencv_highgui220.dll visible.

Update:

Following the previous procedure I got the exact same result on a Windows XP Professional: opencv and project building is OK, but running hangs. There are no other C, C++, compilers and IDEs on this machine that may interfere with my opencv compilation.


I have posted the same question at opencv forum and I got an answer.

The problem was that I used either the lib or the bin opencv directory for linking and the PATH. Using the install guide it turned out to me that I have to use the lib directory for the linking and bin directory for the PATH. The combined usage of dll.a in lib and dll in bin was new to me.

So I have followed the CodeBlocks+MinGW guide step by step to solve the problem, moreover when I use my previous MinGW opencv built without CodeBlocks either the C or the C++ code run correctly.


I thk I have found a detailed description for installing OpenCV in Windows and using it in most of the IDEs from here : http://techarenagadgetz.in/2012/12/configuring-opencv-2-4-2-for-codeblocks-and-similar-ides/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜