Motion detection with the Raspberry Pi, part 1

Okay Declan, let’s try making this post a short and sweet update, not a rambling Homerian epic about simple stuff.

I got a Raspberry Pi (RPi) and an RPi camera because I wanted to learn about them and mess around with them. If I could do image recognition with them, that’d be a good platform to do ML, NN, and if I got enough data, maybe even DS type stuff. Luckily, there’s a ton of resources and code out there already. I drew upon heavily from www.pyimagesearch.com, which is a REALLY useful site, explained very great for beginners. Two articles that I basically copied code from and then butchered were this and this.

He’s not quite doing “image recognition” in this code, it’s more like “difference recognition”. Very simply, he has a stream of frames coming in from the camera. He starts off by taking what will be considered a “background frame”. Then, for all subsequent frames, he subtracts the background from the current frame, and then looks at the absolute difference (all done in grayscale, to make it simpler) of pixels. If two frames were identical, you’d expect very little different. If an object appeared in the new frame, the difference would show that object. Then, he uses some opencv tools to figure out where the object is, and draw a box around it.

I was able to put his code together and run it pretty quickly (though I removed some stuff like uploading it to dropbox, instead doing a kind of naive thing of sending the files via scp to my other machine), producing this gif of local traffic outside my window:

Of course, the devil is in the details. If you watch it a few times, you’ll notice some weird behavior. Most obviously, boxes are detected around the objects, but then the boxes appear to remain where the object was for several frames. Here you can see it frame by frame:

Why does this happen? Well it’s actually a smart feature, but done in a somewhat clumsy way. In his code, he has the following (I combined the few relevant snippets) inside the main frame capturing loop:

if avg is None: print("[INFO] starting background model...") avg = gray.copy().astype("float") rawCapture.truncate(0) continue cv2.accumulateWeighted(gray, avg, alpha) frameDelta = cv2.absdiff(gray, cv2.convertScaleAbs(avg)) read more

Squall Moan: Small Clone clone

squallmoan

Ahhh, where it all started.

I was jamming with a friend in his basement and he had a bunch of pedals, which I was noodling around with. None really stuck out to me until this little guy. If you want a sample of what it sounds like, there are plenty of test drives on YouTube. You may recognize its sound from Nirvana songs (only 90s kids will myeh myeh myeeehhh). read more

The Red Lama (Red Llama clone)

After making the worst fuzz pedal ever and Orange Ya Glad (which was fine, but didn’t add quite as much as I wanted and adds a weird buzz even when you’re not playing on some speakers), I just wanted a normal fuzz pedal. After doing a bit of reading, I found that the Red Llama overdrive pedal (by Way Huge) is a classic, and after watching a few YouTube demos, it seemed good (to be honest, people are crazy about the “different” sounds of various fuzz/distortion/overdrive that various antique/obscure transistors or configurations will give you, but they all sound pretty similar to me, and I suspect people think they’re hearing differences more often than there actually are). read more

A spooOOOOoooky project!

bloodhead1

This is a fun one.

It’s also a testament to how nifty and easy it is to quickly whip up a project with Arduinos, provided you have enough of a “critical mass”, as I’ve called it before, of other stuff that you might end up needing. read more

Back to the blog and the NYC Maker Faire

Hey there, nonexistent reader! You may have (not)iced that I’ve been gone for a while. That’s because I just defended my PhD, and I was pretty balls to the wall busy for the last few months getting ready for that. I made a few posts here and there, but towards the very end I realized I really had no time for a blog that no one reads anyway. Maybe I’ll make a post about the whole before-and-after experience at some point. read more

Low power Arduinos, part 1

pro_mini_led

As part of an ongoing project, I wanted to see how low I could get the power consumption of Arduinos to go. The reason is as follows. When getting back into Arduinos a few months ago, I wanted to try a telemetry project of some sort, collecting data remotely and sending it back. Ideally, the idea would be to collect data from different places and analyze the aggregate in some cool way, but that’s a story for another post. read more

Manual ACKing with the nRF24L01

This one will be very basic to most people who have done this, but it would have been helpful to me when I started with this stuff, so I’m putting it here.

First, a little background:

In the past couple months I’ve been messing around with the nRF24L01 (just gonna call them nRF’s from now on) radio frequency (RF) modules. Arduino hobbyists love them because they’re cheap (it seems like their competitor in this arena were Zigbee chips, which people seem to say are good but very expensive) and relatively versatile and powerful. They operate in the 2.4GHz frequency range and can actually get a pretty hefty amount of range! My roommate and I did a “range test” where I took one nRF that was just spraying out a constant stream of data, and he took another nRF with an LCD attached that displayed the received data. We went to a nearby park, and literally couldn’t get far enough away from each other to make the data stop being collected, which was about 1000′ according to Google Maps. They’re a lot of fun and really open up some project possibilities, which I’ll put here as I do them. read more

Servo controller box

servobox

Woowee, this is a long one.

This is actually something I did for my job. Here’s the deal: I have this electrochemical bath that has a sample in it; one electrode is a piece of graphite, the other electrode is the sample itself. Don’t worry about what the bath does for now, but it’s important that the longer the sample is in the bath, the more the effect of the bath is on the sample. It’s pretty much linear with time. read more

The worst fuzz pedal ever

This thing is such a piece of shit.

I was feeling sorry for myself, so I thought I’d “accomplish” something by making a fuzz pedal. I’ve now been doing this stuff for long enough that I have somewhat of a critical mass of materials, so I have everything I need to make a pretty simple circuit without ordering more things (unless it’s using some weird IC or a whalebone or something). So because there’s no time impediment (waiting for a part to arrive, etc), often I’ll think “hey, I’ll just make a quick little pedal”…and then the next thing I know, it’s 4AM, I’m dizzy from solder fumes, and I’ve made a pedal I don’t need that’s in questionable operation because I’m tired and making mistakes… and it’s generally stupid, is what I’m saying. read more

Orange Ya Glad: first chassis design

The first of many. So, so many.

So I’ve been making these guitar pedals. Ostensibly they’re about cool musical effects, but, let’s be honest: if you’ve seen any of them on the internet, it’s at least half about how they look. People make really fucking cool designs on their guitar pedals. One of my favorite guys who makes cool designs is this guy Cody Deschenes, though he actually does a different design method than I’ve done here (which you’ll see in a future post!). read more