Face recognition for the Cat's door?

Post Reply
o_lampe
Posts: 74
Joined: Wed Jan 01, 2020 12:35 am
languages_spoken: english german
ODROIDs: MC1 solo
Has thanked: 4 times
Been thanked: 9 times
Contact:

Face recognition for the Cat's door?

Unread post by o_lampe » Tue Feb 11, 2020 4:15 pm

Hi folks,
would it be possible to use a docker swarm with an analog IR-vision camera to control access to my cat's door?
I have a LogiLink frame grabber for USB2.0
I read an article about "deep learning", where they were able to recognize a glass of beer at 4 frames/sec? IIRC written 2015

What would I need to teach the ( which?) framework? A few videos of the "enemy" ( racoon ) are available. ( see my YT-video https://youtu.be/vLqN-u3vFXs )

Thanks for any hints and suggestions
Olaf

o_lampe
Posts: 74
Joined: Wed Jan 01, 2020 12:35 am
languages_spoken: english german
ODROIDs: MC1 solo
Has thanked: 4 times
Been thanked: 9 times
Contact:

Re: Face recognition for the Cat's door?

Unread post by o_lampe » Thu Feb 13, 2020 3:12 pm

It seems, that openCV has a module* to process your own images. Positive and negative sample pics are needed to build your own database.
And there's a basic docker image, too.
"It's crunch-time", I'd say :D
Will be pretty difficult to separate right from wrong. Maybe it's easier to use racoons faces as "positive" and let any other animal pass the door? (inverted logic)
freddy.jpg
freddy.jpg (34.68 KiB) Viewed 531 times
mean_racoon.jpg
mean_racoon.jpg (11.32 KiB) Viewed 531 times
* link: https://docs.opencv.org/2.4/doc/user_gu ... scade.html
These users thanked the author o_lampe for the post:
odroid (Thu Feb 13, 2020 3:14 pm)

User avatar
mad_ady
Posts: 7332
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 346 times
Been thanked: 252 times
Contact:

Re: Face recognition for the Cat's door?

Unread post by mad_ady » Thu Feb 13, 2020 3:22 pm

Question is - what are you going to do once you get a positive match? Send out a toy robot to scare it away, perhaps?

Image recognition is a fascinating subject, but it's still to wastefut in terms of power usage. My heart cries with having high cpu usage in idle times (e.g., at night, or when there is no movement), so how about hooking up a pir sensor to trigger recognition only when motion is detected in that area?

Document your work, it looks like a great magazine article!

You can probably find lots of cat images on the net cleaned as training data, but unless you train the racoon as well you'll get nothing when a racoon enters...

o_lampe
Posts: 74
Joined: Wed Jan 01, 2020 12:35 am
languages_spoken: english german
ODROIDs: MC1 solo
Has thanked: 4 times
Been thanked: 9 times
Contact:

Re: Face recognition for the Cat's door?

Unread post by o_lampe » Thu Feb 13, 2020 4:08 pm

Thanks @mad_ady,
the PIR sensor is a MUST. Then take a series of screenshots and compute. A "true" result triggers a solenoid that opens the doors lock ( or chases away the intruder with a loud CLICK ;) )
You can probably find lots of cat images on the net cleaned as training data, but unless you train the racoon as well you'll get nothing when a racoon enters...
The false images can even be empty screenshots of the cat's door without any animal in sight. That way wolves, rats, wiesels and all other sorts of wildlife can't pass.
I just thought I have to train racoons, as they look alot like my cat. ( and they show up around my house frequently )

Bad thing is, I maybe have to use a Raspberry with it's IR camera. Or a surveilance IP-camera
@odroid Is there an Odroid SBC with camera connector?
Last edited by o_lampe on Thu Feb 13, 2020 4:17 pm, edited 1 time in total.

User avatar
mad_ady
Posts: 7332
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 346 times
Been thanked: 252 times
Contact:

Re: Face recognition for the Cat's door?

Unread post by mad_ady » Thu Feb 13, 2020 4:12 pm

