The sharpest photo of the night was a brick
The original idea was to wake up and find out who came by while we were asleep. It took two months to get to it, and then most of the work went into defining what counts as the good picture.
The whole pitch, back at the start, was to point a camera at the yard and have it tell me who came by while we were asleep. Everything since then has been groundwork. Species, individuals, clips, the dashboard.
It took two months to get around to building the actual thing I asked for. It has been sending since the middle of August.
At seven in the morning I get who came by overnight, the best photograph of the night, and a link through to the highlight reel. The email does no analysis of its own. The dashboard already works out that story for every completed night, and the email is a thin layer on top that lays it out like a small newspaper and posts it. If the two ever disagree, the email is the one that is wrong.
Picking the cutest photo, not the sharpest
The first version led with the sharpest frame of the night.
What that gets you is a beautifully focused brick paver with a motion-blurred raccoon draped across it. The camera had focused on the bricks.
So it stopped scoring sharpness and started scoring how cute the animal is, which sounds like a joke. It comes down to four things:
- How much of the frame the animal fills, but peaked rather than more-is-better. Past about a third of the frame you are not looking at a portrait, you are looking at a body part. One night’s highest-scoring candidate by size was a tail taking up 93% of the picture.
- Whether the focus is on the animal or on the yard behind it. It compares the sharpness in the middle of the crop against the ring around the edge. If the ring wins, the camera focused on the wall.
- Eyeshine, as a rough guess at whether the animal is facing the camera.
- A nudge for somebody we know by name, because a raccoon with a name is better news than an anonymous one.
The eyeshine part had to be walked back almost immediately. The first version handed out its full bonus to any bright pixels in a dark crop, and what won was a raccoon backside under the infrared floodlight, where the fur blows out to white across a third of the frame. Eyes are specks. So now a large bright area gets nothing, and only small ones count.
Getting the email to send
The send broke early on with 403 error code: 1010.
That reads exactly like a rejected API key, so I went and checked the key. Then checked it again. The key was fine the whole time.
The mail service sits behind Cloudflare, and Cloudflare blocks Python’s default Python-urllib/3.x user agent before the request ever reaches the service being called. Setting our own user agent string cleared it.
The photos come as attachments instead of links, because the dashboard’s image URLs only exist on my home network and Gmail’s image proxy can never reach them, and Gmail throws away images embedded directly in the HTML. Attachments were the only way that worked.
So now I read it with coffee instead of opening the site, and I send her the good ones.
all Critter Cam updates