I have the following code which should detect a open palm in img.jpg: #!/usr/bin/env python # -*- coding: utf-8 -*- import cv2 import glob #somehow if the path doesn't end in \n it will raise another error classifier=cv2.CascadeClassifier("path/to/classifier.xml\n") r=classifier.detectMultiScale(cv2.cvtColor(img,cv2.CV_8U)) print r cv2.rectangle(img,r[0],r[1],(0,0,255)) cv2.imshow("result",img) cv2.waitKey(1000) classifier.xml is generated by a script similar to i="path/to/positives/images" cd $i #list of the positive images find . -name '*' -exec identify -format '%i 1 0 0 %w %h' \{\} \; >ls.txt opencv_createsamples -vec $(pwd)/coll.vec -info ls.txt \ -bg negatives/ls.txt -w 24 -h 24 -num 1550 mkdir path/to/classifiers #the directory where we put the classifiers opencv_traincascade -data path/to/classifiers\ -bg negatives/ls.txt -vec coll.vec -featureType LBP \ -w 24 -h 24 -numPos 1300 -minHitRate 0.99 \ -precalcValBufSize 4096 -precalcIdxBufSize 4096 But when I execute the python script it gives me the following output () Traceback (most recent call last): File "test1.py", line 13, in <module> cv2.rectangle(img,r[0],r[1],(0,0,255)) IndexError: tuple index out of range How and where did I do wrong?
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)