Building the pHash library on Windows

孤街浪徒 提交于 2019-12-24 11:54:11

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/9962147/building-the-phash-library-on-windows

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!