PyImageSearch / imutils

A series of convenience functions to make basic image processing operations such as translation, rotation, resizing, skeletonization, and displaying Matplotlib images easier with OpenCV and Python.
MIT License
4.54k stars 1.03k forks source link

Unable to cast Python instance to C++ type #64

Closed saadyousuf45 closed 6 years ago

saadyousuf45 commented 6 years ago
RuntimeError                              Traceback (most recent call last)
<ipython-input-8-407e53f9ba21> in <module>()
     65         faceOrig = imutils.resize(img[yw1:yw1 + h, xw1:xw1 + w], width=256)
     66 
---> 67         faceAligned = fa.align(img, gray, rect)
     68 
     69         path = '/home/saadi/Learningfolder/croped images/'

/home/saadi/.virtualenvs/keras-latest/local/lib/python2.7/site-packages/imutils/face_utils/facealigner.pyc in align(self, image, gray, rect)
     22         def align(self, image, gray, rect):
     23                 # convert the landmark (x, y)-coordinates to a NumPy array
---> 24                 shape = self.predictor(gray, rect)
     25                 shape = shape_to_np(shape)
     26 

RuntimeError: Unable to cast Python instance to C++ type (compile in debug mode for details)

I am trying to run this code in jupyter notebook. this is the error that I am getting. If I run the code in simple python environment it runs perfectly. Any suggestions???

jrosebr1 commented 6 years ago

It's strange that it would work perfectly in a Python virtual environment but not in a Jupyter Notebook. I'm assuming you installed and launched your Jupyter Notebook from your Python virtual environment? You might want to double-check that.

My only suggestion is that this is a dlib error. The predictor would be your facial landmark predictor which is a dlib function. If you still have the issue I would suggest opening an issue on the dlib GitHub page.

jrosebr1 commented 6 years ago

Closing due to inactivity.