Open robbyleh opened 7 years ago
Hello Robby,
Thanks for the interest in my project, I look forward to hearing of any progress you make.
There is full support to use webcams with the code. But to do that on the raspberry pi it will require some small code changes.
There is full support for using webcams with catcierge. But I have kind of written the code to make use of that on non-Raspberry Pi platforms (Windows, OSX, Linux). The reason for this is that at first when I started on this project, only the original Raspberry Pi was available. And that version was way to weak to support doing the things that catcierge does using a webcam. For that reason the code is written to assume that if you're using Raspberry Pi you're always using the onboard camera.
Currently I only have one compile-time flag that decides if it's an RPI, which turns on everything RPI specific, including the use of the special camera. To enable using a webcam on the Raspberry Pi I would have to create a separate flag for setting the camera either to "generic" (webcam or whatever) or the built-in raspberry cam. I might be able to do that this week.
When I initially wrote this code, OpenCV the library I use for the image recognition tasks did not have native support for that camera (I think later versions now do), so there's some special code to handle that.
OpenCV should work out of the box with any USB webcam in Linux, but since I haven't tried that myself I cannot verify that. This is the functionality I use on all other platforms, and what I need to enable on the RPI platform as well.
One benefit with the built-in raspberry pi camera is that it supports a lot more tweaking of settings.
Hi Joakim,
great. I'll get a raspi-cam. Its really cheep. Currently I examine to use a backlight from an old 17" Screen of an old laptop :-)... Thanks, Robby
Hello,
I pushed some changes now that should enable you to use a USB webcam on the Raspberry Pi as well.
To get the latest changes:
git checkout master
git pull --rebase origin master
And then to build follow the build instructions in the README.
I added an extra flag --non_rpi_cam
that will look for a "generic" camera like a USB webcam instead of the builtin RPi camera.
If there are multiple attached, you can also specify which one using --camera_index
.
Since I have no USB webcam myself, I have not tested this myself. So it would be nice if you could try?
Hi Joakim,
absolutely great! Thank you for your quick action!
I'm not as good in GIT.
I followed your instruction, but failed at the first command: ( Do I have to replace master with something else? )
history: robby@catpreyblock:~/Katzenklappe $ cd catcierge/ robby@catpreyblock:~/Katzenklappe/catcierge $ ls -l total 112 -rw-r--r-- 1 robby robby 745 Apr 30 15:22 appveyor.yml drwxr-xr-x 8 robby robby 4096 Apr 30 15:55 build -rwxr-xr-x 1 robby robby 484 Apr 30 15:22 build_userland.sh -rw-r--r-- 1 robby robby 305 Apr 30 15:22 circle.yml drwxr-xr-x 3 robby robby 4096 Apr 30 15:22 cmake -rw-r--r-- 1 robby robby 19780 Apr 30 15:22 CMakeLists.txt drwxr-xr-x 2 robby robby 4096 May 2 00:53 doc -rw-r--r-- 1 robby robby 409 Apr 30 15:22 drmemory-suppress.txt drwxr-xr-x 7 robby robby 4096 Apr 30 15:22 examples drwxr-xr-x 4 robby robby 4096 Apr 30 15:22 extra -rw-r--r-- 1 robby robby 18048 Apr 30 15:22 LICENSE.md drwxr-xr-x 2 robby robby 4096 Apr 30 15:22 prototype -rw-r--r-- 1 robby robby 11896 Apr 30 15:22 README.md drwxr-xr-x 11 robby robby 4096 Apr 30 15:25 rpi_userland drwxr-xr-x 7 robby robby 4096 Apr 30 15:22 src drwxr-xr-x 2 robby robby 4096 Apr 30 15:22 test -rwxr-xr-x 1 robby robby 6105 Apr 30 15:22 valgrind-suppress.txt robby@catpreyblock:~/Katzenklappe/catcierge $ git checkout master M doc/README.md M rpi_userland Already on 'master' Your branch is up-to-date with 'origin/master'.
Thanks, Robby
Joakim Söderberg notifications@github.com hat am 3. Mai 2017 um 00:50 geschrieben:
Hello,
I pushed some changes now that should enable you to use a USB webcam on the Raspberry Pi as well.
To get the latest changes:
git checkout master git pull --rebase origin master
And then to build follow the build instructions in the README.
I added an extra flag
--non_rpi_cam
that will look for a "generic" camera like a USB webcam instead of the builtin RPi camera.If there are multiple attached, you can also specify which one using
--camera_index
.Since I have no USB webcam myself, I have not tested this myself. So it would be nice if you could try?
-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/JoakimSoderberg/catcierge/issues/20#issuecomment-298783071
That's not an error, just to make sure you were on the right branch.
However since you have edited the README you will get an error. (I can see that from the line):
M doc/README.md
So before you do the second command first type:
git stash
and then:
git pull --rebase origin master
(You can get your changes back after that (if you intended to edit it)):
git stash pop
Hi Joakim,
I compiled the new code. In the --help section I can see the new Option "--no_rpi_cam". I tried to start (my first time, because I stoped the readme at the position of "Verify the camera orientation" ... "raspivid ...".
here the output of the first try. I guess I have to do some researches, It seems these are some issues because I did not configure anything. I just created the empty file "/etc/catcierge/catcierge-rpi.cfg", but it did not help.
root@catpreyblock:~# catcierge_grabber --non_rpi_cam
Catcierge Grabber v0.6.5-64ea8da (64ea8da-tainted) (C) Joakim Soderberg 2013-2016
Library versions: OpenCV v2.4.9
General: Startup delay: 0.0 seconds Auto ROI: 0 Show video: 0 Save matches: 1 Save obstruct: 1 Save steps: 1 Highlight match: 0 Lockout dummy: 0 Lockout method: 1 Lock time: 30 seconds Lockout error: 0 (off) Lockout err delay: 3.0 Match timeout: 0 seconds Log file: - No color: 0 No animation: 1 Ok matches needed: 2 Output path: /home/catcierge/images/%match_group_start_time:&Y-&m-&d% Match output path: %output_path%/%match_group_id% Steps output path: %match_output_path%/%matchcur_idx%
Matcher type: haar
Haar Cascade Matcher: Cascade: /usr/local/share/catcierge/catcierge.xml In direction: Right Min size: 80x80 Equalize histogram: 0 No match is fail: 0 Prey method: Adaptive Prey steps: 2
[2017-05-03 09:31:05.508489] Failed to write "4" to /sys/class/gpio/export [2017-05-03 09:31:05.509052] Initialized GPIO pins [2017-05-03 09:31:05.522100] Initialized catcierge image recognition Adding user defined variable: 'to_email test@example.com' Adding user defined variable: 'from_email test2@example.com' Adding user defined variable: 'from_email_passw my_secret' [2017-05-03 09:31:05.522240] Loading output templates: [2017-05-03 09:31:05.522415] Event filters: match_group_done [2017-05-03 09:31:05.522456] catcierge_event (%match_group_id%.json) [2017-05-03 09:31:05.522531] Failed to open input template file "/usr/local/share/catcierge/templates/compose_script.sh.in" [2017-05-03 09:31:05.522594] Failed to load output templates
Robby
Joakim Söderberg notifications@github.com hat am 3. Mai 2017 um 01:32 geschrieben:
That's not an error, just to make sure you were on the right branch.
However since you have edited the README you will get an error. (I can see that from the line):
M doc/README.md
So before you do the second command first type:
git stash
and then:
git pull --rebase origin master
(You can get your changes back after that (if you intended to edit it)):
git stash pop
-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/JoakimSoderberg/catcierge/issues/20#issuecomment-298789932
Hmm not sure if I understand what you mean:
I tried to start (my first time, because I stoped the readme at the position of "Verify the camera orientation" ... "raspivid ...".
You are using a webcam on your Raspberry Pi now? Correct?
If that is the case, any settings for the Raspberry Pi camera is not relevant for you. Anything found under --camhelp
is something you can ignore
Also, I suggest you don't fiddle with any of those settings as the first thing anyway. Remove that config file completely. You have done something wrong in it anyway. From your log:
[2017-05-03 09:31:05.495108] Reading Raspberry Pi camera config: /etc/catcierge/catcierge-rpi.cfg
[2017-05-03 09:31:05.495647] Raspberry Pi camera: Failed to split input into command line:
here the output of the first try. I guess I have to do some researches, It seems these are some issues because I did not configure anything. I just created the empty file "/etc/catcierge/catcierge-rpi.cfg", but it did not help.
That config is only meant for more advanced settings for the Raspberry camera (not the webcam). (I only have 2 settings in that file myself, and those are only for flipping the camera image since I happen to have mine mounted upside down).
This is definantly NOT the first step :)
I realise I have not created any "getting started guide", and there's a billion settings and config files to thing about. So, let me suggest the easiest route.
You can test the executable and play around, it's best to do this at first, to understand how things work.
Here's an example of me running (I use --no_default_config
to make sure no default config found on the system is used).
(Note in the examples below my build dir is named build2
. That does not matter)
pi@picat ~/dev/catcierge/build2 $ bin/catcierge_grabber --no_default_config
Catcierge Grabber v0.6.5-c04a0b9 (c04a0b9-tainted)
(C) Joakim Soderberg 2013-2016
Library versions:
OpenCV v2.4.1
Failed to open PID file "/var/run/catcierge.pid"
[2017-05-03 16:46:36.310457] Reading Raspberry Pi camera config: /etc/catcierge/catcierge-rpi.cfg
[2017-05-03 16:46:36.312266] Failed to open file /etc/catcierge/catcierge-rpi.cfg
[2017-05-03 16:46:36.317047] Could not read Raspberry Pi camera config
[2017-05-03 16:46:36.319051] Using default config
[2017-05-03 16:46:36.319782] Default config turned off, ignoring: /etc/catcierge/catcierge.cfg
Usage: catcierge_grabber [--help] [--config CONFIG] [--config_rpi CONFIG_RPI] [--no_default_config] [--chuid CHUID]
........................
[--roi X Y WIDTH HEIGHT, --auto_roi] {--template_matcher, --haar_matcher}
One of these variables is required:
--template_matcher, --haar_matcher
Here it tells me I need to pick one of the matcher types... Here you ALWAYS want the --haar_matcher
, since that's the best and latest. So I add that to the command line. But then I get a new error:
pi@picat ~/dev/catcierge/build2 $ bin/catcierge_grabber --no_default_config --haar_matcher
..........
[2017-05-03 16:49:02.074377] Haar matcher: No cascade xml specified. Use --cascade
[2017-05-03 16:49:02.075903] Failed to init Haar Cascade matcher
Which might not be obvious what it is ... But you can find that out in the --help
under the Haar cascade matcher settings
.
Here I quickly search for it using grep
... The -C10
just says "show 10 lines before and after each matched line":
pi@picat ~/dev/catcierge/build2 $ bin/catcierge_grabber --help | grep -C10 cascade
...
Haar cascade matcher settings:
Settings for when --haar_matcher is used.
This is the recommended matcher type.
--cascade CASCADE Path to the haar cascade xml generated by opencv_traincascade.
....
This file is what's used to find the cat head in the picture. One is available in the code under the path ../extra/catcierge.xml
relative to our build
directory:
pi@picat ~/dev/catcierge/build2 $ bin/catcierge_grabber --no_default_config --haar_matcher --cascade ../extra/catcierge.xml
This time it starts working and you will get a bunch of output like below. Since your camera will be pointing at something random it will probably trigger right away and give you Lockout errors like I get. However if the camera simply is pointing at a white uniform background it will work fine.
pi@picat ~/dev/catcierge/build2 $ bin/catcierge_grabber --no_default_config --haar_matcher --cascade ../extra/catcierge.xml
Catcierge Grabber v0.6.5-c04a0b9 (c04a0b9-tainted)
(C) Joakim Soderberg 2013-2016
Library versions:
OpenCV v2.4.1
Failed to open PID file "/var/run/catcierge.pid"
[2017-05-03 16:49:52.926438] Reading Raspberry Pi camera config: /etc/catcierge/catcierge-rpi.cfg
[2017-05-03 16:49:52.928286] Failed to open file /etc/catcierge/catcierge-rpi.cfg
[2017-05-03 16:49:52.933276] Could not read Raspberry Pi camera config
[2017-05-03 16:49:52.935659] Using default config
[2017-05-03 16:49:52.936352] Default config turned off, ignoring: /etc/catcierge/catcierge.cfg
--------------------------------------------------------------------------------
Settings:
--------------------------------------------------------------------------------
General:
Startup delay: 0.0 seconds
Auto ROI: 0
Show video: 0
Save matches: 1
Save obstruct: 0
Save steps: 0
Highlight match: 0
Lockout dummy: 0
Lockout method: 1
Lock time: 30 seconds
Lockout error: 0 (off)
Lockout err delay: 3.0
Match timeout: 0 seconds
Log file: -
No color: 0
No animation: 0
Ok matches needed: 2
Output path: .
Matcher type: haar
Haar Cascade Matcher:
Cascade: ../extra/catcierge.xml
In direction: Right
Min size: 80x80
Equalize histogram: 0
No match is fail: 0
Prey method: Adaptive
Prey steps: 2
RFID:
Inner RFID: -
Outer RFID: -
Lock on no RFID: 0
RFID lock time: 0.00 seconds
Allowed RFID: -
--------------------------------------------------------------------------------
[2017-05-03 16:49:52.943196] Failed to write "4" to /sys/class/gpio/export
[2017-05-03 16:49:52.946046] Initialized GPIO pins
[2017-05-03 16:49:52.989180] Initialized catcierge image recognition
[2017-05-03 16:49:52.990018] Initialized output templates
[2017-05-03 16:49:52.990709] Initialized RFID readers
[2017-05-03 16:49:53.404457] Starting detection!
[2017-05-03 16:49:53.405299] [Initial] -> [Waiting]
[2017-05-03 16:49:53.426211] Startup delay of 0.00 seconds has ended!
[2017-05-03 16:49:53.428574] Something in frame! Start matching...
[2017-05-03 16:49:53.463652]
[2017-05-03 16:49:53.464510] === Match group id: cb4f5f88f7587a185c31e50456b89af4140be768 ===
[2017-05-03 16:49:53.465146]
[2017-05-03 16:49:53.465982] [Waiting] -> [Matching]
[2017-05-03 16:49:53.530760] Match in - No cat head detected (4a4b0af15c7d051c76956d92180dd81248c8f665)
[2017-05-03 16:49:53.601247] Match in - No cat head detected (c2e3e6f47c8dde32ce7c3d962af9aa5c9339a89a)
[2017-05-03 16:49:53.668535] Match in - No cat head detected (7792a19d6f1dca03a489a208d1bd1f3ff9c2390)
[2017-05-03 16:49:53.736250] Match in - No cat head detected (bd9caefce07d8fb2cf746ae218d9beed49e3b2d9)
[2017-05-03 16:49:53.737675] !!! Match group vetoed match success: No head found in any image !!!
[2017-05-03 16:49:53.743001] Lockout! 0 out of 4 matches failed (for 30 seconds).
[2017-05-03 16:49:53.743234] Waiting for lockout timer only (Lockout method 1)
[2017-05-03 16:49:53.743376] [Matching] -> [Lockout]
[2017-05-03 16:49:53.744355] Saving image ./match__2017-05-03_16_49_53.496674__1.png
[2017-05-03 16:49:53.759913] Saving image ./match__2017-05-03_16_49_53.566832__2.png
[2017-05-03 16:49:53.771090] Saving image ./match__2017-05-03_16_49_53.634172__3.png
[2017-05-03 16:49:53.787343] Saving image ./match__2017-05-03_16_49_53.701802__4.png
[2017-05-03 16:49:55.173878] Received SIGINT, stopping...
At the end there I pressed ctrl+c on the keyboard to quit. Otherwise it will keep spamming and saving images.
Ofcourse specifying all the settings like this on the command line is a bit tedious. Instead of doing that you can create a config file. By default catcierge will look for one at /etc/catcierge/catcierge.cfg
. But you can create it wherever you want and specify the path using --config
.
Options:
-h, --help Show this help
-c, --config CONFIG Path to the catcierge config file. Catcierge looks for /etc/catcierge/catcierge.cfg
by default, unless --no_default_config has been specified. Setting this overrides
the default config.
NOTE: Options for the raspberry pi camera settings --rpi, cannot be used in this
config. Please see --config_rpi and --camhelp for details.
--config_rpi CONFIG_RPI Path to config file for raspberry pi camera settings. See --camhelp for details.
Default location: /etc/catcierge/catcierge-rpi.cfg
--no_default_config Do not load the default config (/etc/catcierge/catcierge.cfg) if none is specified
using --config
NOTE --config_rpi
is something different, and only meant for advanced settings for the onboard raspberry pi camera.
But it's not advisable to run the final setup like this! To facilitate a "proper" installation I have made it so that you can build a debian package.
pwd # Make sure you are in the `build/` directory.
cmake .. # Make sure to re-generate the Make files if needed.
make # And make sure our build is up to date.
# Now we can build the debian package:
cpack -G DEB
You should see something like this:
CPack: Create package using DEB
CPack: Install projects
CPack: - Run preinstall target for: catcierge
CPack: - Install project: catcierge
CPack: Create package
CPack: - package: /home/pi/dev/catcierge/build3/catcierge-0.6.5-64ea8da-armhf.deb generated.
This debian package. will include an example config files that will be placed under /etc/catcierge/catcierge-example.cfg
, you get some step by step instructions on how to proceed as well.
It will also help you setting up catcierge_grabber
to run as a service. So when you reboot it will start running immediately. It will also setup the GPIO pins in the proper mode at boot (the pin that will be used to trigger the lock being the important one).
So now that you have built the debian package you can install it:
sudo dpkg -i catcierge-0.6.5-64ea8da-armhf.deb
You should now get some more instructions on what more to do.
Here's a full list of the files it will install:
$ dpkg -c catcierge-0.6.5-64ea8da-armhf.deb
drwxr-xr-x root/root 0 2017-05-03 13:40 ./lib/
drwxr-xr-x root/root 0 2017-05-03 13:40 ./lib/systemd/
drwxr-xr-x root/root 0 2017-05-03 13:40 ./lib/systemd/system/
-rw-r--r-- root/root 293 2016-07-03 21:16 ./lib/systemd/system/catcierge.service
-rw-r--r-- root/root 159 2016-07-03 21:16 ./lib/systemd/system/catcierge_rpi_gpio.service
drwxr-xr-x root/root 0 2017-05-03 13:40 ./etc/
drwxr-xr-x root/root 0 2017-05-03 13:40 ./etc/catcierge/
-rw-r--r-- root/root 2771 2017-05-02 23:30 ./etc/catcierge/catcierge-example.cfg
drwxr-xr-x root/root 0 2017-05-03 13:40 ./usr/
drwxr-xr-x root/root 0 2017-05-03 13:40 ./usr/local/
drwxr-xr-x root/root 0 2017-05-03 13:40 ./usr/local/share/
drwxr-xr-x root/root 0 2017-05-03 13:40 ./usr/local/share/catcierge/
drwxr-xr-x root/root 0 2017-05-03 13:40 ./usr/local/share/catcierge/templates/
-rw-r--r-- root/root 2586 2016-07-21 13:56 ./usr/local/share/catcierge/templates/event.json
-rw-r--r-- root/root 17747 2016-02-22 02:09 ./usr/local/share/catcierge/templates/match_group.json
-rw-r--r-- root/root 17774 2016-04-29 01:53 ./usr/local/share/catcierge/templates/match_group_done_full.json
-rw-r--r-- root/root 204 2016-04-29 01:53 ./usr/local/share/catcierge/templates/state_change.json
-rw-r--r-- root/root 8903 2016-07-20 14:29 ./usr/local/share/catcierge/catcierge-compose.py
-rw-r--r-- root/root 66096 2016-02-22 02:09 ./usr/local/share/catcierge/catcierge.xml
-rw-r--r-- root/root 2243 2016-02-22 02:09 ./usr/local/share/catcierge/catcierge-twitter.py
-rw-r--r-- root/root 4892 2016-08-01 01:39 ./usr/local/share/catcierge/catcierge-sendmail-new.py
drwxr-xr-x root/root 0 2017-05-03 13:40 ./usr/local/share/catcierge/fonts/
drwxr-xr-x root/root 0 2017-05-03 13:40 ./usr/local/share/catcierge/fonts/alex-brush/
-rw-r--r-- root/root 49020 2016-02-22 02:09 ./usr/local/share/catcierge/fonts/alex-brush/AlexBrush-Regular.ttf
-rw-r--r-- root/root 4392 2016-02-22 02:09 ./usr/local/share/catcierge/fonts/alex-brush/SIL Open Font License.txt
drwxr-xr-x root/root 0 2017-05-03 13:40 ./usr/local/share/catcierge/fonts/source-code-pro/
-rw-r--r-- root/root 88912 2016-02-22 02:09 ./usr/local/share/catcierge/fonts/source-code-pro/SourceCodePro-Black.otf
-rw-r--r-- root/root 90032 2016-02-22 02:09 ./usr/local/share/catcierge/fonts/source-code-pro/SourceCodePro-Semibold.otf
-rw-r--r-- root/root 89596 2016-02-22 02:09 ./usr/local/share/catcierge/fonts/source-code-pro/SourceCodePro-Medium.otf
-rw-r--r-- root/root 92676 2016-02-22 02:09 ./usr/local/share/catcierge/fonts/source-code-pro/SourceCodePro-Bold.otf
-rw-r--r-- root/root 88600 2016-02-22 02:09 ./usr/local/share/catcierge/fonts/source-code-pro/SourceCodePro-Light.otf
-rw-r--r-- root/root 85084 2016-02-22 02:09 ./usr/local/share/catcierge/fonts/source-code-pro/SourceCodePro-ExtraLight.otf
-rw-r--r-- root/root 4525 2016-02-22 02:09 ./usr/local/share/catcierge/fonts/source-code-pro/SIL Open Font License.txt
-rw-r--r-- root/root 90056 2016-02-22 02:09 ./usr/local/share/catcierge/fonts/source-code-pro/SourceCodePro-Regular.otf
drwxr-xr-x root/root 0 2017-05-03 13:40 ./usr/local/share/catcierge/fonts/Asana-Math/
-rw-r--r-- root/root 428892 2016-02-22 02:09 ./usr/local/share/catcierge/fonts/Asana-Math/Asana-Math.otf
-rw-r--r-- root/root 499052 2016-02-22 02:09 ./usr/local/share/catcierge/fonts/Asana-Math/Asana-Math.ttf
-rw-r--r-- root/root 1591 2016-02-22 02:09 ./usr/local/share/catcierge/fonts/Asana-Math/FontLog.txt
-rw-r--r-- root/root 922 2016-02-22 02:09 ./usr/local/share/catcierge/fonts/Asana-Math/README
-rw-r--r-- root/root 374 2016-07-03 21:16 ./usr/local/share/catcierge/catcierge_rpi_gpio.sh
drwxr-xr-x root/root 0 2017-05-03 13:40 ./usr/local/bin/
-rwxr-xr-x root/root 454576 2017-05-03 13:40 ./usr/local/bin/catcierge_rfid_tester
-rwxr-xr-x root/root 468492 2017-05-03 13:40 ./usr/local/bin/catcierge_fsm_tester
-rwxr-xr-x root/root 468244 2017-05-03 13:40 ./usr/local/bin/catcierge_tester
-rwxr-xr-x root/root 468640 2017-05-03 13:40 ./usr/local/bin/catcierge_grabber
-rwxr-xr-x root/root 464444 2017-05-03 13:40 ./usr/local/bin/catcierge_bg_tester
P.S. If you write your messages via github instead, you can use formatting for your code and such, which makes things a bit easier to read.
Oh yea, and you should use --non_rpi_cam
unlike me in the above examples
Also, once you have installed the debian package and followed the instructions that you were prompted with, catcierge should be setup to run as a service and can be controlled using systemctl
.
So for example to restart the service:
sudo systemctl restart catcierge
Here's a guide on how systemctl works: https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units
None of this is foolproof, since I am the only one who has ever used it. So ask if you run into any issues, and please provide as much context as you can so I can easily understand what you have done.
Hey Joakim,
you answers are so much in detail, wowww. Amazing... Don't forget, I already read your README.txt files ;-). So the DEB packaging I already did :-) Thank you for all your time you spend for help ...
I'll continue around midnight with the code stuff. Recent hour I finished the backlight (made from a Laptop Display). See attached picture. It's really perfect I think...
Robby Will let you know about my progress soon...
Joakim Söderberg notifications@github.com hat am 3. Mai 2017 um 19:06 geschrieben:
Oh yea, and you should use
--non_rpi_cam
unlike me in the above examplesAlso, once you have installed the debian package and followed the instructions that you were prompted with, catcierge should be setup to run as a service and can be controlled using
systemctl
.So for example to restart the service:
sudo systemctl restart catcierge
Here's a guide on how systemctl works: https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units
None of this is foolproof, since I am the only one who has ever used it. So ask if you run into any issues, and please provide as much context as you can so I can easily understand what you have done.
-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/JoakimSoderberg/catcierge/issues/20#issuecomment-298973813
Hi Joakim,
it works !!! ( with usb webcam ) I made a silhouette of paper. With many trys I could get matches with and without pray. I'll construct the Box that all is fixed and correct in place, Furthermore I have to create a pushmagnet lock. I guess I can create it byself. I also wind a lot of loudspeaker coils in the past. But I'll also take a look on the marked what is available there...
Robby
with pray: [2017-05-04 01:09:25.350873] [Waiting] -> [Matching] [2017-05-04 01:09:25.414932] Match in - No cat head detected (b98bd4dfeccc157a915e60e23275adb8e35ef5) [2017-05-04 01:09:25.471685] Match in - No cat head detected (15e0525b533aa0be3573e9ed3a24d38cc262a61a) [2017-05-04 01:09:25.531324] No Match in - Prey detected (a6267143941451033e1174f8155cacab2024b1c7) [2017-05-04 01:09:25.579501] Match in - No cat head detected (e69326786bd27ae788842d9a7c05c13cebb3c538) [2017-05-04 01:09:25.580095] Everything OK! (3 out of 4 matches succeeded) Door kept open... [2017-05-04 01:09:25.580309] [Matching] -> [Keep open] [2017-05-04 01:09:25.580363] Saving image ./match2017-05-04_01_09_25.3722901.png [2017-05-04 01:09:25.593410] Saving image ./match2017-05-04_01_09_25.4302562.png [2017-05-04 01:09:25.606085] Saving image ./match_fail_2017-05-04_01_09_25.4937383.png [2017-05-04 01:09:25.620202] Saving image ./match2017-05-04_01_09_25.541922__4.png [2017-05-04 01:09:27.453371] Frame is clear, start successful match timer... [2017-05-04 01:09:27.453532] Go back to waiting... [2017-05-04 01:09:27.453603] [Keep open] -> [Waiting] [2017-05-04 01:09:34.813060] Received SIGINT, stopping...
without pray: [2017-05-04 01:07:14.355767] [Waiting] -> [Matching] [2017-05-04 01:07:14.410116] Match in - No cat head detected (8af5254a541eac8dfd11c3d04a50b1fa7ff5ded8) [2017-05-04 01:07:14.457036] Match in - No cat head detected (a71c64de83229debb3a2172aab431f522f979fb4) [2017-05-04 01:07:14.507544] Match in - No prey detected (6e84b110fef2418ab8ad0da22edb24d4359832e2) [2017-05-04 01:07:14.558071] Match in - No prey detected (6d77bcbf9f60bab136076a651da21ff3c4bfaec4) [2017-05-04 01:07:14.558613] Everything OK! (4 out of 4 matches succeeded) Door kept open... [2017-05-04 01:07:14.558793] [Matching] -> [Keep open] [2017-05-04 01:07:14.558831] Saving image ./match2017-05-04_01_07_14.3725661.png [2017-05-04 01:07:14.571499] Saving image ./match2017-05-04_01_07_14.4195492.png [2017-05-04 01:07:14.585537] Saving image ./match2017-05-04_01_07_14.4699663.png [2017-05-04 01:07:14.598250] Saving image ./match2017-05-04_01_07_14.5205074.png [2017-05-04 01:07:16.190729] Frame is clear, start successful match timer... [2017-05-04 01:07:16.190821] Go back to waiting... [2017-05-04 01:07:16.190839] [Keep open] -> [Waiting]
perfect :-))))
Joakim Söderberg notifications@github.com hat am 3. Mai 2017 um 19:06 geschrieben:
Oh yea, and you should use
--non_rpi_cam
unlike me in the above examplesAlso, once you have installed the debian package and followed the instructions that you were prompted with, catcierge should be setup to run as a service and can be controlled using
systemctl
.So for example to restart the service:
sudo systemctl restart catcierge
Here's a guide on how systemctl works: https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units
None of this is foolproof, since I am the only one who has ever used it. So ask if you run into any issues, and please provide as much context as you can so I can easily understand what you have done.
-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/JoakimSoderberg/catcierge/issues/20#issuecomment-298973813
Nice you got it working! :)
Btw you forgot to attach the image you referred to. I'd love to see your progress.
Furthermore I have to create a pushmagnet lock. I guess I can create it byself. I also wind a lot of loudspeaker coils in the past. But I'll also take a look on the marked what is available there...
You mean a solenoid? That's at least what I use. Sounds interesting to make one on your own.
However if possible make sure it is quite strong. Right now my cat has broken the one I have. When it was subzero temperatures she pushed on the door when it had accidentally gotten locked, and because the shaft of it got very brittle it broke :)
Some tips on building your enclosure:
Keep light pollution down. Make sure you get a uniform light setup for any time of day, if it's pitch black or full sun light.
Build the corridor where the cat enters as an "L" .... So that the cat cannot run too fast by the camera. An added benefit is that wind cannot blow straight into the door either.
If you ever get subzero degrees where you live, you should build an enclosure for your camera + have some sort of heating for that (I can provide pics of my setup, using a cheap. If you don't do this and use the raspberry pi camera, it will stop working (not break, but produces garbage at those temperatures). This might be different for your webcam of course.
If you ever get power outages (I live in a small village, so it happens), make sure you have a battery backup for it. I use this: https://www.modmypi.com/raspberry-pi/breakout-boards/pi-modules/ups-pico ... If you don't have this, its just a matter of time before you have a broken SD card. With this, my cat door has been running non stop for 1.5 years now. (I've had SD cards die because of this before that).
This is a picture of a Spiders Ass:
Here is a picture of it camouflaging itself by sitting on the only dark spot nearby :) This was spamming the cat door the entire night, this week... Stuff like this happens at times, but not super often.
Ohh, the backlight picture I forgot to attach somehow. Here it is. Robby
Von meinem iPhone gesendet
Am 04.05.2017 um 01:21 schrieb Robby Lehmann robby.lehmann@cesp.de:
Hi Joakim,
it works !!! ( with usb webcam ) I made a silhouette of paper. With many trys I could get matches with and without pray. I'll construct the Box that all is fixed and correct in place, Furthermore I have to create a pushmagnet lock. I guess I can create it byself. I also wind a lot of loudspeaker coils in the past. But I'll also take a look on the marked what is available there...
Robby
with pray: [2017-05-04 01:09:25.350873] [Waiting] -> [Matching] [2017-05-04 01:09:25.414932] Match in - No cat head detected (b98bd4dfeccc157a915e60e23275adb8e35ef5) [2017-05-04 01:09:25.471685] Match in - No cat head detected (15e0525b533aa0be3573e9ed3a24d38cc262a61a) [2017-05-04 01:09:25.531324] No Match in - Prey detected (a6267143941451033e1174f8155cacab2024b1c7) [2017-05-04 01:09:25.579501] Match in - No cat head detected (e69326786bd27ae788842d9a7c05c13cebb3c538) [2017-05-04 01:09:25.580095] Everything OK! (3 out of 4 matches succeeded) Door kept open... [2017-05-04 01:09:25.580309] [Matching] -> [Keep open] [2017-05-04 01:09:25.580363] Saving image ./match2017-05-04_01_09_25.3722901.png [2017-05-04 01:09:25.593410] Saving image ./match2017-05-04_01_09_25.4302562.png [2017-05-04 01:09:25.606085] Saving image ./match_fail_2017-05-04_01_09_25.4937383.png [2017-05-04 01:09:25.620202] Saving image ./match2017-05-04_01_09_25.541922__4.png [2017-05-04 01:09:27.453371] Frame is clear, start successful match timer... [2017-05-04 01:09:27.453532] Go back to waiting... [2017-05-04 01:09:27.453603] [Keep open] -> [Waiting] [2017-05-04 01:09:34.813060] Received SIGINT, stopping...
without pray: [2017-05-04 01:07:14.355767] [Waiting] -> [Matching] [2017-05-04 01:07:14.410116] Match in - No cat head detected (8af5254a541eac8dfd11c3d04a50b1fa7ff5ded8) [2017-05-04 01:07:14.457036] Match in - No cat head detected (a71c64de83229debb3a2172aab431f522f979fb4) [2017-05-04 01:07:14.507544] Match in - No prey detected (6e84b110fef2418ab8ad0da22edb24d4359832e2) [2017-05-04 01:07:14.558071] Match in - No prey detected (6d77bcbf9f60bab136076a651da21ff3c4bfaec4) [2017-05-04 01:07:14.558613] Everything OK! (4 out of 4 matches succeeded) Door kept open... [2017-05-04 01:07:14.558793] [Matching] -> [Keep open] [2017-05-04 01:07:14.558831] Saving image ./match2017-05-04_01_07_14.3725661.png [2017-05-04 01:07:14.571499] Saving image ./match2017-05-04_01_07_14.4195492.png [2017-05-04 01:07:14.585537] Saving image ./match2017-05-04_01_07_14.4699663.png [2017-05-04 01:07:14.598250] Saving image ./match2017-05-04_01_07_14.5205074.png [2017-05-04 01:07:16.190729] Frame is clear, start successful match timer... [2017-05-04 01:07:16.190821] Go back to waiting... [2017-05-04 01:07:16.190839] [Keep open] -> [Waiting]
perfect :-))))
Joakim Söderberg notifications@github.com hat am 3. Mai 2017 um 19:06 geschrieben:
Oh yea, and you should use
--non_rpi_cam
unlike me in the above examplesAlso, once you have installed the debian package and followed the instructions that you were prompted with, catcierge should be setup to run as a service and can be controlled using
systemctl
.So for example to restart the service:
sudo systemctl restart catcierge
Here's a guide on how systemctl works: https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units
None of this is foolproof, since I am the only one who has ever used it. So ask if you run into any issues, and please provide as much context as you can so I can easily understand what you have done.
-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/JoakimSoderberg/catcierge/issues/20#issuecomment-298973813
Ah I think it's because you're trying to attach it in a mail. Seems like github throws it away. You need to open the webpage and add it there I think.
Hi, here the photo I missed. ( All my recent comments I sent by email, that's the reason, that my attachments were gone) The new created Backlight (made of an 2010 Sony Laptop Display)....
Hello,
That's nice with a monitor like that. Gives a really good backlight compared to the one I am using, and big as well.
However I could not help seeing your drawing in the background of a build plan. I can see right away that it won't work.
So I started to draw a sketch of my own to show it. But instead moved on to making a CAD model, and got a bit carried away. I've wanted to make one like this before, but only knew sketchup at that time so it was quite futile. So don't think I'm crazy just because I went so overboard 🦑
Anyway, some reasons I saw your design won't work:
You are not taking the swinging door into account, this will trigger the code as the cat is going out. (Of course it would be possible to fix this, by having some kind of external trigger that tells catcierge that the cat is going out, and it should not consider any images. But the design currently uses the camera only for such things).
Having a straight design like this was what I first did as well. This simply won't work in the long run in a robust way, with different light conditions, weather... And the fact that the cat will run past the camera too fast (when my cat got used to the cat door she started speeding up A LOT, so she was basically a streak on the camera image).
Anyway, to illustrate what I mean I created the CAD model as I mentioned. I used the camera specification for the raspberry pi cam from here. Specifically the Field of view (FOV): https://www.raspberrypi.org/documentation/hardware/camera/
This wont' be exactly the same for your webcam, but probably in "the ballpark".
First the version based on your drawing (I interpreted your hand writing as 40x48cm). As you can see the door will intersect with the camera FOV cone which would trigger a bad match:
Then I changed the measurements, moved the camera and created a new version. This one is very close to how I have modified mine after learning all these things (note that these measurements are not the exact same ones I use though):
Here there's an "L-shaped" corridor instead of a straight one, this helps her slow down. Notice that the entrance in the "L-bend" is quite small (15x15cm in the CAD model), this is to make the cat enter the camera frame in a very consistent manner. I also added an acrylic roof that is as low as possible but stays outside of the camera picture to keep this consistency as well. The cat will slow down and keep her head in the same place everytime she walks past.
If you make the corridor too wide, the cat is free to walk in at different distances each time which might make it harder for the algorithm, and the light conditions might change as well.
Another thing to notice is that the camera in the CAD model is pointing straight. In the real world my camera points slightly upwards, to not get too much of the floor in the image, since it had a tendency to cause reflections.
So, obviously you might want to tweak these measurements and stuff to match all your conditions better. The nice thing is that I made the CAD model in a free online program so you can create an account there and make a copy of my model and play with it:
Here is the share link: https://cad.onshape.com/documents/31bd4ce56cbbe15448c87c26/w/b037d8ad72230af672a81c71/e/e836d98c7dc420943ef91c7b
I made a bunch of variables that you can easily just change like this (once you have created a user, logged in, and made a copy of the project):
You can see the animated version in the tab at the bottom. You can just click and drag on the door and it will animate.
Hi Joakim,
ok, I got almost all points out of this: What is the importance that catcierge assume correctly that the cat is going out or not? In our case ( I do this for a good fiend ) it does not mather if the cat goes out. But anyway, we appreciate your valuable tips and will plan a new low level design of the box. Problem in our case is, that we don't have as much space. The 48 cm untill the wall comes is the maximum. But with the "L" design it will work. I'll take your idea and change it to our condition in relation to our angel of wall.
Thanks, Robby
What is the importance that catcierge assume correctly that the cat is going out or not?
Catcierge works like this:
It starts, it goes into the Waiting state.
It will continuously wait and look at the camera picture in this state. In the normal case it expects a completely white picture as the background. However, since we only really care about the white area in this picture, at startup the code will find that part and focus on it. So it will only care about something like this (the region of interest ROI): And to make it even easier for the algorithm it will perform what is called a binary threshold. That is, based on the grayscale values 0-255, pick a threshold (happens to be 90 in the code). Every value below that becomes black, and everything above becomes white. Now there are only black and white pixels in the image. Example of doing this in photoshop (showing multiple threshold examples by sliding):
As soon as something enters the camera frame, that white background is not completely white anymore. The first image it takes is called the "obstruction image". catcierge will count the number of black pixels in the image, and if it goes above a given threshold value (200 pixels in the current code). Here's an example of such an image and its thresholded equivalent: So as you see the image has a lot more than 200 pixels. This triggers the start of the matching algorithm.
The cat door now takes 4 images in succession as quick as it can.
Here's an overview of the state machine:
Ok so as described in the above scenario, as soon as ANYTHING enters the camera frame in #3 above that creates a shadow bigger than 200 pixel, the match algorithm will start.
If that object turns out to be the cat door opening from the inside, that will trigger a failed match and lock the door by default.
However, first of all, it would just lock the cat out for a couple of seconds, just as it is going out (not really an issue). And since the door is already open when that happens, the cat won't be stopped in any way, unless it immediately turns around and wants to go inside again.
The more annoying part with this, is that if you have some mail notification setup, you will get failure mails each time the cat goes outside.
So, as you don't care about the direction at all. One way to not get these false lockouts as the cat goes out. One could add support for some kind of "external trigger", for example an IR emitter that notice the cat about to exit.
If that IR emitter goes high on one of the Raspberry PI GPIO pins when that happens. That could be picked up by catcierge, so that it would for example ignore anything obstructing the frame for some given set of time.
Problem in our case is, that we don't have as much space. The 48 cm untill the wall comes is the maximum. But with the "L" design it will work. I'll take your idea and change it to our condition in relation to our angel of wall.
Here is a version where the door will obstruct the camera but if that does not matter (this is 48cm):
And the "L-part" of this version does not have to be that big, it can be a bit smaller, just not to let too much light in and slow down the cat. In my first version I built it as a removable extra thing afterwards, when I realised my cat simply ran so past by the camera.
But another option would of course be to have the corridor go "along" the wall of the house:
Now I cannot find a picture of that addon, but here is the "straight" version:
P.S. hope I don't overwhelm you with too much info 🤓
Hi Joakim,
Ok so as described in the above scenario, as soon as ANYTHING enters the camera frame in #3 above that creates a shadow bigger than 200 pixel, the match algorithm will start.
Ok understood.
If that object turns out to be the cat door opening from the inside, that will trigger a failed match and lock the door by default.
This scenario only would take affect when the cat is coming in "and" the door is opening from inside in the same moment, am I right?
By the way, the cat door we use (simple door with manual lock mechanism) contains a magnet which keeps the door closed as long the pressure of the air flow is not too heavy...
P.S. hope I don't overwhelm you with too much info :-) No, you don't. I like your detailed replies, and only because of that , I can understand all of it. Thank you very much!!!
So me and my friend have to decide how the direction of the floor has to be... I'll draw our decision with cad.onshape to show you, before I'll take the screwdriver... But before or in parallel that I'll finalize the elecronic steps like:
You story about the spider issue is really incredible and credible at the same time. What a coincidence...
BTW: What do you think about the idea to let turn on the backlight once a cat or other object is comming from outside via a movement sensor ? So it would help to increase the lifetime of the background light...
I thing it would be possible to turn it on within two seconds after the sensor got it ...
Robby
Hi Joakim,
actually we assumed that the cat door is always locked and catcierge is sending a unlock signal to the GPIO pin. No I realize that it is in opposite. Did you aver think about to do it in opposite? One advantage I see in that way you did it: The cat can come in also when you have a power loss in your village. One disadvantage I could imagine is that the cat can wait in front of the back light until the lockout time is expired. After that the cat could access the door.
What do you think about the idea to let turn on the backlight once a cat or other object is comming from outside via a movement sensor ? So it would help to increase the lifetime of the background light...
Robby
This scenario only would take affect when the cat is coming in "and" the door is opening from inside in the same moment, am I right?
That is one scenario, and that would be very rare I guess.
But each time there is a "match", either going in or out a notification will be sent (if you want that turned on). So with the current code if you build it so that the door is shown in the camera image, on each time the cat goes outside an email would be sent telling you there's a failing match. So it would make it hard to know if it's the cat coming in and bringing prey, or if it's just going out.
So my idea was then to add a "pre-trigger", on the inside... If that is triggered you can stop all these "false positive" emails (or other notification you want to setup) when the cat is just going out.
Currently I have no such support in the code. But if you want me to add that I could. It could be laser beam, IR movement sensor, or a magnet switch:
Was that more clear?
By the way, the cat door we use (simple door with manual lock mechanism) contains a magnet which keeps the door closed as long the pressure of the air flow is not too heavy...
Yea I made my own door from scratch, and I used magnets like this as well to keep a good seal to stop the wind blowing straight through.
BTW: What do you think about the idea to let turn on the backlight once a cat or other object is comming from outside via a movement sensor ? So it would help to increase the lifetime of the background light...
I thing it would be possible to turn it on within two seconds after the sensor got it ...
I think you're underestimating the speed a cat can have. At least from experience, the time it takes for a backlight to come on and become fully stable, the cat has time to move quite far... But it all depends on how far from the cat door you put this sensor, if it's in the "general area" outside the cat door or something.
But yea, I'm slightly sceptical about that solution, you would have to experiment. Also think of that fact that in the beginning the cat will be new to all this, and move through the cat door quite slowly. Once it gets used to it, it will probably just run straight through it as fast as it can if it's in a hurry (this is what happened with my cat). So you might experiment and get the perfect timing at the initial install, but then that stops working after a while when the cat gets used to things.
(This is the exact same reason why I had to remake my box to be L-shaped... At first it worked fine with it being just a straight corridor, but when she got used to it she started speeding up).
So it would help to increase the lifetime of the background light...
Assume that everything in this cat door will break eventually, and make it easy to replace it is a good pointer. For example being sure you can access the solenoid easily, the backlight, and every part. Otherwise you will be swearing when that happens :)
For this reason, I have the entire outer part on wheels. It's quite heavy, but I can roll it out of the way, to get access to the door that is used to lock out the cat if it has a prey. I had to do this the other night to replace the broken solenoid.
actually we assumed that the cat door is always locked and catcierge is sending a unlock signal to the GPIO pin. No I realize that it is in opposite. Did you aver think about to do it in opposite? One advantage I see in that way you did it: The cat can come in also when you have a power loss in your village.
Yea I thought about both designs. And I wanted this to be as safe as possible for the cat. Since we live in a place where it goes down to -30C sometimes. And the cat is free to go in and out at any time of day, I never wanted here to get stuck outside for any reason, in a power outage situation or if something else breaks. This might not be as crucial in your climate.
However, there is nothing that stops you in how the code works from doing it like this. In the default setup I trigger a GPIO pin (you can customize which). Then it is up to you if that circuit that is triggered, it locks the door or does nothing.
It is even possible to specify a command line program that should run on Lockout or Unlock. That can use whatever method you want, it does not even have to use the GPIO pins.
One disadvantage I could imagine is that the cat can wait in front of the back light until the lockout time is expired. After that the cat could access the door.
Yes this happened for me. And I have a bunch of settings that compenasates for this.
Lockout settings:
These settings control how the cat door will be locked.
--lockout_method LOCKOUT_METHOD Defines the method used to decide
when to unlock:
[1: Only use the timer, don't care
about clear frame.]
2: Wait for clear frame or that
the timer has timed out.
3: Wait for clear frame and then
start unlock timer.
--lockout LOCKOUT The time in seconds a lockout
takes. Default 30 seconds.
--lockout_error LOCKOUT_ERROR Number of lockouts in a row that's
allowed before we consider it an
error and quit the program.
Default is to never do this.
--lockout_error_delay LOCKOUT_ERROR_DELAY
The delay in seconds between
lockouts that should be counted as
a consecutive lockout. Default
3.0.
--lockout_dummy Do everything as normal, but don't
actually lock the door. This is
useful for testing.
NOTE: The images below were flipped since I took them upside down with my phone, but I'm too lazy to reverse them, if you are confused with the point of view
So I took some images of my newest verison of the cat door (The one in the earlier pics is the old one).
This is how it looks now (and yes we still have snow here):
As you can see above I have a latch and hinges on the side. So I easily open and have access to things.
I also made a similar door on the back of it to be able to access the backlight easily. I definantly recommend having this in mind when building it, for easy maintenance.
Here is the picture of the L-shape from above:
Here you see how the camera is positioned as in my onshape CAD model. And that I have a roof made out of acrylic.
Another angle:
This is looking from the point of view of the backlight towards the camera:
You may notice I have quite a lot of power connectors and stuff on the camera side. This could be made a lot less stuff if you shared 1 power supply with every component. However I wanted to keep things as simple as possible without any custom circuits, so that if something breaks I can easily replace it with an off the shelf part. But you seem more electronics knowledgable than me so you can probably solves this neater with one power supply for Raspberry pi + solenoid + heater element (if you decide to use that).
Here's a closer view of my camera (and raspberry pi in the same enclosure):
I have it slightly off the ground, and it can be pivoted using some adjustment screws.
The thing at the top with the digital numbers is a temperature controller that has a 12V power supply connected to it + a power resistor. This is used to heat the enclosure in the winter (since the camera fails in subzero temperatures) I bought it here cheaply (available on ebay and many other online stores as well): http://www.dx.com/p/hf-1-8-lcd-digital-thermostat-temperature-controller-gray-orange-black-12v-318731#.WQ8h6uWGNbU
Again this could be done neater, and controlled directly by the Raspberry Pi with some custom electronics. But keeping it simple was my idea, it's very easy to replace this if it would break.
Power resistor:
My specific power resistor:
Again this is what happens with the image if the Raspberry Pi camera goes below 0C:
Another image from above:
The entrance:
How it looks when I open the side door:
My ethernet switch. You don't need this, but since I have multiple cameras I need it. Again this has it's own power supply as well, hence so many cables :)
My second camera is placed above the door:
This camera will film what is happening and is triggered by ther first camera over the network. It continously records into a circular buffer. So after the cat door detects something happens it saves 2 minutes before that (it's supposed to be 30 seconds, but there is some bug in my code that makes it 2 minutes, just haven't fixed it). Those videos are automaticlaly uploaded to youtube: https://www.youtube.com/channel/UCjwg_Vloefz2I2ndbQyPIwQ
However I haven't had it running for quite some time, so these videos are old now. Here's a playlist of some interesting ones: https://www.youtube.com/playlist?list=PLFDLU9nH9c7iskUdGiDzXE71NzECgkCRg
Here's one of the videos at the time as the cat is coming in with prey in her mouth: https://youtu.be/uTJYxBa4xEs?t=1m51s
This one being a BAD example, since I had screwed up my settings. And she simply waited until the door unlocked (exact scenario you described above :D Sometimes she will back off outside of the camera picture, wait a while (she listens to the solenoid unlocking) and tries again... Sometimes she has done this 6 times in a row, each time getting locked out).
This is a better example of how she behave most of hte time: https://youtu.be/crGEXvwLjNw?t=6s
And there are other interesting behaviors on there... For example if it's raining she will just sit and watch in the opening for a while, and then "back" into the door. Since the camera will only see her ass in that case, it will lock her out.... So yea it is not perfect, but 90% of the cases it will stop her bringing in prey properly :)
This camera I made with a transparent thingie, so here you can even see the power resistor:
The cat door from the inside, here you see the location of the solenoid:
Here you see how I can move the outer part of the cat door to get access to replacing the solenoid. Here is a better view of my power outlets + ethernet connection:
I'd highly recommend using an ethernet connection rather than wifi. If you use wifi make sure you get a really good antenna and make sure you get a stable connection. I've had really bad experience with that for Raspberry Pi.
...
Another good thing to note. Make the floor out of a "non-soaking" material. In my first version I made it out of bare wood... When the cat was locked out, it would simply drop the dead prey on the floor at times, leaving them there sometimes for weeks, with resulting blood stains.
In this new version I used melanine for the floor, which is a lot easier to clean and won't soak up the gory parts. But now she has stopped dropping prey on the floor. Instead she usually just goes outside again and eats the prey there.
phew ok I think that was it for now :)
I actually have filmed myself building that entire cat door, so I intend to edit all that footage down and upload it to youtube.
Here my second plan. In regard to your valuable tips I made it now in a L form. There is also a distance from the view field of the camera to the swinging door. One background to our plan (see attachment): The cat door inside the house is already there. It's a door with a RFID lock. It works wonderful without problems for several years now. My friend had that idea to fix the solenoid lock at this existing door. I doubt and told him, the door is too far away from the camera sight field, so the cat could paste with to high speed the sight field. Ok then he gave me a simple cat door which I can use inside the box and fix the solenoid to that door. An other idea of mine was to take the simple door just only to lower the speed of the cat and the solenoid I can assemble on thje RFID door inside the house. But now I have doubt, that the cat can wait in the front of the locked door until the lockout timeout expired...(as I wrote already above). Robby
Hi Joakim,
>> Currently I have no such support in the code. But if you want me to add that I could. It could be laser beam, IR movement sensor, or a magnet switch No Thanks I solve it by a bigger distance...
Was that more clear? Yes I got it.
>> This is the exact same reason why I had to remake my box to be L-shaped... Ohh yea, I believe ...
>> being sure you can access the solenoid easily, the back light, and every part. Otherwise you will be swearing when that happens Yes I do, I plan to open the whole box from top, so that I can access all the parts...
Can you sent me a tip about the solenoid? Which type, vendor, where did you get it? I'm also a bit lacy to build it byselfe when it is suitable and available on the marked for some money...
Thank you, Robby
Ok that design looks good. And you can make everything easy to access from above as well.
My friend had that idea to fix the solenoid lock at this existing door. I doubt and told him, the door is too far away from the camera sight field, so the cat could paste with to high speed the sight field. Ok then he gave me a simple cat door which I can use inside the box and fix the solenoid to that door.
An other idea of mine was to take the simple door just only to lower the speed of the cat and the solenoid I can assemble on thje RFID door inside the house. But now I have doubt, that the cat can wait in the front of the locked door until the lockout timeout expired...(as I wrote already above).
Yea, I think it's better to have the solenoid on that extra door he gave you, which is just in front of the camera according to your plan.
The lockout code/settings assumes that the cat is in view of the camera when waiting for the door to open. So that it can continue keep it locked even longer. If you put it at the RFID door it would be able to just wait it out, and there would be no way for catcierge to detect that.
Can you sent me a tip about the solenoid? Which type, vendor, where did you get it? I'm also a bit lacy to build it byselfe when it is suitable and available on the marked for some money...
Unfortunately the place I bought my exact version of does not have that one. It was a Swedish store. It happened that I had 2 of the exact same type, so when it broke I had a replacement.
So I cannot give you a link to the exact one I am using.
Solenoid in german seems to be called "Hubmagnet":
So maybe something like this one: https://www.conrad.de/de/hubmagnet-drueckend-01-n-25-n-24-vdc-2-w-hmf-1614d002-24vdc100-503744.html
This looks similar to mine, but note that that shaft is made out of brass, and not very thick. So this is the reason my cat was able to break it off when it got cold once. What you need to do is get the measurements correct, this one says 39mm, which is around the length of mine. It depends on how your door is, and how close you can place it.
The closer the better, so the cat cannot get too much mechanical leverage to break it :)
I'm sure one could buy a much more expensive one that is sturdier and will never break. Or make some smarter locking solution :)
Hi Joakim, I had a meeting with Tim. He and me prefers a solution to keep the door closed all the time and open it only in a good match case. You already gave me an answer regarding this but I fear you just point me to the fact just to negate PIN4 state zero or 3,3V ... You wrote:
However, there is nothing that stops you in how the code works from doing it like this. In the default setup I trigger a GPIO pin (you can customize which). Then it is up to you if that circuit that is triggered, it locks the door or does nothing. This I dont understand. Of course I can negate the circuit so that it pulls the magnet instead of pushing it, but this does not help.
Just emagine: Door is always closed by a pull magnet which closes the door always with 0 voltage. If the cat comes in to the sightfield giving a good match (no pray detected): Your code would do nothing: "keep door open" PIN4: 0v. So the pull magnet would still lock the door. So I can't just negate all the values on PIN4 to solve this. Or did I misunderstand your answer ? Isn't there any configurable option in you code to do it with a pull magnet?
Thanks, Robby
Hello,
Ok I will need to discuss this in some more detail:
To speak actual code. When a succesful match has been performed I will always perfrom an unlock: https://github.com/JoakimSoderberg/catcierge/blob/master/src/catcierge_fsm.c#L1119
In the code, an unlock is always setting the GPIO pin to LOW (0v) with the default settings on the raspberry pi. https://github.com/JoakimSoderberg/catcierge/blob/master/src/catcierge_fsm.c#L275
Of course it would be simple to reverse this behavior by simply adding a flag, that unlock always means setting the GPIO pin to HIGH (3.3v). And the other way around for locking.
However, since I have focused only on the lockout part. I have no timer or anything that decides how long to keep the door open. So either I need to add that code, or you add some kind of delay in your circuit that triggers the lock.
However......
When I wrote this, I made it multiplatform (Windows, OSX, Linux), and to make it possible to use on those platforms as well I added support for customizing exactly what happens on an unlock or lock event. This is done by running 2 external scripts.
--do_lockout_cmd CMD [CMD ...] Command to run when the do_lockout event is triggered. Triggered right before a lockout
is performed.
--do_unlock_cmd CMD [CMD ...] Command to run when the do_unlock event is triggered. Triggered right before a unlock
is performed.
So here you can pass 1 or more commands that will be run each time something happens. Tihs could be a simple script for example, that in your case opens the lock, waits a number of seconds to let the cat pass through, and then locks it again.
In that case, preferably you would use the same GPIO pin that catcierge normally would use (Pin 4) with the default behavior. Since that is properly setup at boot for writing to (otherwise the script would have to run as root, which is unadvisable).
so for example, if you create a small Python script (I have not run this, but it should work):
unlock.py: (And do chmod +x unlock.py
on it)
#!/usr/bin/env python
import RPi.GPIO as GPIO
import time
GPIO.output(4, True) # Assuming setting PIN high means opening the lock
time.sleep(10) # Keep door open for 10 seconds
GPI.output(4, False) # And lock.
(A small tutorial on scripting with python on rpi: http://www.thirdeyevis.com/pi-page-2.php)
Then you'd pass this on the command line:
bin/catcierge_grabber --do_unlock_cmd "/path/to/unlock.py"
or define it in your /etc/catcierge.cfg
for real use...
Where /path/to
is the path where the file is located of course.
And then you'd write the reverse script for the other case. All that needs to do is make sure the door is locked:
lock.py:
#!/usr/bin/env python
GPI.output(4, False)
Hi Joakim,
that sounds great! I understand now ;-)
Thank you very much... I guess the screwdriver is coming closer now... ;-)
Will keep you up2date...
Robby
Am 09.05.2017 um 01:28 schrieb Joakim Söderberg:
Hello,
Ok I will need to discuss this in some more detail:
To speak actual code. When a succesful match has been performed I will always perfrom an unlock: https://github.com/JoakimSoderberg/catcierge/blob/master/src/catcierge_fsm.c#L1119
In the code, an unlock is always setting the GPIO pin to LOW (0v) with the default settings on the raspberry pi. https://github.com/JoakimSoderberg/catcierge/blob/master/src/catcierge_fsm.c#L275
Of course it would be simple to reverse this behavior by simply adding a flag, that unlock always means setting the GPIO pin to HIGH (3.3v). And the other way around for locking.
However, since I have focused only on the lockout part. I have no timer or anything that decides how long to keep the door open. So either I need to add that code, or you add some kind of delay in your circuit that triggers the lock.
However......
When I wrote this, I made it multiplatform (Windows, OSX, Linux), and to make it possible to use on those platforms as well I added support for customizing exactly what happens on an unlock or lock event. This is done by running 2 external scripts.
--do_lockout_cmd CMD [CMD ...] Command to run when the do_lockout event is triggered. Triggered right before a lockout is performed. --do_unlock_cmd CMD [CMD ...] Command to run when the do_unlock event is triggered. Triggered right before a unlock is performed.
So here you can pass 1 or more commands that will be run each time something happens. Tihs could be a simple script for example, that in your case opens the lock, waits a number of seconds to let the cat pass through, and then locks it again.
In that case, preferably you would use the same GPIO pin that catcierge normally would use (Pin 4) with the default behavior. Since that is properly setup at boot for writing to (otherwise the script would have to run as root, which is unadvisable).
so for example, if you create a small Python script (I have not run this, but it should work):
unlock.py: (And do |chmod +x unlock.py| on it)
!/usr/bin/env python
import RPi.GPIO as GPIO import time GPIO.output(4, True) # Assuming setting PIN high means opening the lock time.sleep(10) # Keep door open for 10 seconds GPI.output(4, False) # And lock.
(A small tutorial on scripting with python on rpi: http://www.thirdeyevis.com/pi-page-2.php)
Then you'd pass this on the command line:
|bin/catcierge_grabber --do_unlock_cmd "/path/to/unlock.py" |
or define it in your |/etc/catcierge.cfg| for real use...
Where |/path/to| is the path where the file is located of course.
And then you'd write the reverse script for the other case. All that needs to do is make sure the door is locked:
lock.py:
!/usr/bin/env python
GPI.output(4, False)
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/JoakimSoderberg/catcierge/issues/20#issuecomment-300018955, or mute the thread https://github.com/notifications/unsubscribe-auth/Aa6iQKpgT0i18V9y59_Zv3M74CUsFa0qks5r36UigaJpZM4NM-Sd.
Hi Joakim,
the external commandoption is really a usefull thing. I did it in the same way, I created these two scripts and I start it with the two arguments as you described above. But in the code something calls the do_unlock in moments I don't want it.
See here: In case It keeped locked, because it recognized prey:
[2017-05-10 22:20:14.145701] [Waiting] -> [Matching]
[2017-05-10 22:20:14.201838] No Match in - Prey detected (800f43c08a076d68c6b823501d10d8a121b6854a)
[2017-05-10 22:20:14.256785] No Match in - Prey detected (e1b2a979fddb6dca243d398226cb4761fd0baa74)
[2017-05-10 22:20:14.311142] No Match in - Prey detected (6df023f8ffea5fb450f597d0c03c883dda0733a8)
[2017-05-10 22:20:14.364784] No Match in - Prey detected (e29e1b46a04f484e5c2b3d08135522b056278b6d)
[2017-05-10 22:20:14.365518] Lockout! 4 out of 4 matches failed (for 4 seconds).
[2017-05-10 22:20:14.365592] Waiting for lockout timer only (Lockout method 1)
[2017-05-10 22:20:14.365627] [Matching] -> [Lockout]
[2017-05-10 22:20:14.368865] Called program "/home/robby/Katzenklappe/tools/lock.py"
[2017-05-10 22:20:24.895150] End of lockout! (timed out after 10.53 seconds)
[2017-05-10 22:20:24.897874] Called program "/home/robby/Katzenklappe/tools/unlock.py"
[2017-05-10 22:20:24.898018] [Lockout] -> [Waiting]
Then as in the unlock script stated it will keep open for 10 seconds, but the cat has prey in the mouth.
Second example I found: When no cat head was recognized the same behaviour:
[2017-05-10 22:21:20.307382] [Waiting] -> [Matching]`
[2017-05-10 22:21:20.366714] Match in - No cat head detected (8a4682f7dd614eee333a9f5ca2ea4c8fe6386a78)
[2017-05-10 22:21:20.414428] Match in - No cat head detected (67bd41f2d092df390180de9465992d14873c265)
[2017-05-10 22:21:20.461998] Match in - No cat head detected (6c3b318d60b0608842e431bc91dd6c7520524ec3)
[2017-05-10 22:21:20.511012] Match in - No cat head detected (727be12095f8a1ad75e877abb38ebfca7053ed3f)
[2017-05-10 22:21:20.511656] !!! Match group vetoed match success: No head found in any image !!!
[2017-05-10 22:21:20.511833] Lockout! 0 out of 4 matches failed (for 4 seconds).
[2017-05-10 22:21:20.511881] Waiting for lockout timer only (Lockout method 1)
[2017-05-10 22:21:20.511925] [Matching] -> [Lockout]
[2017-05-10 22:21:20.514497] Called program "/home/robby/Katzenklappe/tools/lock.py"
[2017-05-10 22:21:30.027556] End of lockout! (timed out after 3.52 seconds)
[2017-05-10 22:21:30.030099] Called program "/home/robby/Katzenklappe/tools/unlock.py"
[2017-05-10 22:21:30.030248] [Lockout] -> [Waiting]
To make the code fitting for both ways (either basis is always unlocked or basis is always locked...) you should use internal commands like "revert_lockout" instead of "unlock" after a lockout timer. I could also search and change it in the code, but think you are also interested to bring your project further to make it usefull for other people like me and you :-) So I guess you will do that? Or did I overlook an command option to change this behaviour? I checked the sense of lockout_method but this has nothing to do with this.
Thanks, Robby
Hello,
So I think you are missunderstanding how this works.
The first scenario is quite clear, the cats head was found in the image, it looks like it has a prey in its mouth:
[2017-05-10 22:20:14.365518] Lockout! 4 out of 4 matches failed (for 4 seconds).
We should lock out the cat.
This is NOT the normal case as you seem to think. This means something triggered the camera, but no cat head was found in any image.
...
[2017-05-10 22:21:20.511012] Match in - No cat head detected (727be12095f8a1ad75e877abb38ebfca7053ed3f)
[2017-05-10 22:21:20.511656] !!! Match group vetoed match success: No head found in any image !!!
[2017-05-10 22:21:20.511833] Lockout! 0 out of 4 matches failed (for 4 seconds).
This probably means one of the following:
Either case, this is considered a case where the door SHOULD be locked!
For example, in these images the algorithm would not detect the cats head:
In some cases that image is preceeded by a good image (the cat might be moving fast), this is why I use 4 images, and require 2 of those to be ok by default:
What you want is the third case, when the cats head is found in the image, but no prey is found in any of them.
This means we should unlock the door and let the cat in. The Normal case!
...
There are settings available for tweaking this (which you probably should not touch):
--ok_matches_needed OK_MATCHES_NEEDED The number of matches out of 4 matches that need to be OK for the match to be
considered an over all OK match.
--no_final_decision Normally after all matches in a match group has been made the matcher algorithm gets to
do a final decision based on the entire group of matches which overrides the
"--ok_matches_needed"setting. This flag turns this behavior off.
Btw if you're using catcierge_grabber
simply to test your settings, that is quite tedious. I'd rather recommend you use the testprogram catcierge_fsm_tester
.
$ bin/catcierge_fsm_tester --help
...
Finite State Machine Tester Settings:
Use these settings to pass a set of images you want to test as if they were detected by catcierge, including all events that would
be triggered by the state machine.
--images IMAGES IMAGES IMAGES IMAGES Input images that are passed to catcierge.
--delay DELAY Initial delay before passing the images to catcierge.
--keep_running Keeps the catcierge state matchine running also after matching. This can be useful to
test things such as lockout times and so on. If this is not used, immediately after
the match is complete and all events have run, the program will terminate.
--keep_obstructing When --keep_running is turned on, don't clear the frame as usual. This is meant to
enable simulating that the cat stays in front of the cat door, trying to get it
open.To clear the frame do Ctrl+C (and to terminate do it again).
--base_time BASE_TIME The base date time we should use instead of the current time. Only meant to be used
when testing the code to have a repeatable time for replaying events.
Here you can get a very consistent test setup, where you pass it 4 images, that are always identical. And you can see the difference depending on your settings.
Either you create these images yourself. Or you use the images that comes with the project.
Using the system config from /etc/catcierge.cfg
.
(Here I use a wildcard to get 4 images, since the images in this folder were made for testing like this):
$ bin/catcierge_fsm_tester --images ../examples/real/series/0004_0*.png
But of course you can specify the path to each image as well.
Here I'm not using any config. So I specify each setting on the command line:
$ bin/catcierge_fsm_tester --no_default_config --haar --cascade ../extra/catcierge.xml --images ../examples/real/series/0004_0*.png
[2017-05-11 00:54:43.213524] Reading Raspberry Pi camera config: /etc/catcierge/catcierge-rpi.cfg
[2017-05-11 00:54:43.214307] Found arguments: -hflip -vflip
[2017-05-11 00:54:43.214631] Using default config
[2017-05-11 00:54:43.214722] Default config turned off, ignoring: /etc/catcierge/catcierge.cfg
Images:
../examples/real/series/0004_01.png
../examples/real/series/0004_02.png
../examples/real/series/0004_03.png
../examples/real/series/0004_04.png
[2017-05-11 00:54:43.236259] [Initial] -> [Waiting]
[2017-05-11 00:54:43.248150] Startup delay of 0.00 seconds has ended!
[2017-05-11 00:54:43.248841] Something in frame! Start matching...
[2017-05-11 00:54:43.268193]
[2017-05-11 00:54:43.268297] === Match group id: db8fb2801f927bb566a9d0d8c896e089b79f312e ===
[2017-05-11 00:54:43.268364]
[2017-05-11 00:54:43.268426] [Waiting] -> [Matching]
[2017-05-11 00:54:43.325879] Match in - No prey detected (6411dd39d4a6b1ce337719bcee972dd9d1c7ed0)
[2017-05-11 00:54:43.385667] Match in - No prey detected (24265707c538fd835d1123d3f8412fdbda8acf8c)
[2017-05-11 00:54:43.433463] Match in - No cat head detected (6a6ef60a17d2c054f95378fd0619800df900067)
[2017-05-11 00:54:43.472423] Match in - No cat head detected (b548eb8c29576f393cdf373012b83c2418f25fe)
[2017-05-11 00:54:43.472800] Everything OK! (4 out of 4 matches succeeded) Door kept open...
[2017-05-11 00:54:43.473226] [Matching] -> [Keep open]
[2017-05-11 00:54:43.473348] Saving image ./match__2017-05-11_00_54_43.306643__1.png
[2017-05-11 00:54:43.484292] Saving image ./match__2017-05-11_00_54_43.366435__2.png
[2017-05-11 00:54:43.494369] Saving image ./match__2017-05-11_00_54_43.413452__3.png
[2017-05-11 00:54:43.504146] Saving image ./match__2017-05-11_00_54_43.453264__4.png
These images can be used to test the settings: https://github.com/JoakimSoderberg/catcierge-examples/tree/63fbcc49ba2069cc1a3188e64ee393cb510d7de5/real/series
Note catcierge_fsm_tester
otherwise works just like catcierge_grabber
. It runs the same code. Except it has the extra settings --images
and such as mentioned above meant for testing, instead of directly using the camera.
Hi Joakim,
thank for your quick reply. No no , so far I understood how it works. But I gues you don't understand the problem I try to describe.
Just emagine. (lockout_time=30) (do_unlock_cmd = phyton script do_unlock_cmd=unlock.py will unlock for 10 seconds) ( see your tips above )
My cat door is always locked by default by a pull magnet (Pin 4 = 0v) Then cat comes with prey >> code: do_lockout for 30 seconds (lockout time) == call do_lockout_cmd=lock.py (pull magnet still has no power, nothing happens, door keeps closed) all is fine...
But, after 30 seconds the code calls the do_unlock_cmd=unlock.py, allthough the cat has prey, my door is now open for 10 seconds.
Also when the cat comes out of the sight field of the cam, the magnet will open after that 30 seconds lockout_time for 10 seconds (stated in the .py script).
Also when "No cat head" were found, the code first calls "do_lockout_cmd" which is absolutely ok, but after 30 seconds the "do_unlock_cmd" is called by the code and will open the door...
I'll create a video tomorrow or Friday, its hard to describe.
Good night...
Robby
Am 11.05.2017 um 01:01 schrieb Joakim Söderberg:
Hello,
So I think you are missunderstanding how this works.
Prey
The first scenario is quite clear, the cats head was found in the image, it looks like it has a prey in its mouth:
|[2017-05-10 22:20:14.365518] Lockout! 4 out of 4 matches failed (for 4 seconds). |
We should lock out the cat.
No cat head
This is NOT the normal case as you seem to think. This means something triggered the camera, but no cat head was found in any image.
|... [2017-05-10 22:21:20.511012] Match in - No cat head detected (727be12095f8a1ad75e877abb38ebfca7053ed3f) [2017-05-10 22:21:20.511656] !!! Match group vetoed match success: No head found in any image !!! [2017-05-10 22:21:20.511833] Lockout! 0 out of 4 matches failed (for 4 seconds). |
This probably means one of the following:
- What is in the image is not a cat (maybe it's a squirrel, a racoon or whatever)
- The cat is in the image, but the algorithm fails to understand that. Maybe because the cat is holding a bird int its mouth in some weird way
Either case, this is considered a case where the door SHOULD be locked!
For example, in these images the algorithm would not detect the cats head: 0004_03 https://cloud.githubusercontent.com/assets/1446626/25924795/2493f666-35e5-11e7-8b7d-94f4c01368f7.png 0004_04 https://cloud.githubusercontent.com/assets/1446626/25924802/278e0cee-35e5-11e7-8cdb-2c6c832aef43.png
In some cases that image is preceeded by a good image (the cat might be moving fast), this is why I use 4 images, and require 2 of those to be ok by default: 0004_02 https://cloud.githubusercontent.com/assets/1446626/25924818/3bd88666-35e5-11e7-8b29-912668791deb.png
Normal case
What you want is the third case, when the cats head is found in the image, but no prey is found in any of them.
This means we should unlock the door and let the cat in. The Normal case!
...
There are settings available for tweaking this (which you probably should not touch):
|--ok_matches_needed OK_MATCHES_NEEDED The number of matches out of 4 matches that need to be OK for the match to be considered an over all OK match. --no_final_decision Normally after all matches in a match group has been made the matcher algorithm gets to do a final decision based on the entire group of matches which overrides the "--ok_matches_needed"setting. This flag turns this behavior off. |
Testing
Btw if you're using |catcierge_grabber| simply to test your settings, that is quite tedious. I'd rather recommend you use the testprogram |catcierge_fsm_tester|.
$ bin/catcierge_fsm_tester --help ... Finite State Machine Tester Settings: Use these settings to pass a set of images you want to test as if they were detected by catcierge, including all events that would be triggered by the state machine.
--images IMAGES IMAGES IMAGES IMAGES Input images that are passed to catcierge. --delay DELAY Initial delay before passing the images to catcierge. --keep_running Keeps the catcierge state matchine running also after matching. This can be useful to test things such as lockout times and so on. If this is not used, immediately after the match is complete and all events have run, the program will terminate. --keep_obstructing When --keep_running is turned on, don't clear the frame as usual. This is meant to
enable simulating that the cat stays in front of the cat door, trying to get it open.To clear the frame do Ctrl+C (and to terminate do it again). --base_time BASE_TIME The base date time we should use instead of the current time. Only meant to be used when testing the code to have a repeatable time for replaying events.
Here you can get a very consistent test setup, where you pass it 4 images, that are always identical. And you can see the difference depending on your settings.
Either you create these images yourself. Or you use the images that comes with the project.
Using the system config from |/etc/catcierge.cfg|. (Here I use a wildcard to get 4 images, since the images in this folder were made for testing like this):
|$ bin/catcierge_fsm_tester --images ../examples/real/series/0004_0*.png |
But of course you can specify the path to each image as well.
Here I'm not using any config. So I specify each setting on the command line:
$ bin/catcierge_fsm_tester --no_default_config --haar --cascade ../extra/catcierge.xml --images ../examples/real/series/0004_0*.png [2017-05-11 00:54:43.213524] Reading Raspberry Pi camera config: /etc/catcierge/catcierge-rpi.cfg [2017-05-11 00:54:43.214307] Found arguments: -hflip -vflip [2017-05-11 00:54:43.214631] Using default config [2017-05-11 00:54:43.214722] Default config turned off, ignoring: /etc/catcierge/catcierge.cfg Images: ../examples/real/series/0004_01.png ../examples/real/series/0004_02.png ../examples/real/series/0004_03.png ../examples/real/series/0004_04.png [2017-05-11 00:54:43.236259] [Initial] -> [Waiting] [2017-05-11 00:54:43.248150] Startup delay of 0.00 seconds has ended! [2017-05-11 00:54:43.248841] Something in frame! Start matching... [2017-05-11 00:54:43.268193] [2017-05-11 00:54:43.268297] === Match group id: db8fb2801f927bb566a9d0d8c896e089b79f312e === [2017-05-11 00:54:43.268364] [2017-05-11 00:54:43.268426] [Waiting] -> [Matching] [2017-05-11 00:54:43.325879] Match in - No prey detected (6411dd39d4a6b1ce337719bcee972dd9d1c7ed0) [2017-05-11 00:54:43.385667] Match in - No prey detected (24265707c538fd835d1123d3f8412fdbda8acf8c) [2017-05-11 00:54:43.433463] Match in - No cat head detected (6a6ef60a17d2c054f95378fd0619800df900067) [2017-05-11 00:54:43.472423] Match in - No cat head detected (b548eb8c29576f393cdf373012b83c2418f25fe) [2017-05-11 00:54:43.472800] Everything OK! (4 out of 4 matches succeeded) Door kept open... [2017-05-11 00:54:43.473226] [Matching] -> [Keep open] [2017-05-11 00:54:43.473348] Saving image ./match2017-05-11_00_54_43.3066431.png [2017-05-11 00:54:43.484292] Saving image ./match2017-05-11_00_54_43.3664352.png [2017-05-11 00:54:43.494369] Saving image ./match2017-05-11_00_54_43.4134523.png [2017-05-11 00:54:43.504146] Saving image ./match2017-05-11_00_54_43.4532644.png
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/JoakimSoderberg/catcierge/issues/20#issuecomment-300636503, or mute the thread https://github.com/notifications/unsubscribe-auth/Aa6iQCP08ADOPh0DZLLdkACkgw---Kc4ks5r4kHYgaJpZM4NM-Sd.
Hi Joakim,
here an other try to explain a problem with the unlock which is too much. Thanks Robby
Hello Robert,
Thanks for the video, now it is totally clear to me what you mean :)
Now I kind of swear to myself that I designed this so centered on the fact that I lock when the cat has prey and keep it open otherwise. Should've predicted most people might want to do the opposite, and made it a bit more elegant to simply flip.
Oh well, maybe I'll change that if I get the full inspiration to redesign...
However a much simpler solution that I did was to simply add a new flag --no_unlock_after_lockout
. This way, it will still trigger the lockout timer and so on. But at the end when it normally unlocks for me. This flag will simply make it skip that step. So that should give you the desired action.
https://github.com/JoakimSoderberg/catcierge/commit/f15cc834a7f754a3ced86a565e30c052364be149
Oh yea to get the change:
git pull --rebase origin master
If you have changed one of the files, the above will complain, so then you can do:
git stash
git pull --rebase origin master
git stash pop
Hi Joakim,
Thank you very much !!! I'll try and let you know .
Robby
Von meinem iPhone gesendet
Am 12.05.2017 um 21:48 schrieb Joakim Söderberg notifications@github.com:
Oh yea to get the change:
git pull --rebase origin master If you have changed one of the files, the above will complain, so then you can do:
git stash git pull --rebase origin master git stash pop — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
Hi Joakim, I compiled and tested without prey seems perfect, but with prey the code will run in a loop now. Just see here: https://goo.gl/photos/sKQnyJbsitAqaLwR7 The loop will not end, neither you can stop it with a new event in the camera. It seems it loops forever then... Hare a snip of the output within the loop:
[2017-05-13 12:00:21.342874] Not performing unlock since --no_unlock_after_lockout is enabled[2017-05-13 12:00:21.378741] End of lockout! (timed out after 17.12 seconds)
[2017-05-13 12:00:21.378866] Not performing unlock since --no_unlock_after_lockout is enabled[2017-05-13 12:00:21.410643] End of lockout! (timed out after 17.15 seconds)
[2017-05-13 12:00:21.410755] Not performing unlock since --no_unlock_after_lockout is enabled[2017-05-13 12:00:21.443600] End of lockout! (timed out after 17.19 seconds)
[2017-05-13 12:00:21.443756] Not performing unlock since --no_unlock_after_lockout is enabled[2017-05-13 12:00:21.479058] End of lockout! (timed out after 17.22 seconds)
[2017-05-13 12:00:21.479215] Not performing unlock since --no_unlock_after_lockout is enabled[2017-05-13 12:00:21.510707] End of lockout! (timed out after 17.25 seconds)
[2017-05-13 12:00:21.547176] End of lockout! (timed out after 17.29 seconds)
[2017-05-13 12:00:21.547332] Not performing unlock since --no_unlock_after_lockout is enabled[2017-05-13 12:00:21.578576] End of lockout! (timed out after 17.32 seconds)
[2017-05-13 12:00:21.578672] Not performing unlock since --no_unlock_after_lockout is enabled[2017-05-13 12:00:21.610762] End of lockout! (timed out after 17.35 seconds)
[2017-05-13 12:00:21.610870] Not performing unlock since --no_unlock_after_lockout is enabled[2017-05-13 12:00:21.647076] End of lockout! (timed out after 17.39 seconds)
[2017-05-13 12:00:21.647220] Not performing unlock since --no_unlock_after_lockout is enabled[2017-05-13 12:00:21.678606] End of lockout! (timed out after 17.42 seconds)
[2017-05-13 12:00:21.678706] Not performing unlock since --no_unlock_after_lockout is enabled[2017-05-13 12:00:21.714548] End of lockout! (timed out after 17.46 seconds)
[2017-05-13 12:00:21.714663] Not performing unlock since --no_unlock_after_lockout is enabled[2017-05-13 12:00:21.747041] End of lockout! (timed out after 17.49 seconds)
[2017-05-13 12:00:21.747155] Not performing unlock since --no_unlock_after_lockout is enabled[2017-05-13 12:00:21.778682] End of lockout! (timed out after 17.52 seconds)
[2017-05-13 12:00:21.778774] Not performing unlock since --no_unlock_after_lockout is enabled[2017-05-13 12:00:21.815494] End of lockout! (timed out after 17.56 seconds)
[2017-05-13 12:00:21.815650] Not performing unlock since --no_unlock_after_lockout is enabled[2017-05-13 12:00:21.847166] End of lockout! (timed out after 17.59 seconds)
[2017-05-13 12:00:21.847353] Not performing unlock since --no_unlock_after_lockout is enabled[2017-05-13 12:00:21.882566] End of lockout! (timed out after 17.63 seconds)
[2017-05-13 12:00:21.882674] Not performing unlock since --no_unlock_after_lockout is enabled[2017-05-13 12:00:21.915044] End of lockout! (timed out after 17.66 seconds)
[2017-05-13 12:00:21.915190] Not performing unlock since --no_unlock_after_lockout is enabled[2017-05-13 12:00:21.946764] End of lockout! (timed out after 17.69 seconds)
[2017-05-13 12:00:21.946876] Not performing unlock since --no_unlock_after_lockout is enabled[2017-05-13 12:00:21.982672] End of lockout! (timed out after 17.73 seconds)
[2017-05-13 12:00:21.982782] Not performing unlock since --no_unlock_after_lockout is enabled[2017-05-13 12:00:22.015099] End of lockout! (timed out after 17.76 seconds)
[2017-05-13 12:00:22.050580] End of lockout! (timed out after 17.79 seconds)
[2017-05-13 12:00:22.050685] Not performing unlock since --no_unlock_after_lockout is enabled[2017-05-13 12:00:22.082966] End of lockout! (timed out after 17.83 seconds)
Robby
ah yes I created a bug in my change, so the state was never changed to waiting ... committed a fix so you can update and try again
HI, as for now it works perfect ! I got the solenoid. I'll build the whole lock mechanism with this now...
Hi Joakim,
a little strange thing happens some times. ( All works still in test laboratory ) When the cat comes in (do_unlock_cmd), the solenoid opens but after one or two seconds (maybe lockout time, when I had set it to two seconds) the code set pin 4 to 0 V although the sleep 10 in the unlock.py was still not expired. So in that case the cat would have only one or two seconds time to pass. It seems there is a code internal lockout call which doies not trigger a loging line neither the external cmd event do_lockout, because when this happens you can not see it in the loging output lines. I guess I can prevent this issue by setting the lockout time to a higher value. I'll do that and observe it some time and let you know later. Coming week I'm on a business trip. So can reply, but can not test or do anything with that project :-( But we are almost ready. Thanks for your time you spend! Robby
Here is the solenoid with the mechanics... The elctronic drivers I self made are also working fine... :-)
Wow that's a huge solenoid compare to mine. What is the model and what did it cost?
a little strange thing happens some times. ( All works still in test laboratory ) When the cat comes in (do_unlock_cmd), the solenoid opens but after one or two seconds (maybe lockout time, when I had set it to two seconds) the code set pin 4 to 0 V although the sleep 10 in the unlock.py was still not expired.
hmmm can't say I understand what that possibly could be. That should never happen, everytime I set the pin low it should also print something. Are you 100% sure it's your PIN and not some glitch in your circuit somehow?
Anyway I need some more details to understand that better...
1 Stück 502352 BLECHBÜGELMAGNET ITS-LS 2924B 16,66 € 16,66
From conrad.de Von meinem iPhone gesendet
Am 15.05.2017 um 14:52 schrieb Joakim Söderberg notifications@github.com:
Wow that's a huge solenoid compare to mine. What is the model and what did it cost?
a little strange thing happens some times. ( All works still in test laboratory ) When the cat comes in (do_unlock_cmd), the solenoid opens but after one or two seconds (maybe lockout time, when I had set it to two seconds) the code set pin 4 to 0 V although the sleep 10 in the unlock.py was still not expired.
hmmm can't say I understand what that possibly could be. That should never happen, everytime I set the pin low it should also print something. Are you 100% sure it's your PIN and not some glitch in your circuit somehow?
Anyway I need some more details to understand that better...
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
Hi Joakim,
came back from business trip yesterday. I was in the store today and bought the wood and some stuff... Will start with building up the box :-) Full of anticipation I started catcierge laboratory and passed my raw hand before the backlight. I was wondering why catcierge unlocked the solenoid... The logoutput states:
[2017-05-20 13:27:47.900285] [Waiting] -> [Matching]
[2017-05-20 13:27:47.954802] Match unknown - No prey detected (98b59bff11013e17a4fffde75a9266a694f0250e)
[2017-05-20 13:27:48.021103] Match in - No cat head detected (72848c0bc2576e0ccdaae2a272b1f8987eb9343)
[2017-05-20 13:27:48.086833] Match in - No cat head detected (2e75d0e03665cd3f26f555ac10b50e855bc52679)
[2017-05-20 13:27:48.150869] Match in - No cat head detected (9b8269452dff45b13532e289b83cb7b74aff4c55)
[2017-05-20 13:27:48.163666] Everything OK! (4 out of 4 matches succeeded) Door kept open...
[2017-05-20 13:27:48.166446] Called program "/home/robby/Katzenklappe/tools/unlock.py"
I can imagine, that catcierge may have trouble recognizing such a fast move of a hand and so on, but for me it seems a bit illogical when the result after 1 positive try (No prey detected) and three negative tries (No cat head detected) are stated with "4 of 4 matches succeeded, everything OK." I would expect that the code says "1 out of 4 tries succeeded" Lockout...
I guess this has to do with the fact, that your solution is based on a open door by default and my on is locked by default, so you would keep the door open in case the cat head is not detected (majority this issue), and this will unlock my door now ;-) Not a big issue, I hope the cat will not realize this :-)
Robby
Ohh I found --no_match_is_fail I guess this will solve the issue... Will try...
works great, yeahhh :-)
:) Good you found the setting. But yea there are a few of those tweak settings I have added. Believe me you won't know all the parameters until you have it running for a while with real world result :)
Last night I happened to be up in the middle of the night and managed to catch my cat just as she has caught a bird and tried to get in.... repeatdly... 10 times in a row, and it keeps stopping her.
https://www.youtube.com/watch?v=utVXP6q7Cys
And yes, this is at night 2:39 am... I live far up north with the midnight sun :)
In that video you can see how she listens to the solenoid opening and tries again. Just too bad I did not have my secondary camera turned on so I could cut in the image of her when she was inside of the cat door as well.
Hi Joakim,
had some days with stress, but now I found time to move the project forward. I'm getting closer to the final destination ;-) See the picture...
Robby
Looks nice! It will be exciting to see the finished thing :)
Regarding the floor, I suggest you paint it with something so it gets a glossy / easy cleanable surface. Having raw wood will soak up any blood or similar from prey... which does not become very pleasant after a while :>
Hi Joakim,
I'm almost done with all of it. Will send photos tomorrow or on Sunday. Currently all the thing are done. Also all your suggestions I implemented. On this Weekend I'll bring this new device to my friend :-)
One thing which is not really working: Email:
[2017-06-10 00:57:58.252697] Something in frame! Start matching... [2017-06-10 00:57:58.327819] [2017-06-10 00:57:58.327909] === Match group id: 682453ecd9ef1989b574178c7e21e93493e51505 === [2017-06-10 00:57:58.327952] [2017-06-10 00:57:58.327985] [Waiting] -> [Matching] [2017-06-10 00:57:58.378380] No Match in - Prey detected (b12d5349c24e35a1669163a9595e523d2e83a1ef) [2017-06-10 00:57:58.428098] No Match in - Prey detected (4a9e55575602ef33f77aba975ecb05b4e467fa42) [2017-06-10 00:57:58.477889] No Match in - Prey detected (9aa338b9f3355471294dee0454eec186edba8a12) [2017-06-10 00:57:58.527828] No Match in - Prey detected (334bd4726bfab51f5dad74e157d888b722cf4f1d) [2017-06-10 00:57:58.528356] Lockout! 4 out of 4 matches failed (for 15 seconds). [2017-06-10 00:57:58.528410] Wait for lockout timer to finish OR frame to clear (Lockout method 3) [2017-06-10 00:57:58.528432] [Matching] -> [Lockout] [2017-06-10 00:57:58.530651] Called program "/home/robby/Katzenklappe/tools/lock.sh" [2017-06-10 00:57:58.530788] Saving image /home/robby/Katzenklappe/run/images//682453ecd9ef1989b574178c7e21e93493e51505/match_fail_2017-06-10_00_57_58.3409211.png [2017-06-10 00:57:58.546226] Saving image /home/robby/Katzenklappe/run/images//682453ecd9ef1989b574178c7e21e93493e51505/match_fail_2017-06-10_00_57_58.390663__2.png [2017-06-10 00:57:58.559916] Saving image /home/robby/Katzenklappe/run/images//682453ecd9ef1989b574178c7e21e93493e51505/match_fail_2017-06-10_00_57_58.4404063.png [2017-06-10 00:57:58.573090] Saving image /home/robby/Katzenklappe/run/images//682453ecd9ef1989b574178c7e21e93493e51505/match_fail_2017-06-10_00_57_58.490343__4.png [2017-06-10 00:57:58.587013] Unknown template variable "RO5 --json "" [2017-06-10 00:57:58.587098] Failed to execute command "python /usr/local/share/catcierge/catcierge-sendmail-new.py --to myemail@mail.de --from myemail@mail.de --smtp smtp.strato.de:587 --password MyPassword --json "%template_path:match_group_done_full%" --images %match_group_id%-combined-steps.png --extra "%template_path:match_group_done_full%""! GPIO.setup(5, GPIO.OUT) [2017-06-10 00:57:59.929319] End of lockout! (timed out after 1.40 seconds) [2017-06-10 00:57:59.929438] Not performing unlock since --no_unlock_after_lockout is enabled[2017-06-10 00:57:59.929459] [Lockout] -> [Waiting]
Thank you ,
Robby
By the way, I replaced my password and my real emeil address with other valuaes. So it should actually work ...
Hello Joakim,
I'm glad about your project is documented and public for all of us who are having this problems :-) Thank you very much! I'll keep you up2date with my project. I'm not really a good programmer in C, I would categorize myself in the box of hobbyists always having fun with that ;-), but out of C i'm definitely technically gifted:-) My question: can I use a standard webcam with your code? I have a RPI 3 Model B and a used Logitech C270 webcam which is also supported by Raspberry. Following your REAME.txt I got stuck at this position: ... " command line options used by the
raspivid
program" ... After investigating I got the fact, this binarys can be used only with the raspi-cam... So I installed some kind of software which belongs to standard USB webcams: ... sudo apt-get install fswebcam ... Now I'm able to take captrure some picture for example with ... fswebcam -r 640x480 --no-banner ~/test.jpg ... But I have no idea to combine this usb webcam with your code. The last few days planning time in mind I was hoping this code would work also wtih other cameras ... Thak you in advance. Robby