Computer Vision with the Raspberry Pi

Computer Vision with the Raspberry Pi

A recent development fresh out of CAROBOT is the involvement of computer vision with a Raspberry Pi and Python. Using the open-source library for computer vision – OpenCV – and a Pi Camera attached, the beginnings of a program to help the Pi understand what it’s seeing is taking shape.

So far, the Pi – using the camera attached – can read in the feed of what it’s seeing at a specified resolution. What our program intends to do is to analyze what it’s seeing in every single frame before moving onto the next. This clearly gates high FPS (Frames Per Second) if there are more computationally intensive operations going on with each analysis, so the resolution should remain small and the operations be kept simple.

As a part of the analysis, it reads in the 2D array of pixels of each frame, with each pixel assigned a specific RGB (Red-Green-Blue) value. Using functions from the OpenCV library, we can create contour plots of a specified range in colour. Seeing that the intention is to follow a line (namely a black one on a white background), we would want to filter out all the pixels that aren’t extremely dark and keep a sort of ‘map’ of what is dark.

When we filter this out, we create an outline of areas that are black – these are contours! Using other functions such as erode() and dilate(), we can clear up ‘noise’ which can be seen by the computer and only interpret the spots of contour that are large and dark. Through use of more functions readily available in OpenCV, we can set up ‘rectangles’ around the contours, such that we can figure out the orientation it has with respect to a vertical line in the center.

Using the rectangles previously used, we can set up motion of the rover based on the orientation and distance to the center, where the motion is based on the need to correct itself and have the line be in the middle of the screen. What’s next is to start incorporating motion and colour detection!

With more to come, the program will be only more polished and well-performing in the future!

SwissCHEESE Robot Car Development

SwissCHEESE Robot Car Development

Hello world! (Cheesy, huh?) As a summer student at CAROBOT Learning and Research Organization, I was tasked with following a modified engineering design process to develop a new car design for the CAROBOT SwissCHEESE Education kits.

SwissCHEESE Robot Car Development

Step 1. Identify Needs

The first step in the modified engineering design process is to find the customer’s needs. Through discussion with my superior, I had come up with the following list of needs:

SwissCHEESE Robot Car Development

Step 2. Establishing Car Specifications

The next step involved creating a list of metrics that helped us quantify our needs.

SwissCHEESE Robot Car Development

Then I came up with a list of marginally accepted and ideal values for our metrics.

SwissCHEESE Robot Car Development

By acknowledging the constraints, I could move on to the next step.

Step 3. Generate Product Concepts

Now came the fun part: producing design sketches.

Concept 1 was the idea of a modular car where certain parts could be exchanged for others. An idea with this concept was the use of slide-in feature where the base carrying the Arduino and breadboard could be slid into a frame. However, this idea was later dismissed because sliding parts are prone to wearing out.

Concept 2 was a minimal design with only the core components attached on the base. These core components included 2 motors, the Arduino and SwissCHEESE boards, a breadboard and a caster.

SwissCHEESE Robot Car Development

Concept 3 was the opposite of the first concept; instead of keeping the flexibility that comes with using multiple parts, the compartment design only would work with components of similar size. The pro of having such a design would be a more rigid model, where parts must stay in the confines of discrete sections.

Concept 4 was based on a DIY car called the Donkey Car. This design would make the car much sturdier in exchange for more material.

Concept 5 was popular with some of the board members. The concept gives the person assembling it creative freedom to place components where they want to. Furthermore, this is a multi-layer concept. The first layer holds the battery, the second layer holds the microcontroller and other electronics parts, and the last layer for customization.

SwissCHEESE Robot Car Development

A final idea was the use of having a sleek-looking car that would have hinges to open the cover. However, the costs would increase because this is a 3D printed design.

SwissCHEESE Robot Car Development

Step 4. Select Product Concepts

I chose concept 2 because of its simplicity, only the base, and two caster attachments needs a laser cutter. Concept 5 was a popular contender, but the hexagonal shape caused the breadboard and battery to jut out at odd angles.

SwissCHEESE Robot Car Development

Step 5. Test Product Concepts

For the chosen concept, I designed the parts using Solidworks and Draftsight.

Note: The caster is not shown in the diagram below as it was difficult to find a solid model of the specific caster used.

SwissCHEESE Robot Car Development

SwissCHEESE Robot Car Development

Step 6. Set Final Specifications

From this model, I noted a few weaknesses. The edges were sharp, and although the board looked aesthetically pleasing, the contours on the sides restricted where the user could place the motor attachments. For the last model, I added a servo slot to the base, rounded the edges, and removed the contour on the sides.

Step 7. Economic Analysis

The cost of the new car is much less than that of the earlier one due to less material being used. That is because the earlier model had two layers, compared to one layer for the new model.

Step 8. Assembling the Car

Some of the parts  in the earlier design were no longer needed, and this resulted in assembly time decreasing. The size of the new base board is around the same as the earlier one.

SwissCHEESE Robot Car Development SwissCHEESE Robot Car Development SwissCHEESE Robot Car Development