Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I am working on my final year project which have two parts
1, image processing in which i am classifying emotions through facial gesture
And 2 is c # parts in which on the basis of emotions we are performing different functionality automatically for eg if a person is sad then in background the sad playlist will play ,,
i have created Executable(exe) file of matlab code nd invoke through c# but its taking too much time to execute , round about 3 to 4 min ,please tell me if some one knows the other efficient method of calling matlab help me please email me on [email removed]
Posted
Updated 22-Dec-13 16:41pm
v2
Comments
Ron Beyer 22-Dec-13 22:41pm    
How can we possibly know if there is a "more efficient" method if we have no idea the method you are currently using? Also, don't post your email in a public forum unless you enjoy a full mailbox of spam.
Peter Leow 23-Dec-13 12:37pm    
Let see if I understand you correctly. You have an image classifier built on matlab code and it has been trained on some historical data set. This trained classifier has been compiled into an exe. The role of c# code here is to send new image to this exe classifier which in turn classify this image and returns the result (say 'sad' or 'happy') to your c# code. It is working but takes too long. Am I correct?

How do you know the problem lies within c# code and not the matlab code. Have you tried classifying the same new image using the trained classifier in the MATLAB environment to compare its response time.
Member 10380349 25-Dec-13 22:39pm    
thanks for your comment ,,
No its not like that you understand , different i m capturing live image from camera, and which give me mood sad or happy ,and the role of c#is that on the basis of mood my system performing different functionality through c# i define a timer of 5 min in c# after every five min system calls an exe of matlab through which i get new image ,matlab totaly consist of camera code only, when i run matlab script in matlab its just take 10sec only for completion , while when i call .exe of matlab code it take 3 to 4 min in execution ,i build .exe of matlab through mcc -m

Let see if I understand you correctly. You have an image classifier built on matlab code and it has been trained on some historical data set. This trained classifier has been compiled into an exe. The role of c# code here is to send new image to this exe classifier which in turn classifies this image and returns the result (say 'sad' or 'happy') to your c# code. It is working but takes too long. Am I correct? How do you know the problem lies within c# code and not the matlab code. Have you tried classifying the same new image using the trained classifier in the MATLAB environment to compare their response time?

If you are still interested in 'other efficient method', there are three ways to integrate matlab code into a c#, briefly:
1. COM
2. .NET assembly
3. C Shared library

Read the details and demo from the MATLAB Central Integrating MATLAB with C#.
 
Share this answer
 
v5
Comments
Member 10380349 25-Dec-13 22:42pm    
this method i have also tried but i cant understand it properly i have created c shared library which consist of dll file but how to use it i dont know :(
Making something faster is usually application specific, or specific to what you are doing. We can't tell you how to make something faster without seeing what it is you are doing.

I assume you are doing a bunch of image processing with Matlab, did you make the algorithms yourself or are you using libraries? ...if you're using libraries, you'll likely have to rewrite portions of it yourself in order to make it work a lot faster.

In addition, if you happened to do it in a native language you'd be able to speed up the process by pre-allocating memory for the images before-hand (since your images are going to be the same size, you can preallocate then use the same memory) and then passing it to an independent thread for the image processing. The results could be fed back to an independent thread for result processing. In another words, if you had a bunch of independent mechanisms working at the same time along with better memory management, you'd likely get better performance. Again, the process of optimization will be specific to what it is you are doing with the data and the type of data you are using.
 
Share this answer
 
Comments
Member 10380349 25-Dec-13 22:45pm    
thanks albert for your comment
Actually i have converted matlab .m file to .exe and when i execute .exe its take round about 3 to 4 min to execute ,,in my case matlab .exe is totaly independent it just call through c#
Albert Holguin 26-Dec-13 10:29am    
Matlab exe? ...did you just "compile" the Matlab code? ...those compilers rarely work well.
Member 10380349 26-Dec-13 11:49am    
when i run in matlab application its work very well takes 9 to 10 sec nd shows result,,,,normally how much time taken for execution ?? i have build my code exe using this command mcc -m coed file.m i think its need the matlab run time environment ,,,,
Albert Holguin 26-Dec-13 11:56am    
Execution time of any program is completely specific to that program. mcc is a Matlab compiler, but again, usually those types of compilers that convert one script into a different executable don't tend to do a great job. What I meant when I said convert it to a native language I meant write a program that will compile natively yourself.
Member 10380349 26-Dec-13 12:47pm    
how ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900