0

I'm trying to install opencv on my machine as explained in the book: "Packtpub OpenCV Computer Vision with Python Apr 2013"

It says that in order to run kinect you need to compile openCV with some stuff in it, so I downloaded openCV .exe that extracts to a 3.2gb folder and proceeded with all the steps...

Used CMaker, used the compiler MinGW, and everything as the book said

Than it tells me to try running some examples... but when I try to run drawing.py as recommended by the book, and all the others, it says:

python drawing.py


OpenCV Python version of drawing

traceback< most recent call last>:

File "drawing.py", line 7, in

import cv2.cv as cv

ImportError: DLL load failed: Invalid access to memory location.


I saw a lot of people saying this problem is fixed by adding the path to the bin of openCV dlls to path...

how do I find out which dll name is missing so I can find the name of it and find the folder where it is?

I have a x64 computer but the book tells me to install everything x86 because it is harder to get some minor bugs, maybe a version incompatibility between openCV, compiler, cmaker, and python?

I've tried to add a lot of folders to "path" variable and it didn't work

please tell me how I find out which dlls are missing so I can search for them on the computer or some other way to solve this problem because I'm just out of ideas

Tiago Mendonça
  • 179
  • 3
  • 14

3 Answers3

0

I don't have a high enough rep to add a comment otherwise I would but something you can do is start python with the -v option.

doing that will add a bit more to the output console and it will cause the python VM to output where it is looking for things when it tries looking for things, especially when failures occur. I've found that to be helpful when trying to hunt problems such as path problems down.

It also sounds like you haven't got your paths setup correctly. Have you looked at ImportError: DLL load failed: %1 is not a valid Win32 application ? If a DLL was expected in a certain location but wasn't loaded or present but then 'called' via a LoadLibrary (without checking to see if it was actually loaded) that might cause such an error. It is probably the fault of the original DLL that failed to verify the subsequent DLL was loaded instead of just assuming the LoadLibrary call succeeded.

In addition to the python -v yourmodule.py option you could also try running an strace (if you are on unix -- but it doesn't sound like you are). I used to use SoftICE on Windows for digging down deep. If you know the package or the DLL that is at the root of the problem, and have access to a dll export tool, you should be able to get a list of the dependencies the dll needs (external functions it relies on). Then you just need to know or find those functions it relies on from other DLLs. It's been awhile since I used to had do this sort of stuff all the time to locate functions in other DLLs but it is something that is entirely doable from a spelunkers perspective. But there are probably easier ways to go about it.

I'd start with the python -v approach first.

Community
  • 1
  • 1
Div
  • 130
  • 1
  • 14
0

The DLLs you need are almost certainly the ones kept in opencv/build/x64/vc11/bin (this path will be different, but equivalent, based on whatever compiler you used). That's the only folder that needs to be added to your system path.

Make sure that if you have a 32-bit version of Python, you compile OpenCV with a 32-bit compiler. Open up Python and it tells you its architecture.

kokociel
  • 497
  • 6
  • 17
0

Also, try installing numpy+mkll instead of numpy from the link of binary packages binary package for numpy+mkll. I had the same error and this solution solved the problem for me.

if you have installed simple numpy, don't worry, open cmd in the directory where you downloaded the new package. use this:

pip install name_of_the_whl_file 

or

pip3 install name_of_the_whl_file

it will automatically uninstall the old numpy and install numpy+mkll. Also, always remmember to add import numpy statement in your code before import cv2 statement.

import numpy import cv2

Hope it helps.