我想使用的OpenCV作为here,和我被困在一个时刻,我得到PInvoke的,即:DLL PInvoke的与Windows Mobile C++库移植到C#
我DLL.cpp
#define DLL_API __declspec(dllexport)
//...
DLL_API short processImage(const char* in_file, const char * out_file)
//...
我form.cs
[DllImport("DLL", EntryPoint = "processImage")]
private static extern short _ProcessImage(byte[] in_file, byte[] out_file);
public static short binarizeImage(string in_file, string out_file)
{
return _ProcessImage(StringToASCIIByteArray(in_file), StringToASCIIByteArray(out_file));
}
public static byte[] StringToASCIIByteArray(string str)
{
return Encoding.ASCII.GetBytes(str + "\0");
}
我认为,这可能与目标体系结构问题(在我的VS 2008项目)。当我使用'任何CPU'它编译&运行,但抛出Pinvoke,当我将它设置为'Windows Mobile 6专业SDK(ARMV4I)'它编译但不想部署,我得到了这个在输出窗口:
1>------ Deploy started: Project: DLL, Configuration: Debug Windows Mobile 6 Professional SDK (ARMV4I) ------
1>The system cannot find the path specified.
1>
2>------ Deploy started: Project: smartDeviceOcr, Configuration: Debug Any CPU ------
2>Deploying 'D:\VS 2008 Projects\C++\SmartDevice\ocr\smartDeviceOcr\bin\Debug\smartDeviceOcr.exe'
========== Deploy: 1 succeeded, 1 failed, 0 skipped ==========
请问具体ARMV4I事?我的手机上有ARM920T。我可以/应该编辑这个工作吗?
编辑:
只是要清楚的PInvoke点:
return _ProcessImage(StringToASCIIByteArray(in_file), StringToASCIIByteArray(out_file));
和异常消息是:
System.MissingMethodException was unhandled
Message="Cannot find the library DLL PInvoke 'DLL'."
StackTrace:
in smartDeviceOcr.Form1.binarizeImage(String in_file, String out_file)
in smartDeviceOcr.Form1.button1_Click(Object sender, EventArgs e)
in System.Windows.Forms.Control.OnClick(EventArgs e)
in System.Windows.Forms.Button.OnClick(EventArgs e)
in System.Windows.Forms.ButtonBase.WnProc(WM wm, Int32 wParam, Int32 lParam)
in System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam)
in Microsoft.AGL.Forms.EVL.EnterMainLoop(IntPtr hwnMain)
in System.Windows.Forms.Application.Run(Form fm)
in smartDeviceOcr.Program.Main()
EDIT2:
好了,现在它真的很奇怪。我改变了一些东西。我已经将openCV的dll添加到项目属性的部署列表中,以便我可以看到它们正在复制部署,并且我手动将所有dll复制到了PC上的exe目录。
我也改变了一些在DLL项目的部署选项,这样的DLL文件被复制到正确的目录(自动)电话及....
现在我有运行时错误(当试图访问从DLL中的函数 - OpenCV的):
到设备的远程连接已丢失
OpenCV是本地代码。你需要一个专门针对你的处理器的版本。 – 2011-12-18 11:12:33
此版本是为Windows移动处理器而设计的(我使用的是我在开始提到的网站中的版本 – Patryk 2011-12-18 15:29:09
pinvoke编组似乎不同意看到实际的异常消息将帮助我们帮助您诊断问题 – 2011-12-18 15:32:50