If you have a disposable camera you could try to hack it and remove the IR filter and bathe the scene in IR light (https://www.instructables.com/id/infrar ... -real-way/). Though, for best results the training images should be IR too...

o_lampe
Posts: 74
Joined: Wed Jan 01, 2020 12:35 am
languages_spoken: english german
ODROIDs: MC1 solo
Has thanked: 4 times
Been thanked: 9 times
Contact:

Re: Face recognition for the Cat's door?

Unread post by o_lampe » Thu Feb 13, 2020 4:19 pm

I already have analog IR cameras, but the video grabber messes up the picture quality.
Though, for best results the training images should be IR too...
That's a real good starting point: installing a PIR + camera and make lot's of screenshots when the cat passes the door.
Last edited by o_lampe on Thu Feb 13, 2020 4:29 pm, edited 1 time in total.

User avatar
odroid
Site Admin
Posts: 33270
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 365 times
Been thanked: 445 times
Contact:

Re: Face recognition for the Cat's door?

Unread post by odroid » Thu Feb 13, 2020 4:28 pm

o_lampe wrote:
Thu Feb 13, 2020 4:08 pm
@odroid Is there an Odroid SBC with camera connector?
Nope.

But you can consider USB cameras or other sensors.
https://magazine.odroid.com/article/obj ... -tracking/
https://magazine.odroid.com/wp-content/ ... df#page=30
https://magazine.odroid.com/article/odr ... droid-xu4/

o_lampe
Posts: 74
Joined: Wed Jan 01, 2020 12:35 am
languages_spoken: english german
ODROIDs: MC1 solo
Has thanked: 4 times
Been thanked: 9 times
Contact:

Re: Face recognition for the Cat's door?

Unread post by o_lampe » Sat Feb 15, 2020 4:22 pm

I have to face another challenge:
How do you edit hundreds or thousands of pictures to collect a decent database for openCV on a headless cluster?
Sure I could do that on my windows machine and copy the processed pictures to the cluster, but that's cheating!

I read about "remote desktop" using a vnc client, but that requires some modifications in GNOME desktop environment ( enable shared view and set a password for remote clients ) Easy enough, if I could only start GNOME desktop once on a MC1...it's a hen/egg problem.
I'd need an XU4 only to modify the desktop, make an image and install it on my MC1.
Or I ask someone with an XU4 to do the modifications on a clean Ubuntu-mate image and send the fresh image to me... :)

For now I found a different way: Using a ssh connection via puTTY with enabled "X11 forwarding" and Xming as X-window interface on my Windows PC. Very slow, but I could start a browser to find some pictures on the net and store it on my MC1.
Then I found graphicsmagick. A tool to edit pictures from a terminal window or in my case, from the puTTY screen. It is able to crop, resize and grayscale images and it has a batchmode to process all images, too. That's pretty handy for my project!

PuTTYs data rate is now set to 38400 BAUD. Does anyone know the fastest stable setting? It's a Gigabit network.

Thanks for reading. Any comments are welcome
Olaf

User avatar
mad_ady
Posts: 7332
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 346 times
Been thanked: 252 times
Contact:

Re: Face recognition for the Cat's door?

Unread post by mad_ady » Sat Feb 15, 2020 5:01 pm

If it's over network, then baud setting makes no sense. Are you sure you're using ssh and not serial connection?

o_lampe
Posts: 74
Joined: Wed Jan 01, 2020 12:35 am
languages_spoken: english german
ODROIDs: MC1 solo
Has thanked: 4 times
Been thanked: 9 times
Contact:

Re: Face recognition for the Cat's door?

Unread post by o_lampe » Sat Feb 15, 2020 7:26 pm

Are you sure you're using ssh and not serial connection?
There is a separate connection speed setting, but changing it to 10MBit didn't change anything.
Also tried setting serial baudrate from 9600 to 115200 without luck.
putty_speed.jpg
putty_speed.jpg (51.71 KiB) Viewed 389 times

o_lampe
Posts: 74
Joined: Wed Jan 01, 2020 12:35 am
languages_spoken: english german
ODROIDs: MC1 solo
Has thanked: 4 times
Been thanked: 9 times
Contact:

Re: Face recognition for the Cat's door?

Unread post by o_lampe » Sat Feb 15, 2020 7:38 pm

BTW: I found a blog where it's done already, except the door control part:
https://meenavyas.wordpress.com/2018/11 ... ng-opencv/

They use the obsolete HAAR-algorithm, but openCV propagates the faster LBP algo:
LBP features yield integer precision in contrast to HAAR features, yielding floating point precision, so both training and detection with LBP are several times faster then with HAAR features.
These users thanked the author o_lampe for the post:
mad_ady (Sat Feb 15, 2020 8:38 pm)

o_lampe
Posts: 74
Joined: Wed Jan 01, 2020 12:35 am
languages_spoken: english german
ODROIDs: MC1 solo
Has thanked: 4 times
Been thanked: 9 times
Contact:

