Dlib: Boost.Python.ArgumentError for dlib.rectangle

Created on 19 Apr 2017  路  9Comments  路  Source: davisking/dlib

Hello,

I am getting this weird issue where the dlib.rectangle is working when I try it in python shell, but doesn't work when i try it in a script in the same shell.

Here is my code:

tx0, ty0, tx1, ty1 = (bounds[0][0], bounds[0][1], bounds[1][0], bounds[1][1])
print (tx0, ty0, tx1, ty1)
rect = dlib.rectangle(tx0, ty0, tx1, ty1)

giving me following error:

70 0 157 172
Traceback (most recent call last):
File "test.py", line 107, in <module>
rect = dlib.rectangle(tx0, ty0, tx1, ty1)
Boost.Python.ArgumentError: Python argument types in rectangle.__init__(rectangle, numpy.int32, numpy.int32, numpy.int32, numpy.int32) did not match C++ signature:
__init__(struct _object * __ptr64, long left, long top, long right, long bottom)
__init__(struct _object * __ptr64)

where as same values in the shell doesn't give any error:

> a = ([ 70, 0], [157, 172])
> tx0, ty0, tx1, ty1 = (a[0][0], a[0][1], a[1][0], a[1][1])
> import dlib
> dlib.rectangle(tx0, ty0, tx1, ty1)
rectangle(70,0,157,172)

I am not sure what is wrong with it. Thanx for the help in advance.

Most helpful comment

python filename.py .. anyways I fixed it, I manually converted each number using int() and it worked. Previously also it was integer. I am assuming it was in numpy.int8 and using int converted to needed numpy.int32. But I am still not sure what the problem was.

Here is the updated code:

tx0, ty0, tx1, ty1 = (bounds[0][0], bounds[0][1], bounds[1][0], bounds[1][1])
print (int(tx0),int(ty0),int(tx1), int(ty1))
rect = dlib.rectangle(int(tx0), int(ty0), int(tx1), int(ty1))

All 9 comments

You have two different versions of pyhton installed. One gets called when you run interactively and another when you run the other way. One isn't compatible with the boost.pyhton install you have. You should figure out what pyhton you are running and make sure you call the one you want.

Like I said, I have checked already if it is the same version. It's like, if I write python it is not working, but and same time, if I write python, and in that write the same code, it is. Plus, dlib is only installed in one environment in my setup.

There are a huge number of python versions. You would be surprised. If you aren't running the same python interpreter binary when you do this then it isn't the same python.

Also I mentioned that I am doing it on the same command line, with out actually closing anything or changing the environment. That's why I am sure the environment it not changing. I have also made this sure by printing the location of dlib and python binaries being called.

What do you type to run it?

python filename.py .. anyways I fixed it, I manually converted each number using int() and it worked. Previously also it was integer. I am assuming it was in numpy.int8 and using int converted to needed numpy.int32. But I am still not sure what the problem was.

Here is the updated code:

tx0, ty0, tx1, ty1 = (bounds[0][0], bounds[0][1], bounds[1][0], bounds[1][1])
print (int(tx0),int(ty0),int(tx1), int(ty1))
rect = dlib.rectangle(int(tx0), int(ty0), int(tx1), int(ty1))

Yeah, getting consistent versions of a python environment are a huge problem for everyone that uses python. It's amazing how difficult it is.

i was having the identical issue, which was fixed with use of dlib.rectangle(*bbox) where bbox was a list of coordinates (which i had converted to long but blv that was unnecessary)

@rohanpooniwala thanks ,got the solution of this problem

Was this page helpful?
0 / 5 - 0 ratings