monkeyfork
Posts: 62
Joined: Tue Oct 29, 2013 10:14 am
Location: orlando

catPooPee

Sat Sep 29, 2018 10:50 pm

I am a ways into my project catPooPee (aka PooPeePi ) which records overhead video of cat's litter box (using "motion") and records weight of litter box using load-cells (3-5kg load cells arranged as three hard points touching floor ). I want to move forward with ID of cat using openCV but that software suite is not in my skill set yet. I'd really like recommendations to help me down a path of least resistance of Identifying cat by color of collar.

Motion video is running well on old original pi burning about 25% of cycles. Measuring load-cells is off-loaded to arduino uno underneath litter box and is sent serially to overhead rpi. Rpi and RPi-cam is currently in structure above litter box but will be relocated to pole mount in future. Daily videos are offloaded to another server. I'd like to migrate entire system to one rpi-zero-w eventually if within it's limits of computational power.

Here is video of recent gangsta cat behavior uncovered <grin> by catPooPee. ( https://youtu.be/y2UVLkZmGP8 )

Any help to move forward with openCV on rpi greatly appreciated.

monkeyfork
Posts: 62
Joined: Tue Oct 29, 2013 10:14 am
Location: orlando

Re: catPooPee

Thu Oct 11, 2018 3:53 pm

humm... crickets. Maybe I should give more to receive. I have decided that it would be better to do the "which-cat-recognition" on a more powerful server where the daily collection of cat-event jpg's and avi's are moved to on a daily basis. I _think_ it will be easier to configure and use openCV for that sort of task on ubuntu than Raspbian but that's still total unknown for me. So, specifically for the RPi, I'm moving toward doing the load-cell weight measurement directly on the RPi rather than offloaded to a serially connected arduino. I've found this code base;
https://github.com/ggurov/hx711
for the very nice/cheap instrumentation amp that I'm using. Looks promising, will report after testing.
I am using 3 load-cells per litter box (underneath a platform that supports litter box) and was amazed to find that the weight is NOT equally distributed. Maybe it's a function of cat-center-of-mass versus centroid of load-cell contact points??? (I am static's challenged).

For anyone interested in connecting load cells as I have already tested (connecting load-cell to arduino, then arduino serial to RPi) this is where i started; https://github.com/bogde/HX711

I'm building up a second litter box now that I hope to connect the three load-cells (using the proprietary but documented synchonous serial protocol) very soon, reports to forum will follow.

wpballa1
Posts: 52
Joined: Sat Jun 27, 2015 12:49 am

Re: catPooPee

Tue Oct 16, 2018 12:47 am

Well I did something similar (just video with motion) to see which cat was missing the box. It turned out to be the one with arthritis. Rather than video identification, could you do it by weight? That might be a lot simpler in the long run.

monkeyfork
Posts: 62
Joined: Tue Oct 29, 2013 10:14 am
Location: orlando

Re: catPooPee

Tue Nov 06, 2018 5:22 pm

Thanks for input wpballa1. It appears with weight difference between _my_ two cats and accuracy of the load cells that I can indeed differentiate and ID which cat is in box with weight. However, I've already seen a few instances where one cat is in the box and one cat is on the platform (with load cells) harassing the cat in the box (grrrr) so the weight is screwed. So, I'm trying to cover the corner cases and lower the false alarms and provide other sensing methods for anyone that wants to try this. I will work toward pet-microchip sensing (not hopeful), and collar bound RFID (hopeful, but will piss off the cats). But first I'm working on using openCV to detect colored collars (slightly hopeful, cause I don't know openCV)

wpballa1
Posts: 52
Joined: Sat Jun 27, 2015 12:49 am

Re: catPooPee

Thu Nov 08, 2018 12:52 am

Well, we've got 4 cats and 5 cat boxes so they don't argue over who is using which one. After a while I can tell who did what by the shape of the poop! Of course that doesn't work with the pee...

PhatFil
Posts: 1309
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: catPooPee

Thu Nov 08, 2018 2:45 am

While I applaud your inventiveness i am dumbfound as to WTF and WHY???

I have dotted on all my cats over the years, i lost my lil black stealth cat Daisy about 3 years ago and still expect to find her occupying the corner of my eye in every room of my home, I was raised to understand that in the grand scheme of things Cats come first, For my formative years i would return home from school and wait while my Mam finished cooking the cats dinner (fish rabbit or chicken) before i was given my frozen reheat..

anyway good luck with the project and i look forward to the write up, I guess filling the cloud with cat scat is no worse than the bile found in social media