Re: Face recognition for the Cat's door?

Unread post by o_lampe » Mon Feb 17, 2020 4:53 pm

I read about "remote desktop" using a vnc client, but that requires some modifications in GNOME desktop environment ( enable shared view and set a password for remote clients ) Easy enough, if I could only start GNOME desktop once on a MC1...it's a hen/egg problem.
Could I use losetup to mount the Mate-image as loop device and then modify the settings via text-editor? Which file would I have to modify to enable shared view. Is there a tool in Ubuntu like "Raspi-Config" that allows system config from the CLI?

Thanks
Olaf

User avatar
mad_ady
Posts: 7332
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 346 times
Been thanked: 252 times
Contact:

Re: Face recognition for the Cat's door?

Unread post by mad_ady » Mon Feb 17, 2020 5:16 pm

Forgot to mention. I don't generally use VNC, I use xpra instead. It's useful for running a specific application instead of the whole desktop environment. You can find standard usage tips here: viewtopic.php?t=35710
These users thanked the author mad_ady for the post:
o_lampe (Mon Feb 17, 2020 7:31 pm)

o_lampe
Posts: 74
Joined: Wed Jan 01, 2020 12:35 am
languages_spoken: english german
ODROIDs: MC1 solo
Has thanked: 4 times
Been thanked: 9 times
Contact:

Re: Face recognition for the Cat's door?

Unread post by o_lampe » Mon Feb 17, 2020 7:42 pm

Thanks for the hint, although I didn't get the whole picture, I 'm afraid ;)
Wouldn't xpra use the same slow puTTY connection on my Win-PC?
Alternatively I can use RasPi3 as "head" of my cluster, would that be a faster ssh connection? WLAN or 100Mbit at most...

The easiest way would be buying an XU4 and integrate it in my cluster, but that would almost double the cost of my toy-cluster.

User avatar
mad_ady
Posts: 7332
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 346 times
Been thanked: 252 times
Contact:

Re: Face recognition for the Cat's door?

Unread post by mad_ady » Mon Feb 17, 2020 8:55 pm

No, xpra is independent of ssh, though it can work over ssh. It runs a X server so the video part is transferred over network. It does some video encoding though.

User avatar
rooted
Posts: 7259
Joined: Fri Dec 19, 2014 9:12 am
languages_spoken: english
Location: Gulf of Mexico, US
Has thanked: 450 times
Been thanked: 126 times
Contact:

Re: Face recognition for the Cat's door?

Unread post by rooted » Mon Feb 17, 2020 9:01 pm

You could use Google custom search JSON API, it's reverse search could easily identify a cat vs a coon.

https://developers.google.com/custom-se ... view?hl=it

You can get 100 search queries per day for free, if your Internet goes down you could fallback to full automation until it comes back up.

o_lampe
Posts: 74
Joined: Wed Jan 01, 2020 12:35 am
languages_spoken: english german
ODROIDs: MC1 solo
Has thanked: 4 times
Been thanked: 9 times
Contact:

Re: Face recognition for the Cat's door?

Unread post by o_lampe » Tue Feb 18, 2020 3:13 pm

rooted wrote:
Mon Feb 17, 2020 9:01 pm
You could use Google custom search JSON API, it's reverse search could easily identify a cat vs a coon.

https://developers.google.com/custom-se ... view?hl=it

You can get 100 search queries per day for free, if your Internet goes down you could fallback to full automation until it comes back up.
What would I learn from that?

I'd only get swamped with cat-related advertising...
No Sir, guugel will never intrude my privacy.

It's a horrifying thought, that anyone can send pictures of strangers to google ( without their permission !? ) and get an answer, who this might be.

User avatar
rooted
Posts: 7259
Joined: Fri Dec 19, 2014 9:12 am
languages_spoken: english
Location: Gulf of Mexico, US
Has thanked: 450 times
Been thanked: 126 times
Contact:

Re: Face recognition for the Cat's door?

Unread post by rooted » Tue Feb 18, 2020 4:25 pm

It's pictures of animals...

User avatar
mad_ady
Posts: 7332
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 346 times
Been thanked: 252 times
Contact:

Re: Face recognition for the Cat's door?

Unread post by mad_ady » Tue Feb 18, 2020 4:40 pm

rooted wrote:It's pictures of animals...
You don't know the cat in question. It has high opinions on privacy Image

Post Reply

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 2 guests