通过c#调用matlab [英] Invoke matlab through c#

查看:93
本文介绍了通过c#调用matlab的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在研究我的最后一年项目,它有两个部分

1,图像处理,我通过面部姿势分类情感

和2是c#部分,其中基于情感,我们自动执行不同的功能,例如,如果一个人悲伤,那么在背景中悲伤的播放列表将播放,

i已创建可执行文件(exe)matlab代码的文件nd通过c#调用,但是花了太多时间执行,大约3到4分钟,请告诉我,如果有人知道调用matlab的其他有效方法请帮我,请给我发电子邮件[电子邮件删除]

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]

推荐答案

让我看看我是否理解正确。你有一个基于matlab代码的图像分类器,它已经在一些历史数据集上进行了训练。这个训练有素的分类器已编译成exe。这里c#代码的作用是将新图像发送到这个exe分类器,后者又对该图像进行分类并将结果(比如说悲伤或快乐)返回给你的c#代码。它工作但需要太长时间。我对么?你怎么知道问题在于c#代码而不是matlab代码。您是否尝试使用MATLAB环境中经过训练的分类器对相同的新图像进行分类,以比较它们的响应时间?



如果您仍对其他有效方法感兴趣,有三种方法可以将matlab代码集成到ac#中,简要说明:

1. COM

2. .NET汇编

3.共享库



从MATLAB Central中读取详细信息和演示将MATLAB与C#集成
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#.


提高速度通常是应用程序特定的,或者特定于您正在做的事情。我们不能告诉你如何在不知道你正在做什么的情况下更快地制作东西。



我假设您正在使用Matlab进行一系列图像处理,您是自己编写算法还是使用库? ...如果您正在使用库,您可能必须自己重写部分库,以使其更快地工作。



此外,如果您碰巧使用母语,您可以通过预先为图像预先分配内存来加快这一过程(因为您的图像大小相同,您可以预先分配然后使用相同的内存),然后将其传递给独立的线程进行图像处理。结果可以反馈给独立的线程进行结果处理。换句话说,如果你有一堆独立的机制同时工作以及更好的内存管理,你可能会获得更好的性能。同样,优化过程将特定于您正在使用的数据和您正在使用的数据类型。
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.


这篇关于通过c#调用matlab的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