antilobi.blogg.se

Openttd raspberry pi
Openttd raspberry pi














So in other words we will first create a black and white mask image from the frame we are processing and then perform blob detection on the mask. So this means we should somehow isolate the ball (or rather the color of the ball) and then make it black and the background white. OpenCV has a nice function that can do this for us, the only requirement is that it should be a black blob on a white background. Once a blob (or multiple blobs) has been detected you can retrieve some additional information from it, like for example the size of the blob and where in the camera frame it is located. If you haven’t heard of blob detection before, it basically does what it is called, it detects blobs or pixels which are grouped together. So the approach I went with was to do blob detection on each frame that is read from the camera. The servo is held in place by some “soldering helping hands” and I printed a simple bracket to mount the camera to the servo. Power for the servo is taken from the Pi’s 5V output and the servo signal line connected to GPIO12. The camera is a 5MP Raspberry Pi camera by WaveShare and the servo a MG90S by Tower Pro.

OPENTTD RASPBERRY PI CODE

I have commented the code fairly well so will not describe each step, it is actually very self explanatory. To keep it simple I used OpenCV and Python for programming the Pi.

openttd raspberry pi openttd raspberry pi

Once the position of the ball is known, the Pi should also control the servo so that the camera keeps facing the ball.Īfter doing a bit of research on how this can be achieved, I came up with a solution which I will share in this post. The camera together with the Pi should then detect and track a yellow ball within the camera frame. The idea is to just have a Raspberry Pi3 with a camera mounted on top of a small servo. As a prelude to that project and to learn more about what is involved in terms of the image processing I came up with a smaller sub project. In an upcoming project I want to experiment with image recognition and have a balance robot track and follow a colored ball.














Openttd raspberry pi