monkeyfork
Posts: 62
Joined: Tue Oct 29, 2013 10:14 am
Location: orlando

Re: catPooPee

Thu Nov 08, 2018 3:38 pm

thx for testimonials and data. to answer WTF & WHY. background. I spent life disliking cats and being a dog person. Then I spent some romantic weeks with beautiful russian lady in Sochi who is bonkers for cats. We spent much budget and time helping strays. That was NOT my plan but the experience changed me about cats. Now I'm certified cat-person. Of course all this happens about the time I retire. So... got all these aerospace skill sets and time on my hands... voila... project "catPooPee" that i'm sure will splinter and fork into many more cat-tech projects, ha.

I'm in a great maker space (Familab, Orlando) where I'm trying to recruit openCV expertise to pursue the first goal of ID-by-collar-color, then on from there. Periodic reports will be made to rpi-forum.

btw... the real WHY is that I've been convinced that cat dropping analysis (and weight tracking) may be a path of least resistance to monitoring cat health (so far I'm trusting but have goal of verifying).

PhatFil
Posts: 1309
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: catPooPee

Thu Nov 08, 2018 8:51 pm

Power to you, and Go For It (as you indeed are..) a mod, hack, or even a complete redesign/build of the automatic litter boxes that filter and discard the doings i can get behind 100% i can even understand the addition of say rfid collar tags and a reading coil-loop around the doorway and perhaps even a load cell or two to record mass of litter scat and liquid ejected each time to be used for a health related data log. but i would halt way before i started a photographic record of the scat left behind, no no no no no.. then again i bet there is a category on pornhub or similar that would welcome such media?? No disrespect intended, just honest horror at the prospect, Anyway have fun and enjoy, just not too much eh ;)

monkeyfork
Posts: 62
Joined: Tue Oct 29, 2013 10:14 am
Location: orlando

Re: catPooPee

Sat Dec 08, 2018 8:53 am

Update on catPooPee. With help from local maker space (Familab, Orlando) I _finally_ got a good working environment for openCV (with C++ bindings on lubuntu 18.04). I've hacked a number of how2s for openCV and am now confident that I can identify which cat (of 2) is in the litter box for an 'event' (based on color of collar). Weighing the cats upon arrival (to the litter box) is looking good using 3 load-cell contact points is looking good (for long term cat-weight tracking). However, determining weight of their deposits is going to be a bit tricky due to long term drift of the load cells (probably caused by self-heating of resistors in wheatstone bridge of load-cell). The HX711 based load cell amps have a power down feature that may help in fighting temperature drift but that is untested. So for now the planned system for 2 litter boxes (scalable to more boxes) looks like this;
- rpi-zeroW + rpi-cam running motion will capture box visit events (one avi plus sequenced jpgs) overhead litter box on pvc tubing structure.
- arduino nano running HX711-multi code base to manage 3 load-cells (5kg) will connect to rpi-zeroW via usb.
- central cat-server will pull accumulated poo-pee events from each remote rpi-zeroW (with local purge) on daily basis.
- central cat-server will prepare daily report based on motion event combined with weight measurements during the events.

I was discouraged from trying to incorporate pet-chip RFID detection due to poor detection range. However, collar borne passive RFID looks very good and I have access to some good tribal knowledge locally. (ID of cat using openCV and color of collar is not probably scalable)

Drawings for catPooPee platform that contains hardpoints for load-cells and pvc pipe structure for holding rpi-zeroW will be made available at some point.

Kalayana
Posts: 1
Joined: Wed Dec 19, 2018 8:46 pm

Re: catPooPee

Thu Dec 20, 2018 1:23 am

In response to Phatfil asking WHY, I had the same question after meeting 'monkeyfork' at Familab. He convinced me of the need though. First, on the individual level; when one of his cats was ill he said he would have realized sooner and prevented unnecessary suffering if he'd known that one particular cat had stopped using the litter tray regularly.

Also he's thinking far into the future. When we start having general purpose robots doing household chores we will create less landfill if they can detect when to clean the litter tray, rather than changing it at set times.

This catPooPee project is a step towards a bigger environmental project. And when he's developed this system there might be wider applications of the technology.

monkeyfork
Posts: 62
Joined: Tue Oct 29, 2013 10:14 am
Location: orlando

Re: catPooPee

Fri Dec 21, 2018 11:16 am

