We’re on a sort of vacation in Tanzania at the moment and staying in a modest hotel away from the tourist and government district. It’s a district of small shops selling the same things and guys repairing washing machines out on the sidewalk. The men repairing washing machine are happy to chat. Everybody’s amazingly friendly here, the hotel guy grilled us for an hour about our home state. But I really didn’t expect to end up in a conversation about computer vision.
We went for a walk to find some yogurt, and perhaps something cooler to wear. A robotics shop was just a few streets away. Mecktonix has a store about 2 meters long, with Arduinos robots electronics components servos random computer gear. [Yohanna “Joe” Harembo]. A 3D printer, laser engraver, and other equipment are located nearby. The tiny space doesn’t stop them from being busy. The National Institute of Transport is nearby and a constant stream of automotive students from that institute shuffles in for advice or parts for class assignments.
In between students, Joe demos an autonomous car he’s working on. In classic hacker fashion, he first has to reattach the motor driver board and various sensors, but then he demos the car and its problem – the video frame rate is very slow. We jump in and use profiling to try and get him going. time.monotonic_ns()
. He’s never done profiling before, so this is a big eye opener. He’s only processing one video frame every 4.3 seconds, using YOLO on a Pi 3, and yup, that’s the problem. I suggest that he switch to gamut detection, or use a Pi 4
Gamut Detection
If you’re not familiar with gamut detection, it’s one of the simplest of all computer vision techniques, so it’s easy to implement on slow processors and almost trivial to code. Basically, it’s “look for a color”. Wear a lime-green T shirt if you want the robot to follow. Now, the robot only has to search for green. It’s the same for catching or following lines, or a ball. The algorithm is simple – convert each pixel to HSV, where hue corresponds to the direction around the color wheel, saturation corresponds to how concentrated the color is, and value how bright. As brightness depends on the lighting conditions, we can just limit H and S. Everything within these limits will be part of our goal. The box formed by those limits is our “gamut”.
You can also apply a few speedups. Ask yourself what resolution you require from the camera. If you only want to track a green T shirt that’s never less than 24 pixels on screen, turn the resolution down by a factor of six each way and look for four-pixel T shirts. Your algorithm will run 36 times faster because you only have to process 1/36th of the data. If you can’t control the camera resolution, you can shrink the image or just sample every nth pixel. You can also ask the camera for a YUV image or a YIQ. You can set your limits by IQ coordinates or UV coordinates. It’s about the same as HSV.
Joe’s eating this up – he’s had limited chances to talk with somebody else who is into computer vision. As we write this, he’s still trying with YOLO, but at lower resolution. If it doesn’t work he’ll try gamut detection. And it’s not his only project. Pikipikis (motorcycles with passenger carrying) are commonly seen in the Philippines. A student has a project to enforce passengers wearing a helmet, and we fiddle with the student’s project.
Dar es Salaam Scene
There’s other tech happening in Tanzania too. Only a few streets away is [Ruta Electronics], a similar sugar cube sized shop developing smart meters. In this tiny shop, everything from PCBs to cases is produced. In the center of town, there are several startups. There’s a fab lab, mostly oriented towards children. And on a quiet side street off the main drag, there’s a tiny shop with three guys who are hacking like crazy.
For us, we’ve had a chance to make a friend from a different culture and play with a robot car together — what could be better? When you’re traveling, are you on the lookout for other hackers or hackerspaces? It’s worth the effort and brings our community together in a way that even the internet can’t.