4

I am having so much trouble installing openCV 2.3 with visual studio 2010. Crash after crash, installation after installation and after several weeks I've had no luck. Unfortunately there are no installation documents for openCV 2.3 and the directory structure and file locations are different from openCV 2.2 which makes the current tutorials almost useless. :(

Has anyone out there had any success with openCV 2.3? Can someone please try it and let me know if its an openCV build issue or my setup?

Or maybe someone can suggest an alternative to openCV. What my end goal is, is to get Pixel info, use inpaint functions, and basic image processing for After Effects and Maya.

EDIT: Sorry I thought I posed the error! This is what happens when I run the code:

  #include <iostream>
  #include <cv.h>
  #include <highgui.h>

  using namespace cv;

  int main()
  {

Mat image;
image = imread( "c:/image1.png", 1 );
namedWindow( "Gray image", CV_WINDOW_AUTOSIZE );
imshow( "Gray image", image );

      waitKey(0);
      return 0;
  }

It runs until imshow. If I comment out imshow it runs fine with no errors. Here is the errors when I add IMSHOW:

Unhandled exception at 0x76bfb727 in openCV_test.exe: Microsoft C++ exception: cv::Exception at memory location 0x0015ec20. and it gives me the option to break or continue.

This is what the output window shows:

First-chance exception at 0x76bfb727 in openCV_test.exe: Microsoft C++ exception: cv::Exception at memory location 0x0015ec20.. Unhandled exception at 0x76bfb727 in openCV_test.exe: Microsoft C++ exception: cv::Exception at memory location 0x0015ec20..

It then goes on to open SYSTEM.CPP and give me this:

- exc {msg="......\modules\core\src\array.cpp:2482: error: (-206) Unrecognized or unsupported array type " code=-206 err="Unrecognized or unsupported array type" ...} const cv::Exception & + std::exception {_Mywhat=0x00000000 _Mydofree=false } std::exception + msg "......\modules\core\src\array.cpp:2482: error: (-206) Unrecognized or unsupported array type " std::basic_string,std::allocator > code -206 int + err "Unrecognized or unsupported array type" std::basic_string,std::allocator > + func "" std::basic_string,std::allocator > + file "......\modules\core\src\array.cpp" std::basic_string,std::allocator > line 2482 int

Thanks!

に か
  • 117
  • 1
  • 3
  • 12
  • 1
    what kind of problems do you meet? – CharlesB Jul 12 '11 at 15:19
  • Without knowing what the specific problems are (error message at compile time/run time/etc.) it is probably difficult to help you out. So you might want to inform us what specifically is going wrong. – Bart Jul 12 '11 at 15:23
  • 1
    Stop installing and start addressing the crashes. You cannot get help with them until you document what you see and what you know in a question. – Hans Passant Jul 12 '11 at 16:20
  • Sorry guys...i forgot to add the code and errors. The errors make no sense to me...I hope it helps though. – に か Jul 13 '11 at 00:36
  • oh the includes are wrong... use #include #include – Nick Jul 16 '11 at 23:32
  • Thanks foe the response Nick. I was using the x64 dlls with x86 complier. It now loads fine and see the cv.h and core and highgui stuff. The issue I am having is running the code above. The error above is in respone to "imshow( "Gray image", image );" failing. When I comment out that line it runs fine...but the syntax looks correct so now I'm thinking its "image = imread( "c:/image1.png", 1 );" thats failing to run. Theres a problem with "imread". If you have some time...and are using openCV2.3, could you please run my code and let me know if it runs... – に か Jul 17 '11 at 07:59
  • Thanks for answering. I figured out the issue. It was a conflict between the 32 and 64 bits dlls vs the compiler. When I installed VS 2010 with superpack 2.3 the compiler I think tries to use a mix match of x86 and x64 dlls based on the way its setup in the environment vars and Vs2010. I figured it out by installing VS2010 on a different computer with only x86 support compiler and I had no trouble at all. Everything Worked Fine! Exact same setup, only one is X86 and the other is X86 and X64. It didn't make sense because the compiler should choose one right? and not a mix of x86 and 64 dlls? – に か Aug 03 '11 at 14:59
  • In the future, check this answer for a step-by-step installation: http://stackoverflow.com/questions/7011238/opencv-2-3-c-visual-studio-2010/7014918#7014918 – karlphillip Aug 12 '11 at 03:05
  • After reading all this I think I will go with OpenCV 2.1 – Matt Montag Sep 13 '11 at 21:22

