Closed RhamyB closed 7 years ago
If I had to guess, you did not add the location of OpenCV DLLs to the PATH environment variable.. Same as this
Also worth checking out these instructions: https://github.com/kyamagu/mexopencv/wiki
@amroamroamro I set the path to the DLLs once again for both the user and system and still, no luck. Do you have a zip with your generated MEX files? I'm not sure what the issue is but I have been struggling for weeks now.
I don't have stable ones right now; I'm currently hacking on the sources and rebuilding each time I make a change... Not to mention that my environment is a bit different: VS2013, MATLAB R2015a, and a custom-built OpenCV. (Besides, I'm not sure how @kyamagu feels about me distributing random binaries!)
Now in order to help you figure out the problem, we still need a bit more context. Describe how you compiled mexopencv, where you extracted the files, the location of dependencies, your environment, etc..
First thing, try to use Dependency Walker to figure out which modules failed to load. So in my case, I ran the following command (it's important to run it from inside MATLAB):
>> !"C:\path\to\depends.exe" "C:\Users\Amro\Desktop\mexopencv\+cv\imread.mexw64"
If you haven't correctly set up the PATH, you will see something like below, indicating that required OpenCV DLLs are not found:
NOTE: if MATLAB is running while you change PATH variable using the Windows settings dialog, it won't pick up on the changes. Either restart MATLAB, or use the setenv
function inside your existing MATLAB session.
Next, I would ask you how you organized the files. Based on your first comment, the MEX-files are placed in C:\opencv\build\install\matlab\+cv\imread.mexw64
. Is it the case that you've manually copied them to that location?
Again, I suggest you refer to the wiki page I mentioned before. It should walk you though the process step-by-step. Even if you're not building OpenCV from sources and using the official binaries instead (without opencv_contrib
), it might still help you in case you missed a step..
I have used dependency walker and everything checked out. I did copy manually unfortunately. I've already started from the beginning and wiped all opencv files I have! I'll be sure to follow your instructions and hopefully this'll do it!
@amroamroamro you can go ahead and distribute binaries if needed, though the current mexopencv is not best suited for binary distribution.
@RhamyB did you use the same MSVC compiler/runtime version for both mex and OpenCV? Also don't forget to reboot after changing the PATH variable.
Well. I took the liberty and went ahead and started fresh yesterday and followed all steps on the wiki you showed me, @amroamroamro! Fortunately, there were no errors throughout making, building, and mex file compiling. BUT, when I ran a simple comman in MATLAB:
>> inImage = cv.imread('blobs.png');
Error using cv.imread
Invalid MEX-file 'C:\OpenCV300\mexopencv\+cv\imread.mexw64': The specified module could not be found.
I have rebooted after setting the PATH and all, but still no progress!
Why is that? @kyamagu
Visual Studio Pro 2012 (vc11) 64-Bit compiled in release mode. MATLAB R2013b 64-Bit OpenCV 3.0.0 Python 2.7.6 Python 3.4 Windows 7 64-Bit
I decided to restart MATLAB once more and I get the following error now:
>> inImage = cv.imread('blobs.png');
Undefined variable "cv" or class "cv.imread".
Upon navigating to the mexopencv directory and running the command once more:
>> inImage = cv.imread('blobs.png');
Error using imread
imread failed
@RhamyB
Either you addpath
the mexopencv directories (each time you restart MATLAB), or you can just persist the modified paths with savepath
.
See the docs for more info about this...
(I should remind you that the MATLAB search path is not the same thing as the system's PATH environment variable)
>> inImage = cv.imread('blobs.png');
Error using imread
imread failed
I savepath the directories in the tutorial and still receive the same error! @kyamagu @amroamroamro
Also when I call cv.getBuildInformation()
General configuration for OpenCV 3.0.0-dev =====================================
Version control: unknown
Platform:
Host: Windows 6.1 AMD64
CMake: 3.3.0-rc3
CMake generator: Visual Studio 11 2012 Win64
CMake build tool: C:/Windows/Microsoft.NET/Framework/v4.0.30319/MSBuild.exe
MSVC: 1700
C/C++:
Built as dynamic libs?: YES
C++ Compiler: C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/bin/x86_amd64/cl.exe (ver 17.0.60610.1)
C++ flags (Release): /DWIN32 /D_WINDOWS /W4 /GR /EHa /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /wd4251 /wd4324 /MP8 /MD /O2 /Ob2 /D NDEBUG /Zi
C++ flags (Debug): /DWIN32 /D_WINDOWS /W4 /GR /EHa /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /wd4251 /wd4324 /MP8 /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1
C Compiler: C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/bin/x86_amd64/cl.exe
C flags (Release): /DWIN32 /D_WINDOWS /W3 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /MP8 /MD /O2 /Ob2 /D NDEBUG /Zi
C flags (Debug): /DWIN32 /D_WINDOWS /W3 /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE /D _SCL_SECURE_NO_WARNINGS /Gy /bigobj /Oi /MP8 /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1
Linker flags (Release): /machine:x64 /INCREMENTAL:NO /debug
Linker flags (Debug): /machine:x64 /debug /INCREMENTAL
Precompiled headers: YES
Extra dependencies: comctl32 gdi32 ole32 setupapi ws2_32 vfw32
3rdparty dependencies: zlib libjpeg libwebp libpng libtiff libjasper IlmImf ippicv
OpenCV modules:
To be built: hal core flann imgproc ml photo reg surface_matching video face imgcodecs shape videoio highgui objdetect optflow superres tracking ximgproc xobjdetect xphoto adas bgsegm bioinspired features2d latentsvm line_descriptor saliency text calib3d ccalib datasets rgbd stereo videostab xfeatures2d aruco stitching matlab
Disabled: ts world contrib_world
Disabled by dependency: structured_light
Unavailable: cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java python2 python3 viz cvv matlab
Windows RT support: NO
GUI:
QT: NO
Win32 UI: YES
OpenGL support: NO
VTK support: NO
Media I/O:
ZLib: build (ver 1.2.8)
JPEG: build (ver 90)
WEBP: build (ver 0.3.1)
PNG: build (ver 1.5.12)
TIFF: build (ver 42 - 4.0.2)
JPEG 2000: build (ver 1.900.1)
OpenEXR: build (ver 1.7.1)
GDAL: NO
Video I/O:
Video for Windows: YES
DC1394 1.x: NO
DC1394 2.x: NO
FFMPEG: YES (prebuilt binaries)
codec: YES (ver 55.18.102)
format: YES (ver 55.12.100)
util: YES (ver 52.38.100)
swscale: YES (ver 2.3.100)
resample: NO
gentoo-style: YES
OpenNI: NO
OpenNI PrimeSensor Modules: NO
OpenNI2: NO
PvAPI: NO
GigEVisionSDK: NO
DirectShow: YES
Media Foundation: NO
XIMEA: NO
Intel PerC: NO
Other third-party libraries:
Use IPP: 8.2.1 [8.2.1]
at: C:/OpenCV300/opencv/3rdparty/ippicv/unpack/ippicv_win
Use IPP Async: NO
Use Eigen: NO
Use TBB: NO
Use OpenMP: NO
Use GCD NO
Use Concurrency YES
Use C=: NO
Use pthreads for parallel for:
NO
Use Cuda: NO
Use OpenCL: YES
OpenCL:
Version: dynamic
Include path: C:/OpenCV300/opencv/3rdparty/include/opencl/1.2
Use AMDFFT: NO
Use AMDBLAS: NO
Python 2:
Interpreter: C:/Python27/python.exe (ver 2.7.6)
Python 3:
Interpreter: C:/Python34/python.exe (ver 3.4.3)
Python (for build): C:/Python27/python.exe
Java:
ant: NO
JNI: C:/Program Files/Java/jdk1.8.0_60/include C:/Program Files/Java/jdk1.8.0_60/include/win32 C:/Program Files/Java/jdk1.8.0_60/include
Java wrappers: NO
Java tests: NO
Matlab:
mex: C:/Program Files/MATLAB/R2013b/bin/mex.bat
Compiler/generator: Not working (bindings will not be generated)
Tests and samples:
Tests: NO
Performance tests: NO
C/C++ Examples: NO
Install path: C:/OpenCV300/build/install
cvconfig.h is in: C:/OpenCV300/build
-----------------------------------------------------------------
the above appears... Matlab "Compiler/generator: Not working (bindings will not be generated)"
@RhamyB
General configuration for OpenCV 3.0.0-dev
You are building against the master branch of opencv
and opencv_contrib
. The guide explicitly mentions that you must build against 3.0.0
, NOT the dev version!
When you clone the git repos (opencv and opencv_contrib), you need to switch to the correct tag in both and rebuild from scratch:
git checkout tags/3.0.0
As for the "matlab module" in opencv_contrib, it is unrelated to mexopencv and you don't need to build it. Again, just follow the guide and disable all contributed modules in cmake except for the four listed ones (bgsegm, latentsvm, optflow, and xfeatures2d).
What is wrong??
Visual Studio Pro 2012 (vc11) 64-Bit compiled in release mode. MATLAB R2013b 64-Bit OpenCV 3.0.0 Python 2.7.6 Windows 7 64-Bit