Integrating Matlab with C++ - matlab

I need to localize facial landmarks as a part of my research project and planning to use Supervised Descent Method (SDM) for that. Both the C++ and Matlab versions are available at the following site and when I contacted them they said C++ version is not going to be available until they secure it. So, I had no other option and had to opt for Matlab version.
http://www.humansensing.cs.cmu.edu/intraface/download_functions_matlab.html
The problem is that My project is in C++ and OpenCV. I wonder whether there is a way to access Matlab version of SDM in Visual C++ . I mean, is there an integration mechanism available for that ?
And, the next issue is when executing the "Facial Feature Detection" code available at the above site I get the following error.
I executed it as given below.
[detected_points] = xx_track_detect(Model,[],image,[],options);
and, it says "undefined function or variable named 'model' "
anyone have a solution to this ?

It seems like you need to use Matlab engine to be able to execute Matlab commands from C++. The engine interface allows you to do just so.
Regarding the model variable - it is probably a representation of the learned model for facial landmarks, it should be supplied with the packge or you need to tune it by yourself. Without additional information I suggest you contact the publishers of the package for more information.

Related

Problems in OpenModelica v1.19.2 when installing OpenHydraulics v1.0.1 with Modelica Standard Lib v3.2

Greeting Everyone, I am a new one here.
I'm a brand new Modelica user. I'm trying to learn the language with OpenModelica. I'd like to use OpenHydraulics which is in github link in OpenModelica (specifically in the OMEdit Connection Editor).
I downloaded OpenModelica v1.19.2 and Modelica Standard Lib v3.2 to browse and run the library OpenHydraulics v1.0.1. However, when I open the Excavator example and try to Instantiate or Simulate the model I get many errors of the form:
[OpenHydraulics.Basic.VariableRestriction: 51:3-54:64]: Function ReynoldsNumber_m_flow not found in scope VariableRestriction.
Could you help me with this problem?
Thanks in advance.
there are a couple of things you need to take into consideration:
The current version of OpenHydraulics is still the original release from almost 10 years ago.
The library was developed using Dymola which at the time also supported a couple of non-standard Modelica, Dymola-specific constructs that other tools struggle to work with.
The example you are trying to run is the most complex one utilizing almost all of the power of the library and hence has quite a high degree of complexity.
Taking all this together means that OpenModelica is bound to struggle with that example. But all is not lost. If you actually look at the more simple circuit examples (under Circuit) you'll find that they work just fine. And depending on your application area they might already demonstrate a usage that will fit your needs.
I hope this helps.

How to implement fixed point operations without Fixed Point Designer Library in Matlab?

I am supposed to work with an existing code in my work and at some places the previous programmer has extensively used Fimath function. Unfortunately, I am not having the license for the Fixed Point Designer toolbox and was looking for some alternatives.
I tried getting the fimath.m file from another source but it is referencing to some embedded libraries in the toolbox.
Is there some other way in which I can bypass this problem?
Thank You

How can I package a MATLAB application that utilises toolboxes?

I want to package up an application in MATLAB for another team to use. They will have an appropriate version of MATLAB to run this application, but they might not necessarily have licenses for all the toolboxes used by the application.
Is there a way to "bundle" the toolboxes into the application so that they do not require expensive licenses to run it?
If not, is it possible to create a stand-alone/license independent MATLAB application a different way?
EDIT: Some of these applications might feature GUIs as well as command line interfaces.
To generate code that can be run by MATLAB, you need the MATLAB Coder. The codegen command will generate the executables that can be run in MATLAB. Loren of MathWorks has a nice blog post on the product.
Here is an example of how to use codegen to create a MEX function from MATLAB code.
One big caveat is that with MATLAB Coder, the complete functionality of MATLAB is not yet available for compilation. This is because the generated binaries do not require the MATLAB Compiler Runtime (MCR), which is essentially a headless MATLAB virtual machine. Instead MATLAB Coder generates C code that is truly standalone, but the code generation is somewhat limited as a result. Here is a description of the subset of functionality, and here are complete lists of functions supported. Most toolkit functions appear to be supported according to the categorical list.
If the required functions are not supported, then it will be necessary to use the Compiler to generate standalone libraries and roll your own MEX interface to those libraries, as MrAzzaman indicated. Another possibilities is to use the loadlibrary function to directly load the Compiler-generate libraries, although I have never tried this last option. If you can't successfully interface with these libraries back in MATLAB, the MATLAB compiler can of course be used to generate a standalone executable. The deploytool simplifies the process of packaging the code and its dependencies.
The MATLAB Compiler sounds like exactly what you need. Unfortunately, it is a separate Toolbox which you would have to purchase.
EDIT: I should note that this will compile your MATLAB code into an application/library, not MATLAB code. The other team would still be able to use it with MATLAB, I believe, but I don't think they would be able to see the code itself.