6 Answers6

2

I have OpenCV2.3 and had no problem to install it with Visual Studio v9.0.

What you should do to compile and run correctly your project in all the Visual Studio versions :

Properties of your project (right click on it)

  • C/C++
    • General
      • Include directory add the < your directory >\OpenCV2.3\include\opencv2, < your directory >\OpenCV2.3\include\opencv and < your directory >\OpenCV2.3\include
  • Linker
    • General
      • Add lib directory < your directory >\OpenCV2.3\lib
    • Input
      • Add all the libs like opencv_core230d.lib opencv_highgui230d.lib and so on...

Then don't forget to add the dll to your system path. Configuration panel > System > Advanced > Environment variables > Path you can add a user environment path which will override the other one, just click New (if you have never added directory to your system path before) and write the path eg : < your directory >\OpenCV2.3\bin

Without more information, I hope it could help...

Julien,

jmartel
  • 2,771
  • 4
  • 24
  • 27
  • Thankyou for responding jmartel. Those are the steps I tried also...among others. :) – に か Jul 13 '11 at 00:31
  • I think the issue is not in my installion but in this line of my code: image = imread( "c:/image1.png", 1 ); Can you please test my code above and see it it runs...when you have time that is.. :) – に か Jul 16 '11 at 22:29
  • Thanks for answering. I figured out the issue. It was a conflict between the 32 and 64 bits dlls vs the compiler. When I installed VS 2010 with superpack 2.3 the compiler I think tries to use a mix match of x86 and x64 dlls based on the way its setup in the environment vars and Vs2010. I figured it out by installing VS2010 on a different computer with only x86 support compiler and I had no trouble at all. Everything Worked Fine! Exact same setup, only one is X86 and the other is X86 and X64. It didn't make sense because the compiler should choose one right? and not a mix of x86 and 64 dlls? – に か Aug 03 '11 at 14:59
1

Sometimes, the compiler cannot find the dll even if you have the correct path settings. At that point try copying the dll files from the openCV folder to ur current project (not solution) folder.

Nick
  • 1,692
  • 3
  • 21
  • 35
  • core230d.dll, highgui230d.dll.... Funny, I just installed openCV 2.3 just yesterday and most of the setup was same. Except when it was complaining that it couldnt find the dll files, I just copied the dlls which I needed and dumped in the project root and it works like a charm now. – Nick Jul 12 '11 at 18:54
  • What you are describing there is not a linker problem. But anyway, perhaps it might help the OP. – Bart Jul 12 '11 at 18:54
  • oops I meant compiler.. sorry – Nick Jul 12 '11 at 18:56
  • Thanks Nick. I added all the .dlls and libs. The code works until I hit the line with imshow. I updated my issue above. Theres something wrong with imshow function. – に か Jul 13 '11 at 00:33
  • yess!! imshow works for me.. make sure this include headers are there #include #include #include #include and core and highgui dlls are there – Nick Jul 13 '11 at 01:57
  • Oh I know why.. Coz ur using wrong dlls ... they are probably compiled by other compilers.. not necessary VS 2010 or win32 environment. make sure ur using the correct dlls. – Nick Jul 13 '11 at 01:59
  • http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.3/OpenCV-2.3.0-win-superpack.exe/download download all these pre built dlls and navigate to C:\OpenCV2.3\build\x86\vc10 – Nick Jul 13 '11 at 02:05
  • okay...so I had this setup with x86 but I switched to x64 and added all the includes and libs and dlls and this is the error I get: opencv_highgui230d.lib(opencv_highgui230d.dll) : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86' – に か Jul 15 '11 at 23:53
  • well.. u have a x86 VS running on a x64 machine. So remove the x64 dlls and just use x86 dlls and include path. – Nick Jul 16 '11 at 01:57
  • i tried all the different combos...and I think the issue is not in my installion but in this line of my code: image = imread( "c:/image1.png", 1 ); Can you please test my code above and see it it runs...when you have time that is.. :) – に か Jul 16 '11 at 22:30
  • I had the same problem with dlls. Restarting Visual Studio solved the problem. – fdermishin Jun 07 '12 at 08:24
