1 2 3 4 5 6 7 8 9 10 11 |
lenna = Image("lenna") segment = HaarCascade("face.xml") autoface = lenna.findHaarFeatures(segment) if ( autoface is not None ): face = autoface[-1].crop() face.show() |
其中”face.xml”文件locate一下在:
1 |
/usr/local/lib/python2.7/dist-packages/SimpleCV-1.3-py2.7.egg/SimpleCV/Features/HaarCascades |
同一目录下还有其它的xml文件:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
~$ ls -l /usr/local/lib/python2.7/dist-packages/SimpleCV-1.3-py2.7.egg/SimpleCV/Features/HaarCascades total 20120 -rw-rw-r-- 1 root staff 506314 6月 4 14:38 eye.xml -rw-rw-r-- 1 root staff 919871 6月 4 14:38 face2.xml -rw-rw-r-- 1 root staff 837462 6月 4 14:38 face3.xml -rw-rw-r-- 1 root staff 3644763 6月 4 14:38 face4.xml -rw-rw-r-- 1 root staff 919871 6月 4 14:38 face_cv2.xml -rw-rw-r-- 1 root staff 1254733 6月 4 14:38 face.xml -rw-rw-r-- 1 root staff 636650 6月 4 14:38 fullbody.xml -rw-rw-r-- 1 root staff 1095035 6月 4 14:38 glasses.xml -rw-rw-r-- 1 root staff 312877 6月 4 14:38 left_ear.xml -rw-rw-r-- 1 root staff 777721 6月 4 14:38 left_eye2.xml -rw-rw-r-- 1 root staff 323227 6月 4 14:38 lefteye.xml -rw-rw-r-- 1 root staff 531497 6月 4 14:38 lower_body.xml -rw-rw-r-- 1 root staff 719806 6月 4 14:38 mouth.xml -rw-rw-r-- 1 root staff 1585210 6月 4 14:38 nose.xml -rw-rw-r-- 1 root staff 1125633 6月 4 14:38 profile.xml -rw-rw-r-- 1 root staff 324727 6月 4 14:38 right_ear.xml -rw-rw-r-- 1 root staff 1383113 6月 4 14:38 right_eye2.xml -rw-rw-r-- 1 root staff 324586 6月 4 14:38 right_eye.xml -rw-rw-r-- 1 root staff 358385 6月 4 14:38 two_eyes_big.xml -rw-rw-r-- 1 root staff 410204 6月 4 14:38 two_eyes_small.xml -rw-rw-r-- 1 root staff 1046387 6月 4 14:38 upper_body2.xml -rw-rw-r-- 1 root staff 1522737 6月 4 14:38 upper_body.xml |
这下眼耳口鼻,全身,半身,上身,下身都有了!
http://tutorial.simplecv.org/en/latest/examples/segment.html