thanks kalayana for mission support)) Your perspective is valued. I should think more about how to present intent of project. Now a short catPooPee update for proof-of-life (i am old, that is always in question). The arduino code base HX711-multi is now working (after minor tweaks) for the triad of load-cells (for litter box weight measurement) and giving reasonable data (still drifty as a ten-cent gyro because of temp coefficient of resistors in loadcell combined with self-heating effects). The arduino connects to a rpi-B-early. The arduino is pumping out 3 measurements of the litter box weight at 10hz @ 115200bps. I've now written C code that receives the weight data and prepends a motion-like time stamp to record.

So... Motion running full time can consume 20% of available cycles (of old rpi). Layering on handling of the serial data from arduino is peacefully coexisting with motion so far although I did have apparent buffering problems that I've bandaided (to be analyzed later, right now I need drama).

Quick analysis of weight vs video are nominal and weight tracks with video. I've now captured a few full 'events' and will start spreadsheeting
the data to see if it's possible to measure the weight of 'deposits' and how well weight can be used to ID the cats. (my two furry lab assistants are close in weight so they make a good test case).

PhatFil
Posts: 1309
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: catPooPee

Fri Dec 21, 2018 1:18 pm

consider my vision expanded ;) :oops:

monkeyfork
Posts: 62
Joined: Tue Oct 29, 2013 10:14 am
Location: orlando

Re: catPooPee

Wed Dec 26, 2018 3:17 am

Christmas 2018 sitrep of catPooPee. There is a fly in my ointment :-( The weighing system for litter box plus cat works fine for clearly indicating that a cat is present... but I can do that with the motion videos. Need to get to accuracy and precision and repeatability to weigh their deposits. Initial weight data indicates goofy things like litter box weights tiny tiny bit less after the cat's visit than before. Don't think the cat comes to the litter box to eat dirt so that finding is suspect. My first guess of the errors in repeatability or showing small weight changes over very short period of time comes from the haphazard way in which I constructed the platform on which the litter box rests and which holds the three load cells. Take a look at my thrown-together platform and hazard some guesses (please)
platform0 pix link: http://dabeak.com/platform0_3strut_3LC_ ... 2357~2.jpg

platform0: 3/8" plywood scrap for planar surface. 1/2" AL angle used to fab struts that hold load-cells (at extreme ends). arduino and load-cell amps mishmashed willie nillie toward center. Assembly contacts floor by 3 M4 hex head bolts and extreme end of load cell. The 'struts were intended to stiffen the plywood to minimize sag when loaded.

My guess is that in taking path of least resistance for fabrication, the floor contact points are a few degrees off plumb. The off-plumbness is aggravated by the platform not being stiff enough. Fully loaded with litter box, litter and cat there is a perceptible sag in middle. When cat jumps out after 'event' the sag rebound plus stiction of the floor contacts probably changes how far off vertical the contact points are oriented.
Next action is to remount all the load cells to ensure vertical force vector and to stiffen platform to eliminate sag.

After reading up on the HX711 load cell amp I see lots of folks chasing both noise and drift issues. I'm sure I'll get to that but that's fine tuning compared to errors that I have now.

Still convinced that cats are extra-terrestrial engineers.

monkeyfork
Posts: 62
Joined: Tue Oct 29, 2013 10:14 am
Location: orlando

Re: catPooPee

Thu Dec 27, 2018 4:52 pm

Ok... I'm officially jazzed now. After yesterday's tweaks on the platform that has load-cells as floor contacts I'm getting very good data.
Here is time history of a "pee-event" (helpfully arranged by my furry lab assistant PeachO).
http://dabeak.com/test25dec2018_02_peachO_pee_event.pdf

Note stairstep on on leading edge. I believe this to be cat stepping into box. Stepping onto the platform in someplaces will actually "unload" some loadcells and probably accounts for this artifact. Also note a bit of scratching around early, a section of calm, then another section of scratching around as would be expected. Then near end of event a spike as PeachO launches himself out of the box. Finally and most importantly, a baseline shift that hopefully will be a standard data point, the weight of the cat-deposit.

I could make available the raw data and the associated jpg's and avi's from overhead motion triggered cam if anyone is interested in analyzing. I'm not very good at that aspect and would welcome opinions.

The "tweaks" on the platform yesterday was stiffening with aluminum angle and adjusting hard points (load-cell floor contacts) so that they are much closer to being orthogonal to floor.

monkeyfork
Posts: 62
Joined: Tue Oct 29, 2013 10:14 am
Location: orlando

Re: catPooPee

Fri Jan 18, 2019 5:33 pm

I've had to do another spin of my catPooPee platform. My failure analsis crew (cat PeachO and cat Piffy) have shown me how clever they are at destroying electronics. long story short, load-cells with associated delicate strain-gauge wires were underneath platform away from platform perimeter, hopefully out of reach of inquisitive cat-claws. My lab assistants schooled me... they can reach a LOOOONG way and #26 wire doesn't stand a chance against cat claws! So, now deciding how to put a skirt around perimeter of platform that will cut gap down to about 1/4" (get your paws under that you little bastards!). In mean time, check pix of what I call "hardpoints", a metal place to mount load-cell. http://dabeak.com/catPooPee_hardpoint_l ... 4915~2.jpg It's fabbed out of electrical junction box cover plate, very cheap in US. Another cover plate is used to complete the hardpoint as they are sandwiched on opposite sides of 5mm cheapie homestore plywood. Mo pix of new design platform soon. Meow

monkeyfork
Posts: 62
Joined: Tue Oct 29, 2013 10:14 am
Location: orlando

Re: catPooPee

Thu Jan 24, 2019 11:13 pm

Here's latest evolution of a litter box weighing platform;
http://dabeak.com/cPP_platform2_box_lid ... 1114~2.jpg
The platform has evolved to be a box structure to maximize rigidity and minimize weight while using off the shelf material that can be formed with simple wood working tools. The metal in corners of box are electrical outlet cover plates that act as rigid hardpoints on which to mount the weighing sensors called load-cells. The box structure will contain some of catPooPee electronics. One arduino and the load-cell differential amps will be wired together inside box. delicate wires from load-cell enter box very near load-cell to minimize exposed wire, silicon caulk will be added at that entry point to protect wires. Here's a view of the underside of the box platform showing detail of loadcell mounted to coverplate. http://dabeak.com/cPP_hardPoint_loadCel ... 1147~2.jpg The M4 hex head bolt on this upside down view is one of three contact points with the floor.

I welcome comments about my 3 point weighing scheme which was a path of least resistance and has not been a tipping problem (so far).

monkeyfork
Posts: 62
Joined: Tue Oct 29, 2013 10:14 am
Location: orlando

Re: catPooPee

Tue Feb 26, 2019 9:06 pm

work continues... I'm coming to grips with the realities of CAT ENGINEERING

the good news. The famed cat curiosity is real, new innovations are rapidly investigated and subjectect to intense environmental testing, herf, electrostatic discharge, salt water spray, shake and bake.
http://dabeak.com/piffySniffAtLitterBox ... 123925.jpg

the bad news. The famed cat curiosity is real... I can't keep the furry varmits out of the electronics. here's pix of the growing anti-curiosity protection of raspberry pi with cam that is presently suspended over the cat box on a temp horizontal surface that apprarently a MUST-VISIT cat LZ.
http://dabeak.com/anti_cat_curiousity_I ... 123930.jpg

right now I'm accumulating about 200MB/day of litter box visits (jpg&avi). Obviously too much data. Will be working toward paring that down to something reasonable before merging with cat-box weight data that is now just streaming to /dev/nul.

PhatFil
Posts: 1309
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: catPooPee

Wed Feb 27, 2019 1:47 am

little brightly coloured wires will be uber catnip ;) consider potting the electronics when finalised..

