How can I use Software Development Kit (SDK) in Matlab for image capture using USB camera?

14 views (last 30 days)
I have a canon EOS T4i camera, I would like to capture an image without using Image Acquisition Toolbox.
I have used "videoinput" and "getsnapshot" with my webcam before and I know this approach is pretty straight forward. But now I do not have Image Acquisition Toolbox anymore.
I implemented my image capture using the Canon SDK in MS visual studio. I made an exe file from that c++ implementation and used it in Matlab, which is not what I'm looking for. (same goes with mex files)
I want something purely in Matlab, using the functions coming with the SDK.
Is it even possible?
I tried: loadlibrary('EDSDK'); (the .h file and .lib files are in my working directory) but the error is
error using loaddefinedlibrary the specified module could not be found
My problem is that the SDK comes with several dlls and header files. I don't know how/when link/include them before using the functions. Also how can I directly use c++ functions in Matlab?
This is an example of creating a .NET API in Matlab.
I would like something similar with c++.
Any help or idea is appreciated.
EDIT: (for future references) Be careful with 32 bit libraries in 64 bit Matlab (you may want to use Matlab 32bit if you have 32 bit libraries)

Accepted Answer

Guillaume
Guillaume on 6 Jul 2015
Edited: Guillaume on 6 Jul 2015
Possibly, some dlls used by your main dll are not found. This MSDN page gives you the search path and order for dlls. Note that the application directory is most likely matlab's own directory.
You can also use the dependency walker (which used to come with visuals studio) to see all the dlls that are required by your main dll.
edit: I've just noticed that you're talking about C++. Matlab can only use the C calling convention when talking to dlls. If the exports of your C++ dll are not wrapped in extern "C" then matlab won't be able to call them.
  4 Comments
Walter Roberson
Walter Roberson on 20 Jul 2015
dynamically loaded DLLs are usually loaded only upon need, by the operating system. The details differ between operating systems.
64 bit MATLAB can never use 32 bit libraries. That is an operating system restriction that has been true on ever 64 bit operating system I have looked at.
elham sa
elham sa on 21 Jul 2015
Thank you both Walter and Guillaume!
Creating an exe file and placing the dlls in the folder with the exe was the workaround for me, although not the best solution!
(I guess the slowness was due to some other issues on my computer, it was resolved by several restarts.)
Thanks for your help guys!

Sign in to comment.

More Answers (0)

Categories

Find more on COM Component Integration in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!