Question

I've been trying to build pHash(http://phash.org/) on my windows machine and haven't been having any luck. I'm new to programming desktop applications. I will be using the pHash library with Python through ctypes. Could someone post the steps involved with building pHash?

What I tried, was opening pHash.sln with Visual Studio 2008 and chooing the Release(as opposed to debug) and building pHash. I wasn't sure where it was building to as I couldn't find the file. I tried looking in Visual Studio's projects folder but it wasn't there so I assumed it was building to pHash/release/pHash.dll, but when I load that dll with ctypes.cdll none of the functions listed in the pHash docs(http://phash.org/docs/howto.html) seem to be accessible, e.g. ph_dct_imagehash(), ph_dct_videohash.

Here is an example of my code:

import ctypes
import inspect

PHASHPATH = "C:\Users\me\Downloads\phash\release\pHash.dll"
phash_dll = ctypes.CDLL(PHASHPATH)
phash_dll['ph_dct_imagehash']

The response I get is:

Traceback (most recent call last):
  File "C:\Users\me\workspace\project\src\opencv.py", line 12, in <module>
    phash_dll['ph_dct_imagehash']
  File "C:\Program Files (x86)\Python27\lib\ctypes\__init__.py", line 371, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'ph_dct_imagehash' not found

I'm new at this, so please bear with me. Thanks.

EDIT: I'm running Python 2.7.

Was it helpful?

Solution

Except for some dirent functions, no pHash functions are exported from pHash.dll. That can be verified with DependencyWalker http://www.dependencywalker.com/. Try adding __declspec(dllexport) in front of the function declarations in pHash.h (e.g. for ph_dct_imagehash) and recompile.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top