Matlab Vs. Maple for curve fitting to data, finding eq'n of curve then integrating through code

Im sure there are a thousand different posts on Maple vs Matlab, but i have a bit of a unique set of requirements and before i go off to learn one of the two i would like to know which one will do it best.
I have a set of data from an accelerometer recording an impact. I need to do the following:
fit a curve to the data
Find the equation for that curve
solve the equation listed at the link
http://upload.wikimedia.org/wikipedia/en/math/2/d/3/2d39556df1dbbd467dc914253e93cdb0.png
which solves for a family of curves,i.e the MAX under the interval.
I would like to do this as seamlessly with visual studio as possible. The GUI and all the other elements of the app are built in VB and I would like to keep it there. I know maple has a code generating part to it that will convert to VB, would it be able to handle something like this? Does Matlab integrate with Visual Studio well? I would be thrilled if there was an object i could place on the VB form which would facilitate the communication to and from the matlab or maple framework. Currently i have it working with R, however to do so i need to write the data to a file, launch the R script, wait for it to finish, return control to my VB app and take it from there. This process takes too long and since i do not have experience with multi threaded programming the GUI freezes up when control is passed to the script.
Any help or suggestions would be very much appreciated!
In your case I would choose neither of the two. You may have a look at Python Tools for Visual Studio. The blog post mentions support for NumPy & SciPy for .Net which gives you all the math power you need at hand well integrated in the .Net world.
EDIT:
By looking at matplotlib's gallery I'm tempted to say that matplotlib is on par with MATLAB.
MATLAB doesn't auto-generate VB code, but it can easily be called from a VB application without the indirection of writing a file. It has COM interface that can be called directly from within VB code. See this example from the MATLAB documentation to find out more.
To carry out the technical analysis you've mentioned, you would probably save time by using Curve Fitting Toolbox in addition to base MATLAB.
Note that the above method of connecting to MATLAB via its COM interface relies on there being a live copy of MATLAB present when the VB application is executed. If you need to share your application with people who don't have a copy of MATLAB, you can also create standalone COM components and .NET assemblies from MATLAB code that can be called in the same way by your VB code, but can be deployed freely to people without a MATLAB license - however, this requires an extra product, MATLAB Builder for .NET.

Where can I find good open source code flow visualization software?

I am working on an academic research regarding some very long functions in the Linux kernel (link, link).
For that research, I would like to use some code flow visualization tool, that would be able to plot a graph in which each vertex is a decision point and each edge is a piece of code which runs in a consequent way.
Do you know of any good, open source project that can visualize C code?
Perhaps a tool like KCacheGrind would be of help. It generates call graphs based on actual calls and cannot pre-generate a call graph without actually running the program, which may not suit your needs, but then it again it may.
History flow's are very neat for changes/diff across multiple versions.
Codeplex has a project, Dependency Visualizer which does support C also.
Gprof2Dot can render oprofile, this would get you dynamic info also.
CodeViz also (static tool) would work.
If your using gcc, gcc-xml has an introspector plugin also todo this.
You appears to want to acquire a flowchart of C source code ("decisions", "code blocks").
Something like this C flowchart?
To do this correctly, esp. for Linux kernal code, I'd expect you to have to preprocess the code first to get rid of macros and conditionals. I would assume that GCC would construct such a graph internally and that you ought to be able to get your hands on that graph.
Doxygen does some amount of 'visualization',
but you need to work on the code a bit for it to be usable.
Another interesting thing to check would be lxr
Linux Cross Referencer is a software toolset for indexing and presenting source code repositories. LXR was initially targeted at the Linux source code, but has proved usable for a wide range of software projects. lxr.linux.no is currently running an experimental fork of the LXR software.
I can recommend Sourcetrail. Can work with a compile_commands.json. Not sure if it's still maintained, though. But it's foss and you can fork it!