Comments (6)
Sounds like an issue in the way you set up PATH. I have totally no idea how MCR works, but is there any way to check PATH within your compiled executable? Like calling getenv?
from mexopencv.
Yeah, I am calling getenv from within the script, appending my relative DLL folder path, and then setting the new path. I don't think it is a PATH mistake as on my development machine I have the OpenCVs installed DLL path '.../vc10/bin' hardwired into my system. And when I run the script from MATLAB on my dev comp, it works fine -> it finds the DLLs. But then the .exe throws the invalid MEX function error on my dev comp, even though the hardwired OpenCV install DLL path '.../vc10/bin' still exists in the PATH environment, in addition to the './DLLs' I am now adding programmatically.
from mexopencv.
Further, I have installed MATLAB on a clean target machine with no opencv or visual studio compiler. When I setup a folder with the './DLLs' and './mexopencv-master' paths below the m file and run it in MATLAB, it works fine. This tells me that the programmatic adding of that relative DLL path to the system PATH is working correctly, as on this target there are no openCV DLL paths hardwired into the machine.
BTW, sorry for closing this. I hit the wrong button.
from mexopencv.
may i ask, what exactly is the error message? perhaps the target machine is missing the visual c++ redistributables
from mexopencv.
Disregard my last comment. I tested this myself, and I can say for sure this is a PATH issue.
First lets make sure we are on the same page. There are several "path" we need to manage: internal MATLAB path, external system path (system environment variable).
Before building the example, I have added mexopencv to the MATLAB path, and added opencv bin directory to the system-wide Windows PATH.
>> addpath('...')
C:\> echo %PATH%
Using "deploytool", I created a windows application, using the "classification_demo.m" script found in the sample folder of mexopencv. Once compiled, I ran the generated .exe file in command prompt, and it ran successfully.
Next, I removed OpenCV bin directory from the PATH variable, and reran the executable. I get the following error:
C:\Documents and Settings\Amro\Desktop\cv\test_mexcv\distrib>No log file specified
Invalid MEX-file 'C:\DOCUME~1\Amro\LOCALS~1\Temp\Amro\mcrCache8.0\test_m0\Documents and Settings\Amro\Desktop\mexopencv\+cv\private\ANN_MLP_.mexw32': The specified module could not be found.
Error in cv.ANN_MLP (line 113)
Error in classification_demo (line 19)
MATLAB:invalidMEXFile
Note that if you want your built .exe to find the required DLLs, they have to be added to the PATH env. var. on a system-wide level, or simply copy all OpenCV DLLs to the same directory as your executable.
A good way to troubleshoot dll issues is using the dependency walker tool. Load the executable from before, then from the Profile menu, select 'start profiling'. Once finished, inspect the generated log at the bottom for any problems.
Note that you will not see all the dependencies at first. The way the MATLAB compiler works is by bundling all you files (M-files, MEX-files, ..) encrypted into the output .exe, and it is not until you run the file that these are extracted and executed by the MCR.
This was tested on WinXP 32-bit, MATLAB R2012b, OpenCV 2.4.3, mexopencv compiled with VS2010
from mexopencv.
Well f me. It was a PATH issue, but only in my compilation. I didn't realize that the MATLAB compiler needs all of the DLLs AND .mexw64 files at the same level as main when compiling because in runtime it expands the .exe into a temporary folder in which all relative paths no longer exist, and so searching for the './mexopencv-master' folder containing the .mexw64 files was what was returning the Invalid MEX-function error. By compiling with everything at the main.m level and removing all addpaths(...), I was able to successfully run the .exe on both my dev comp, and target machine which has no compiler or anything on there.
Thanks everyone for the help, and sorry to disturb you with this question. I learned a lot about compilers today. And thank for this wonderful tool that is mexopencv.
from mexopencv.
Related Issues (20)
- Mexopencv using MatLab Runtime
- Using homebrew to install OpenCV==3.4.1
- windows opencv3.4.1 cmake
- Setting up mexopencv for matlab 2018b HOT 2
- No output from cv.getBuildInformation() in Octave 5.1.0
- maybe bug about the queryIdx and trainIdx
- ld: symbol(s) not found for architecture x86_64
- Invalid MEX-file : Missing dependent shared libraries
- [error 3] gcc >= 4.4 g++ >= 4.4 is installed
- v3.2.0 and xfeatures2d HOT 1
- mexopencv not compiling HOT 2
- error in setup opencv and mexopencv
- how Mac to mexopencv HOT 1
- [lib/mexopencv_features2d.o] Error 255 HOT 1
- MxArray::toMoments out of order arguments to cv::Moments
- Consider leveraging MATLAB in your CI
- MATLAB Error: Unrecognized function or variable 'FeaturesFinder_'.
- why can't I use the 'cv.detectMarkers' function???
- Hi all, I have a big problem when I am using matlab R2021a to builed mexopencv. HOT 1
- mexopencv building error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mexopencv.