onwards n upwards ;)

mushu999
Posts: 29
Joined: Sun Aug 20, 2017 11:24 pm

Re: catPooPee

Wed Feb 27, 2019 6:35 pm

Perhaps instead of weight use image recognition: https://github.com/ctchuang/yolo3-camera

monkeyfork
Posts: 62
Joined: Tue Oct 29, 2013 10:14 am
Location: orlando

Re: catPooPee

Sat Mar 02, 2019 7:33 pm

PhatFil: I've used a lot of milspec equipment with potted connectors, potted assemblies and conformal coated pcbs but never had to deal with the manufacturing particulars. You got any recommendations for a pourable RTV?

mushu999: I'm using weight as a health metric and that is working very good. However, I do want to move forward with getting openCV to be more robust at identifying individual cats using distinguishing cat collars. It appears that your link identifies sortof generic objects. Do you have any idea if that code base is tweakable to be very specific?

Thanks for your inputs

blimpyway
Posts: 120
Joined: Mon Mar 19, 2018 1:18 pm

Re: catPooPee

Wed Mar 06, 2019 1:14 am

This is a bit gross, cute project. It has great potential, pet health monitoring might be a lucrative thing.

I guess you can identify an individual cat in opencv by combining weight and image colour. Unless you deal with equal sized/coloured twins, it might work.

A pi should be sufficient to process image data in opencv since it doesn't need to be done real time, it can spare a few minutes to analyse each "pee-poo-pi event" .

----
The "normal" bathroom scales use four half bridge load cells, one in each corner of the square platform.
They are wired in a full wheatstone bridge so the output is a single analog voltage proportional with the sum of weights on all four sensors. They do not need individual readings /HX711 for each load cell.

