Posts Tagged ‘Computer Vision’

h1

Circle clockwise three times

August 14, 2014

I mentioned that I’m working on a Raspberry Pi project with video. It wasn’t going well.

I started with Python + SimpleCV because it looked easy and fun but then determined that frame rates of six frames per second would make it hard to show moving things. So I went a more native option: cross compiled C with OpenCV.

The problem with this path is that it feels like work.

While I strongly believe in life outside tech, I do some personal engineering-related projects. I consider the podcast my main personal project. But Element 14 has graciously been sending me hardware and the occasional check to write for them. This arrangement lets me learn new things and share my enthusiasm. It is pretty cool (zOMG, you guys, they pay me to goof off! If I whine enough, they send me even neater hardware! This is such a scam!)

But I do have a day job. Oh, don’t get me wrong, my billable hours are not totaling anywhere near 40. But I could be gardening, reading a book, writing a novel, designing my Halloween costume, or painting the ceiling; I could be doing other amusing things but I’ve opted to work on a technical project because I find it interesting. Getting paid is nice and directs my (often scattered) attention but it is not a large portion of my income (thus it is not motivation enough).

Having a project lose the joy of discovery and become a grind is not good for its prospects of completion. (Though I am excited about the end widget. But maybe it would be easier to do on my laptop. But then it isn’t embedded. Maybe there is an 8-bit microcontroller out there that needs me to do something with it. You know, my Halloween costume is likely to be pretty technical…)

Doing a project in Python on the Raspberry Pi is fun: hack it together, do a little experimentation, call it done enough, maybe revisit in a few weeks.  But it didn’t work, too slow. And then cross compiling and C felt workish, especially the starting over part. I actually had some things working in Python. I fought the evil of Linux video drivers. I learned about computer vision libraries too. It was fun in Python.

It was less fun in C. Though, realistically, I haven’t gotten to do much C, mostly build nonsense. But SimpleCV looks friendlier than OpenCV.

Imagine my disappointment to read that I can only expect ten frames per second in the C+OpenCV version. I don’t know how I missed that. It seems impossible. There is rasppivid video that is 30 fps, why can I get to something like 25? Oh, I know there is hardware acceleration and blah. blah, blah. But I want it. I want it more than they do. (Hey, you did read my Guardians review, right?)

So now I’ve found a different Python package, one with better Pi Camera integration. It is even linked from the Raspberry Pi Camera page. (Was it there before and I missed it? The idea of that makes me feel slightly insane. I looked around A LOT for Pi Camera stuff before deciding to leave Python).

The Camera Modes documentation shows some high frame rates.  The text later talks about all the interesting ways users can mess that up. And there is a section for rapid capturing and processing though I wasn’t clear that I could display them too. It would be interesting to try.

Ok, I think that, yes, I am going to restart the project but back to Python. All the paths are frustrating. But Python has the most potential for amusement and the chance that I’ll get beyond fighting tools and back to playing with gear. I hope.

 

h1

Here’s how you can’t do it too!

August 7, 2014

I just cross compiled an application for Raspberry Pi: camcv combines the Pi’s camera program raspivid with OpenCV.

It took hours and hours. Not just to build the cross compilers (though that did hours) and figure out cmake and figure out what code I needed, it took hours of tweaking and fiddling to make it work.

I suppose now I’m supposed to write up how I accomplished it, so you can reproduce it, glossing over the tricky bits and making it sound like a walk in the park.

First, I must give credit to

Well, and to be fair, I’m still at Step 3 of OpenCV and Pi Camera’s instructions (of 7 (and a half)). I finally got the program to compile but I have a new Raspberry Pi board and haven’t even powered it on. Oh heck, if I’m reading step 4 correctly, I haven’t actually managed to pull in OpenCV.

I had this neat plan for what to do with the Pi, a camera (two maybe!), and a small display. But I’ve been so battered by compiling something that already existed and isn’t even really what I meant to compile anyway.

I find that many Linux projects have this exponentially expanding scope. My initial initial plan was to play with the camera in python using the actually pretty simple SimpleCV computer vision tools. But it was horrifically slow (a known issue to people who have tried the python and camera but a new issue to a newbie like me).

Worse, I don’t know cross-compiling has been truly worth it. Is multiple hours of setup worth many times two minutes of recompile time? Also, the RPi Compute doesn’t have an Ethernet port so it isn’t as easy to set up a tftp that would all my device access to the cross compiled executables without even a scp copy.

So I’m not going to give you the “here’s how I did it”… I’m not even sure how to post my trees. And I went through so many strange turns, I’m not sure my results will be useful (“and then at step 1123, spin in your chair, clockwise three times, the next cmake .; make instruction will then work”).