Removed The Cheats

In my last blog I increased the area searched around the mouth, and all of a sudden I detected a bunch of smiles. Earlier in my search for a working smiles haarcascade file, I created a bunch of jpegs from the video I'm using as an example of smiles. Offhand, this sounds like terrible programming, but what I was trying to do was create a haarcascade file that contained the information in the video; if my Python program worked, it would have to find smiles, even if there weren't any. To make sure I was actually detecting smiles (now that I knew my Python program was working) I ran my Python program against a video of all the different emotional expressions. The smiles showed up as smile hits, but so did some of the non-smile expressions; the result of putting in every single frame of the smile video (including all of the non-smile frames, and these were showing up as false positives). So what I did for this blog was remove all of my "Cheats" before creating a new haarcascade file.

I'm still getting a bunch of smile hits, even without any of the video frames embeddded into the haarcascade file. After getting rid of the "Cheats", I added back in some smile jpegs too get the total number of smile samples over 1000 (got it to 1014). I still haven't run this haarcascade file against a multiple emotional expression video, but I need to do that (and find out if I need to check my smile jpegs for any more that I need to delete). BTW, the last blog featured the text of my Python program called "video_streamer17Surface.py.txt" but now it's missing from my website. I'm uploading a new text file by the same name, but it's a little different; features a smaller enlargement around the smile area then the old text file did - still is working, but there is less chance of the program capturing an image that isn't a smile.

Before I go, I want to make a comment about the current state of OpenCV. I decided to do this work on my 8 GByte Raspberry Pi 4 Model B. I went ahead and installed OpenCV from the Raspberry Pi repositories, but couldn't find opencv_createsamples after the installation. Looking into this, I found out that the last version of OpenCV that included opencv_createsamples was version 3.4.15. I went ahead and created Opencv from the Github source, but after getting the source I entered

git checkout 3.4

After re-installing OpenCV, I created the new haarcascade file by entering the following commands:

opencv_createsamples -info pos.txt -num 1014 -bg bg.txt -vec vector/facevector.vec -w 25 -h 25 -maxxangle 1.5 -maxyangle 1.5 -maxzangle 0.75

opencv_traincascade -vec vector/facevector.vec -data cascades -bg bg.txt -numPos 800 -numNeg 400 -numStages 10 -precalcValBufSize 1024 -precalcIdxBufSize 1024 -numThreads 4 -w 25 -h 25 -mode ALL

I

Return To My Blog Page       Video Streamer       Return To My Programming Page