iacopomasi / face_specific_augm

Face Renderer to perform Domain (Face) Specific Data Augmentation

Home Page:http://www.openu.ac.il/home/hassner/projects/augmented_faces/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

too many values to unpack

JoeFannie opened this issue · comments

when I run demo on a single image: python demo.py input.jpg
but it returns error as follows:
Traceback (most recent call last):
File "demo.py", line 117, in
demo()
File "demo.py", line 48, in demo
allModels = myutil.preload(this_path,pose_models_folder,pose_models,nSub)
File "/home/jiajiong.caojiajio/workspace/gongan_live/face_specific_augm-master/myutil.py", line 66, in preload
model3D = ThreeD_Model.FaceModel(this_path + pose_models_folder + pose, 'model3D', True)
File "/home/jiajiong.caojiajio/workspace/gongan_live/face_specific_augm-master/ThreeD_Model.py", line 15, in init
self.eyemask = self.getEyeMask(width=8,plot=False)
File "/home/jiajiong.caojiajio/workspace/gongan_live/face_specific_augm-master/ThreeD_Model.py", line 38, in getEyeMask
output1 = self.createMask(eyeLeft, width=width)
File "/home/jiajiong.caojiajio/workspace/gongan_live/face_specific_augm-master/ThreeD_Model.py", line 65, in createMask
contours, hierarchy = cv2.findContours(eyemask,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
ValueError: too many values to unpack

Does anyone have any idea to figure it out?

Works fine here on my machine with python demo.py input/input.list
Check if you have installed OpenCV 2 or 3.

That is:

$ipython
In [4]: import cv2;cv2.__version__
Out[4]: '2.4.10'

In my case this is the version of OpenCV that I am using probably that's the problem: you are using OpenCV 3.

The code should work with Opencv3 to the only minor problem is that in Opencv3 they changed the interface for findContours. See here .

On my laptop, I was able to solve this time ago but I forgot to commit.
The fix should be:

  1. detecting the opencv version with cv2.__version__
  2. then if else to make the right call to find Contours and fix any other possible issues.

Then all should work in OpenCV3 too. Feel free to send a PR if you are able to provide the fix.

Thanks.
I hope this helps.

commented

from: https://stackoverflow.com/questions/28113221/findcontours-and-drawcontours-errors-in-opencv-3-beta-python
as implied above, i used:
contours, hierarchy = cv2.findContours(...)[-2:]
and it worked.

(well, needed another of fix:
#3)