However by measuring multiple points, more detailed movement patterns could be detected, which might be useful to figure out "something could be wrong" with a cat.

monkeyfork
Posts: 62
Joined: Tue Oct 29, 2013 10:14 am
Location: orlando

Re: catPooPee

Sun Mar 10, 2019 1:17 pm

thx blimpyway for comments, all analyzed and weighted ))

here is the latest shiny redirection and unintended consequence of my folly.
http://dabeak.com/catGridPee_IMG_20190222_164510~2.jpg

so far tentative name of this increment is "gridPee". There is a dual intent
1- move toward reuseable - renewable -destinkable litter
2- make easier to take urine sample using the usual litter box and litter when needed (when UTI or other pathology is suspected)

Initial construction is to have plastic grid seen in pix is just standard plastic lighting louvre. Underneath louvre is fiberglass screen material.
Underneath screen is a gap then short drop and sudden stop in bottom collection grid which is another section of same grid at top.

The grid at top will be filled and covered with safflower seeds which supposedly are non absorbing (trust but verify at this point). The top grid is present to keep claws from fiberglas screen. The air gap between screen and bottom collection grid is maintained (against weight of litter and cat) by a grid of ping-pong balls.

The bottom grid will be bottom sealed _somehow_ to form a gridded urine collection area. Viewing the "motion" catPooPee events should provide geolocation(haha) of urine and link to proper PurrrPEEtrator.

All will be documented and engineering data will be available on absolutely no schedule))

monkeyfork
Posts: 62
Joined: Tue Oct 29, 2013 10:14 am
Location: orlando

Re: catPooPee

Fri Mar 15, 2019 8:02 pm

from @Blimpyway comment;
However by measuring multiple points, more detailed movement patterns could be detected, which might be useful to figure out "something could be wrong" with a cat.
is intriguing idea. I actually went with the multiple weight measurement points because it was the path of least resistance that I had confidence in. I really don't like the comsumer scale method of combining 4 load cells into one wheatstone bridge. Also the load cells I'm using each come with a instrumentation amplifer at minimal cost (5kg LC plus amp ~ $5). Now that Blimpyway mentions the possible cat-diagnostic upside to having some AI analyze a cat's scratching, circling, prancing I want to keep the multiple weight points for sure.

I'm refining my data collection now and trying to come up with way to take a continuous baseline at a low sample rate (because baseline drifts A-LOT) then switch to a higher sample rate during a poo-pee-event and have each sample be time stamped to correlate with the avi's and jpg's
of the event.

so faithful readers... if I make a dataset available that contains a full pi-poo-pee event could someone smarter than me (low bar) play with analyzing. Indicate your willingness here and I'll try to make it happen sooner rather than later.

monkeyfork
Posts: 62
Joined: Tue Oct 29, 2013 10:14 am
Location: orlando

Re: catPooPee

Sat Mar 16, 2019 6:23 pm

quick n' dirty block diagram of catPooPee as it exists now.
http://dabeak.com/catPooPee_block_diagram.svg.png

I have two litter boxes that record motion video but only one has litter box weight instrumentation. The central server pulls accumulated motion avi/jpg on daily basis by a script that does mostly scp then purges via remote cli. The script is now manually run but will be cron soon.

monkeyfork
Posts: 62
Joined: Tue Oct 29, 2013 10:14 am
Location: orlando

Re: catPooPee

Mon Mar 18, 2019 6:29 pm

For anyone who like playing with datasets, here is a pee-event.
http://dabeak.com/cPP_piffy_peeEvent_18mar2019.tar.gz
Lab assistant Piffy-the-cat was chunked into the litter box for a functional check of the load-cell recording hardware/software. Evidently she decided to enhance the experiment by relieving herself, how accommodating!

So in the tarball you'll find a single avi of the event, the sequence of jpgs and a text file. The text file contains single line samples that's roughly;
<time as milliseconds since epoch> <date in application "motion" format> <clock-time>: <LoadCell#1sample> <LC#2samp> <LC#3samp>. For this stage of development, I'm keeping the jpgs in hopes that it's more robust to detect the colored-collar of the cats using openCV on static images.

The load cell samples are just raw output of signed 24bit digitizer (it's a differential voltage so can go + or - ). The transfer function from bits to grams is not apparent at this time (cheapie chinese load-cells kinda weak on docs).

Happy number mashing! (comments very welcome, analyzing data makes my noodle wobble... not overburdened with intelligence)

Return to “Advanced users”