Giter Site home page Giter Site logo

pixel_to_svg's Introduction

This is a simple unsupervised segmentation based method for turning a raster image into SVG.

How to install?

You first need to install pypotrace.

Here are the steps to install pypotrace:

  1. sudo apt-get install build-essential python-dev libagg-dev libpotrace-dev pkg-config
  2. git clone https://github.com/mehdidc/pypotrace
  3. cd pypotrace
  4. git checkout to_xml
  5. rm -f potrace/*.c potrace/*.cpp potrace/agg/*.cpp potrace/*.so potrace/agg/*.so
  6. pip install .

Once pypotrace is available, you can install this repo. Here are the steps:

  1. git clone https://github.com/mehdidc/pixel_to_svg
  2. cd pixel_to_svg
  3. python setup.py install

How to use ?

Please check the example in https://github.com/mehdidc/pixel_to_svg/tree/master/examples

pixel_to_svg's People

Contributors

mehdidc avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

pixel_to_svg's Issues

run simple.py

Dear Author:

$ python3 simple.py
Traceback (most recent call last):
  File "simple.py", line 25, in <module>
    svg = to_svg(img, seg)
  File "/usr/local/lib/python3.8/dist-packages/pixel_to_svg-0.1.0-py3.8.egg/pixel_to_svg/pixel_to_svg.py", line 35, in to_svg
  File "/usr/local/lib/python3.8/dist-packages/pixel_to_svg-0.1.0-py3.8.egg/pixel_to_svg/pixel_to_svg.py", line 121, in binary_image_to_svg2
  File "/usr/local/lib/python3.8/dist-packages/svgpathtools/svg_to_paths.py", line 217, in svg2paths2
    return svg2paths(svg_file_location=svg_file_location,
  File "/usr/local/lib/python3.8/dist-packages/svgpathtools/svg_to_paths.py", line 144, in svg2paths
    if os_path.dirname(svg_file_location) == '':
  File "/usr/lib/python3.8/posixpath.py", line 152, in dirname
    p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not _io.StringIO

When I run simple.py, the above error appears...

Error installing pypotrace

Hi!
When I try to run pip install . in pypotrace
I get the following error:

 Error compiling Cython file:
    ------------------------------------------------------------
    ...
                self._data = value
                # Init potrace bitmap struct
                self.po_bitmap.w = self._data.shape[1]
                self.po_bitmap.h = self._data.shape[0]
                self.po_bitmap.dy = (self.po_bitmap.w + (
                    (N - (self.po_bitmap.w & (N - 1))) & (N - 1))) / N
                                                                   ^
    ------------------------------------------------------------
    
    potrace/_potrace.pyx:130:63: Cannot assign type 'double' to 'int'
    
    Error compiling Cython file:
    ------------------------------------------------------------
    ...
    cdef void setpixel(potrace_bitmap_s *bmp, int x, int y, int on):
        """
        Set a pixel on or off in a potrace_bitmap_s.
        """
        if on:
            bmp.map[y*bmp.dy + x/N] |=  (1uL << (N - 1 - x % N))
                   ^
    ------------------------------------------------------------
    
    potrace/_potrace.pyx:377:15: Invalid index type 'double'
    
    Error compiling Cython file:
    ------------------------------------------------------------
    ...
        Set a pixel on or off in a potrace_bitmap_s.
        """
        if on:
            bmp.map[y*bmp.dy + x/N] |=  (1uL << (N - 1 - x % N))
        else:
            bmp.map[y*bmp.dy + x/N] &= ~(1uL << (N - 1 - x % N))
                   ^
    ------------------------------------------------------------
    
    potrace/_potrace.pyx:379:15: Invalid index type 'double'
    

I think this is maybe due to version changes? I added an explicit cast to int at every line with issue, which resulted in a functioning installation.

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.