Giter Club home page Giter Club logo

embroidery-vision's Introduction

End to end image tests

🧵 embroidery-vision

My blog post: Computer Vision and Embroidery


A CLI for finding the approximate embroidery floss colours from an image of an embroidery hoop.

OpenCV is used to locate the hoop area then the color space is reduced and matched to the limited set of DMC colors (see dmc.csv). A color palette is generated with the DMC identification number attached to each color.

In order to find the hoop area, a series of destructive filters are used — the image is converted to gray and then the following are applied: GaussianBlur, medianBlur, adaptiveThreshold, erode, dilate. As we see below, this makes the hoop more identifiable to the circle Hough transform.

Usually, multiple circles are found but the largest and most central one is chosen. This logic was chosen after reviewing ~100 of the latest posts to r/embroidery.

To find the colors, the area is quantized and then the nearest color is looked up in a cached k-d tree of DMC colors. The lower occuring colors are filtered out from the palette.

Usage

Tested with Python 3.8.

pip install -r requirements.txt

pip install -r requirements-dev.txt

$ python cli.py  -h
usage: cli.py [-h] [--output file.jpg] [--debug] file.jpg

Get a DMC color palette for an image of an embroidery hoop.

positional arguments:
  file.jpg           an input file.

optional arguments:
  -h, --help         show this help message and exit
  --output file.jpg  an output file.
  --debug            set debug mode. Saves debug files to current directory.

Limitations

This program doesn't take lighting conditions into account and doesn't filter out the base material (it thinks the background is another thread) so the accuracy is low.

Tests

python -m unittest discover test/

mypy .

License

MIT.

embroidery-vision's People

Contributors

healeycodes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.