I'm trying to use phash library using this wrapper https://github.com/ludoviclefevre/phash-integration-in-csharp
c++ header:
int ph_dct_imagehash(const char* file,ulong64 &hash)
c# dll import:
DllImport(@"pHash.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int ph_dct_imagehash(string file, ref ulong hash);
test code:
ulong hash = 0;
foreach (var file in files)
{
ph_dct_imagehash(file, ref hash);
dictionary.Add(file, hash);
}
It works perfectly for few picture, but when ther's about 200-300 pictures i got Accesviolation exception
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
My first lead is garbage collector but i'm confused.. should i use intpr instead of string and hash parameters? I tried changing ref parameter to out but it doesn't matter..