https://qiita.com/Threen/items/b21a0e1a9b0624f3ba8c
上記のサイトを参考に、顔認証プログラムを作成しています。
カメラを起動し、40枚ほど写真を撮影、撮った写真のかさ増しを行い、顔を学習するプログラムです。
サイトのプログラムを書き換えているわけではないので、コード自体に問題があるとは思えないのですが、
Train dataset for temp stage can not be filled. Branch training terminated. Cascade classifier can't be trained. Check the used training parameters.
というエラーが出てしまい、動作してくれません。
cascadeはリンク先のものを使用しています。
https://github.com/opencv/opencv/blob/master/data/haarcascades/haarcascade_frontalface_default.xml
cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml') picnum_max = input('please input a number of pictures to take\n') # remove pos and files in pic/pos removePic() # start video and take pictures takePic(cascade, int(picnum_max)) # count a number of picutres bulkOut() # make text file of face positions in pictures generatePosFile(cascade) subprocess.call('opencv_createsamples -info pos.txt -vec pos.vec -num ' + str(countPic()), shell=True) posnum = input('please input a number of created pos\n') subprocess.call('opencv_traincascade -data ./cascade -vec pos.vec -bg neg.txt -numPos ' + posnum + ' -numNeg 40', shell=True)
上記のコードがcascadeを指定している部分です。
cascadeを使える様にする方法があれば教えてもらえると幸いです。
環境
macos monterey ver.12.5
python 3.7.13
vscode
あなたの回答
tips
プレビュー