这是后续帖子使用 .NET 中的 pHash https://stackoverflow.com/questions/6254447/using-phash-from-net
您将如何在 .NET 中声明以下 C++ 声明?
int ph_dct_imagehash(const char* file,ulong64 &hash);
到目前为止我已经
[DllImport(@"pHash.dll")]
public static extern int ph_dct_imagehash(string file, ref ulong hash);
但我现在收到以下错误
ulong hash1 = 0, hash2 = 0;
string firstImage = @"C:\Users\dance2die\Pictures\2011-01-23\177.JPG";
string secondImage = @"C:\Users\dance2die\Pictures\2011-01-23\176.JPG";
ph_dct_imagehash(firstImage, ref hash1);
ph_dct_imagehash(secondImage, ref hash2);
它基本上表明我对 ph_dtc_imagehash 的声明是错误的。
我在这里做错了什么?
堆栈不平衡表明 C++ 代码使用cdecl
你的 C# 使用stdcall
调用约定。改变你的DLLImport
对此:
[DLLImport(@"pHash.dll", CallingConvention=CallingConvention.Cdecl)]
C# 中的函数签名(返回值和参数)在其他方面是正确的。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)