top of page
  • Writer's picturerbdlab haifa

Lego Sorting using Robotic Arm


Sorting Legos was always a problem as a kid, so we made a robot that could do it for us!

The Lego Sorter organize legos by color using a webcam and a robotic arm, using computer vision algorithms. the webcam take capture for the Lego pieces, then, using image processing algorithms we locate the centers of the pieces for each color separately, and let the arm pick them up(using magnet) . the project can be utilized (with slight modification) for other sorting tasks.


project Flow 1) The robot arm go to capture position and take a picture. 2) Separate the image for two images (blue and red) using Image Thresholding. For every image: 3) Find the Legos using cv::findcontours(). 4) Find centers of Legos . 5) Calculate the coordinates of the object according to the robot arm coordinates. 6) The arm pick them up(using magnet) . The program is written in QT editor, C++, with using OpenCV library. For the code contact us. code:

bottom of page