0

You should try making a cycle structure:

#include <iostream>
#include <cv.h>
#include <highgui.h>

using namespace cv;

int main(){

  Mat image;
  namedWindow( "Gray image", 2 );

    while(1){
       image = imread( "d://Gaa6P.png", 1 );
       imshow( "Gray image", image );
       waitKey(0);

    }

return 0;

}
Jojodmo
  • 23,357
  • 13
  • 65
  • 107
Diame
  • 39
  • 1
  • 7
0

Rather than copy pasting I'll just link: http://theroundedengineer.blogspot.com/2011/07/opencv-23-for-vs-2008-from-source.html

Hopefully that helps. Granted I'm far from an expert on the differences between VS 2008 and VS 2010.

Russbear
  • 1,261
  • 1
  • 11
  • 22
  • Thanks Russbear. I followed and still no joy. :( – に か Jul 13 '11 at 00:34
  • 1
    Thanks for answering. I figured out the issue. It was a conflict between the 32 and 64 bits dlls vs the compiler. When I installed VS 2010 with superpack 2.3 the compiler I think tries to use a mix match of x86 and x64 dlls based on the way its setup in the environment vars and Vs2010. I figured it out by installing VS2010 on a different computer with only x86 support compiler and I had no trouble at all. Everything Worked Fine! Exact same setup, only one is X86 and the other is X86 and X64. It didn't make sense because the compiler should choose one right? and not a mix of x86 and 64 dlls? – に か Aug 03 '11 at 15:00
0

I got exactly the same problem. I couldn't read any image. I checked the data flag and image size. The flag indicated error and the size was always (0, 0). Although I do not know the actual cause, I somehow could avoid the problem and run my program fine.

At first, I compiled OpenCV myself. Even though all the dlls seemed to be created correctly and there was no build error, I noticed that the header folders are not correctly organized. Therefore, I switched to the superpack binary and tried static linking. There were a lot of undefined symbols at the beginning, so I basically just put everything into VS link options. The number of libraries I had to input to VS was quite absurd, but it is a good way to test if the superpack works.

These are what I use. opencv_core230d.lib;opencv_calib3d230d.lib;opencv_contrib230d.lib;opencv_features2d230d.lib;opencv_highgui230d.lib;opencv_legacy230d.lib;opencv_ml230d.lib;opencv_imgproc230d.lib;opencv_video230d.lib;libjasperd.lib;libjpegd.lib;libpngd.lib;libtiffd.lib;zlibd.lib;

I also need to input Comctl32.lib to resolve linking error.

I tested my program with static libraries of superpack. Things work fine now. The headers I used are

#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>

I do not try using dlls yet, but I can confirm that VS 2010 + OpenCV 2.3 64 bit from the superpack work. I hope you will have some luck with the superpack too.

(Hmm, I can't remember if I put opencv.hpp in the opencv2 folder myself, or if it was there right from the beginning. I did a lot of things to make it work and was a bit confused. But, I believe you can figure this out yourself if there is anything wrong about the header.)

Hope this helps, Pinyo

pinyotae
  • 106
  • 4
  • Thanks for answering. I figured out the issue. It was a conflict between the 32 and 64 bits dlls vs the compiler. When I installed VS 2010 with superpack 2.3 the compiler I think tries to use a mix match of x86 and x64 dlls based on the way its setup in the environment vars and Vs2010. I figured it out by installing VS2010 on a different computer with only x86 support compiler and I had no trouble at all. Everything Worked Fine! Exact same setup, only one is X86 and the other is X86 and X64. It didn't make sense because the compiler should choose one right? and not a mix of x86 and 64 dlls? – に か Aug 03 '11 at 14:58
-1

Check your firewall. turn off firewall totally. Your antivirus may block the process too. I had the same problem: cv::exception for memory and this was it's cause.

Avi
  • 21,182
  • 26
  • 82
  • 121
Nabzi
  • 1,823
  • 1
  • 16
  • 26