0

I am trying to use pdiffer in ubuntu. It is a python interface to the PerceptualDiff tool. https://pypi.python.org/pypi/pdiffer

I installed pdiffer using pip (after installing pip)
I installed cmake
I installed freeimage (sudo apt-get install libfreeimage-dev)
I built PerceptualDiff following the read me file.

As far as I know, everything is setup (there were no errors). Under Home/Documents I have my two images and a folder called pdiff that has the compiled perceptualdiff file in it.

I used the python interpreter in a terminal window

from pdiffer import PDiffer

pdiff = PDiffer(bin='/home/username/Documents/pdiff/perceptualdiff')
result = pdiff('image1.png', 'image2.png')

no errors until the last command

Traceback (most recent call last):

File "<stdin>", line 1, in <module>
TypeError: 'PDiffer' object is not callable

This is the first time I've tried to use a python interface for a C module. If you could tell me what I'm doing wrong (or let me know what other information I need to include), I would appreciate it.

1 Answer 1

0

The documentation lacks a basic explanation.

Let's have a look first at your error. You create an instance of the PDiffer class and then trie to call that instance again. See this very simplified example with the same error:

>>> class PDiffer:
...   def __init__(self, *args, **kwargs):
...     pass
... 
>>> pdiff = PDiffer(bin="/path/to/bin")
>>> pdiff("image1.png", "image2.png")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'PDiffer' object is not callable

That said, the documentation gives 2 options to use pdiff. Create an instance of PDiff and give it a custom path to the binary or use the helper function pdiff. Giving them the same variable name and using them in the same code block is just very confusing. It's either one OR the other.

I had to look at the source to see what's going on. You should use the pdiff method of the PDiff class instead. The second example is a shortcut to this method with the custom binary path.

So a working example would be:

from pdiffer import PDiffer
pdiff = PDiffer(bin='/home/username/Documents/pdiff/perceptualdiff')
result = pdiff.pdiff('image1.png', 'image2.png')

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .