While dealing with the given below snippet, i got error :
[freestyler@localhost realtime]$
python pygam.py VIDIOC_QUERYMENU:
Invalid argument VIDIOC_QUERYMENU:
Invalid argument VIDIOC_QUERYMENU:
Invalid argument Traceback (most
recent call last): File "pygam.py",
line 35, in <module>
facecrop = fd2.faceCrop(im,boxScale=1) File
"/home/freestyler/mainpro/realtime/fd2.py",
line 97, in faceCrop
croppedImage=imgCrop(cv_im, face[0],boxScale=boxScale) File
"/home/freestyler/mainpro/realtime/fd2.py",
line 73, in imgCrop
return image.crop(PIL_box) AttributeError: 'cv2.cv.iplimage'
object has no attribute 'crop'
def imgCrop(image, cropBox, boxScale=1):
xDelta=max(cropBox[2]*(boxScale-1),0)
yDelta=max(cropBox[3]*(boxScale-1),0)
# Convert cv box to PIL box [left, upper, right, lower]
PIL_box=[cropBox[0]-xDelta, cropBox[1]-yDelta, cropBox[0]+cropBox[2]+xDelta, cropBox[1]+cropBox[3]+yDelta]
**return image.crop(PIL_box) <---- problem here**
def faceCrop(img,boxScale=1):#changed imagepattern to img not going to process a complete list
faceCascade = cv.Load('Mouth.xml')
#pil_im=Image.open(img)
cv_im=pil2cvGrey(img)
faces=DetectFace(cv_im,faceCascade)
if faces:
n=1
for face in faces:
croppedImage=imgCrop(cv_im, face[0],boxScale=boxScale)
if n==1:
croppedImage.save("mouth.jpg")
fname,ext=os.path.splitext(img)
croppedImage.save(fname+'_crop'+str(n)+ext)
n+=1
else:
print 'No faces found:', img
Any idea!! How to solve this?