Help with electronic motion counter

Hi there! I have a salvage/reuse warehouse around the corner from ATXHS on Brown Lane. Among many projects, I’m working on ways to save jigsaw puzzles from the landfill. There is some expensive technology that can count or will soon be able to count puzzle pieces but I’m hoping to find an interim solution, something that is cheap, albeit far more time consuming. One thought I’ve had is to use Arduino to build a simple motion sensor. Then someone just has to make sure each time they cross the sensor they have say, 2 pieces - over and back being an accurate count. I know nothing about Arduino so hoping someone in your space might be able to help and or advise.
Sarah Bird
USE2 Austin

PS - for puzzle enthusiasts, I am aware that most puzzles don’t contain the exact number of pieces given on the box. I’ve figured out how to know the exact count so down to making sure I can count accurately!


Hey Sarah,

It sounds like you might need some machine learning model doing image recognition to identify each puzzle piece as it goes by, does that sound like what you’re aiming for? I don’t have much experience with arduino either, but I have done a little image recognition modeling, so may be able to point in the right direction if that’s the route you’re taking.

1 Like

Arduino won’t have the compute to do something advanced like image recognition. However, a raspberry pi or computer or smartphone would certainly be able to do the trick.

What you want to do is complex, but what I would recommend is:

  1. Take an image of all pieces on a white background, with separation between the pieces
  2. Have a python program that:
    1. Turns the color image into black/white
    2. Applies a gaussian blur to the image
    3. Apply a threshold to the image, so that ideally there is just black on where the pieces are
    4. Use opencv’s findContours function to get the border between the pieces and the background
    5. Then I think you can just check the length of the returned contours array to get the length. You may need to post processing additionally to remove false positives, depending on the camera / lighting
1 Like

@iheartblocks @wynd
I think all she is trying to do is count the number of pieces that are in a box and compare that to what that number is supposed to be. That would mean that the puzzle has all the pieces and can be resold or donated as complete.

Yes it is possible for puzzles pieces getting mixed up in different boxes but I don’t think that is the main goal/concern as I read it.


My posted solution (or, at least, hint to a solution) was for finding the number of pieces in the box. Happy to elaborate if desired

1 Like