I am looking at adding recognition software to this pi 3.

What prompted this was a squirrel who keeps leaving black walnut shells on my deck, both of which are nasty creatures. Who wouldn't want a pi that realizes it is a squirrel and then pulls the proverbial trigger on it? I am not sure what "the trigger" will become, possibly my compressed air pellet gun, possibly a dog barking wav file.. not sure yet. Time will tell just how destructive I want to be. Since Mr. Squirrel has also filled my boat with shells and ripped the seats apart, it may eventually trigger some c4.. haha.
I have used a few recognition packs listed elsewhere on this site, but this time I am going to try tensorflow.
Ref:ADAFruit
After installing the camera to the camera slot on the pi I ran
sudo raspi-config to turn the camera on in the settings. It is the first setting under Interfacing Options.
As usual, I will do some setup standards.
sudo apt update
sudo apt-get update
sudo apt-get upgrade
You will need to install some additional python libs. Some may already be installed depending on your version. I am using the CLI only version of buster.
sudo apt-get install -y python3-pip
pip3 install --upgrade setuptools
Because I am not using the pi touchscreen on this round, I skipped the touch screen installs. I am using hdmi output.
More utils..
sudo apt-get install -y libatlas-base-dev libhdf5-dev libc-ares-dev libeigen3-dev build-essential libsdl-ttf2.0-0 python-pygame festival
Since I am using ssh to get to the pi, I typed raspistill -t 0 as mentioned and the camera video displayed when I switched over to the pi hdmi. (Funny story, the video was just a big red screen.. then I realized I had it facing down and it was pointing at the red static mat. Turning it over I then had the image of the basement ceiling. lols
On to the tensorflow setup.
Some preqs - (*almost 50MB so it takes a little time)
pip3 install virtualenv Pillow numpy pygame
For some reason GIT did not appear to be installed and required for the next step. I ended up doing
sudo apt update and then
sudo apt install git and it installed.
Install required for object detection. This part takes a wee while.
cd ~
git clone --depth 1 https://github.com/adafruit/rpi-vision.git
cd rpi-vision
python3 -m virtualenv -p $(which python3) .venv
source .venv/bin/activate
This pretty muched seemed to be an instant failure. Not for the faint of heart for sure. reinstall after reinstall nothing seemed to work.jerrors, upon erros... etc.ex
I did finally get it working though.
As it turns out, I had to follow the instructions for installing the 3.5 display on adafruit. There are libs it was looking for.
Once I did that it failed on the display because I did not actually have the 3.5 display connected due to it having the piface hat.
The python script tests/pitft_labeled_output.py file needed to have the line that points to /dev/fb1 to dev/fb0.
Once I changed that, I was able to see the output on the hdmi on the piface pi.
Though it said that it would recognize things like a cup, this was not the case for me.
Possibly, it was the lighting, camera angle, something.
I tried all different types of objects and none of them were successful that I could tell for recognition.
I even tried a slide show from google on a tablet in front of the camera and not one "squirrel" was recognized.
That was somewhat depressing since the whole reason was to possibly recognize a squirrel.
I also noticed that the power icon kept on pretty regularly so it was probably burning a good amount of processor while running.
I guess it is back to the drawing board, possibly with openCV. That one did have cat recognition but I was unable to find anything for any other animals.
Was worth a shot though and was actually kind of cool. I may play with it more in the future but I guess for now I am bouncing back to the openCV pi forum.