Ask Your Question

rosnikv's profile - activity

2014-04-29 03:23:23 -0600 received badge  Student (source)
2014-02-15 12:21:56 -0600 asked a question Real time video processing, attribute error in python-opencv

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?