Coder Social home page Coder Social logo

tw1ddle / geometrize-lib-example Goto Github PK

View Code? Open in Web Editor NEW
13.0 4.0 2.0 8.69 MB

Minimal example using the Geometrize library, a tool for geometrizing images

Home Page: https://www.geometrize.co.uk/

License: MIT License

QMake 0.15% C 96.88% C++ 2.97%
art geometry-processing hill-climbing geometrize

geometrize-lib-example's Introduction

Geometrize library example logo

License Build Status Badge

Minimal example of the Geometrize library, the library used in the image-to-shapes conversion app Geometrize.

Usage

Copy the binary to the sample images folder and start geometrizing some images via the command-line.

# Create an image made of 500 rotated rectangles
geometrize_lib_example -i monarch_butterfly.png -o monarch_butterfly_out.png -t rotated_rectangle -s 500

Geometrize Monarch Butterfly Example

# Create an image made of 400 circles
geometrize_lib_example -i sliced_fruit.png -o sliced_fruit_out.png -t circle -s 400

Geometrize Fruit Example

# Create an image made of 400 rotated ellipses
geometrize_lib_example -i pomegranate_splitting.png -o pomegranate_splitting_out.png -t rotated_ellipse -s 400

Geometrize Pomegranate Example

# Create an image made of 300 triangles
geometrize_lib_example -i grapefruit.png -o grapefruit_out.png -t triangle -s 300

Geometrize Grapefruit Example

# Create an image made of 300 ellipses
geometrize_lib_example -i hot_air_balloon.png -o hot_air_balloon_out.png -t ellipse -s 300

Geometrize Hot Air Balloon Example

# Create an image made of 500 rectangles
geometrize_lib_example -i sunrise_at_sea.png -o sunrise_at_sea_out.png -t rectangle -s 500

Geometrize Sunrise At Sea Example

# Create an image made of 5000 polylines
geometrize_lib_example -i sundaes.png -o sundaes_out.png -t polyline -s 5000

Geometrize Sundaes Example

# Create an image made of 4000 quadratic beziers
geometrize_lib_example -i jammy_biscuit.png -o jammy_biscuit_out.png -t quadratic_bezier -s 4000

Geometrize Jammy Biscuit Example

# Create a JSON data file defining 400 circles that make up an image
geometrize_lib_example -i sliced_fruit.png -o sliced_fruit_out.json -t circle -s 400
# Create a SVG image file consisting of 400 circles 
geometrize_lib_example -i sliced_fruit.png -o sliced_fruit_out.svg -t circle -s 400
# Create an SVG image file consisting of 200 circles, ellipses and rotated rectangles
geometrize_lib_example -i sliced_fruit.png -o sliced_fruit_out.svg -t "circle ellipse rotated_rectangle" -s 200

Options

Flag Description Default
i The filepath to load the input image from n/a
o The filepath to save the output image, JSON data or SVG n/a
t The types of shapes to use One or more of: rectangle, rotated_rectangle, triangle, ellipse, rotated_ellipse, circle, line, quadratic_bezier, polyline
s Number of shapes to use in the output image 250
c The number of candidate shapes per shape added to the output image 500
m The maximum number of times to mutate each candidate shape 100
a The opacity (0-255) of each shape added to the output image 128

Notes

  • Got an idea or suggestion? Open an issue or send Sam a message on Twitter.

geometrize-lib-example's People

Contributors

tw1ddle avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

geometrize-lib-example's Issues

Build for Ubuntu fails

Build started
2git clone -q --branch=master https://github.com/valeriyvan/geometrize-lib-example.git /home/appveyor/projects/geometrize-lib-example
3git checkout -qf 6ba8b57
4Running "install" scripts
5git config --global user.name "AppVeyor CI Bot"
6git config --global user.email "[email protected]"
7git submodule update --init --recursive
8Submodule 'lib/args' (https://github.com/Tw1ddle/args) registered for path 'lib/args'
9Submodule 'lib/geometrize' (https://github.com/Tw1ddle/geometrize-lib) registered for path 'lib/geometrize'
10Cloning into '/home/appveyor/projects/geometrize-lib-example/lib/args'...
11Cloning into '/home/appveyor/projects/geometrize-lib-example/lib/geometrize'...
12Submodule path 'lib/args': checked out 'bd0429e91f5bb140271870d5421e412bf78b9f31'
13Submodule path 'lib/geometrize': checked out '9797ccd9deb9ab700d72da65438bb65684c0bb99'
14git submodule update --remote --merge
15if [[ git status --porcelain ]]; then
16 git checkout master
17 git add lib/geometrize
18 git commit --message "Build bot updating submodule"
19 git remote rm origin
20 git remote add origin https://${GITHUB_API_KEY}@github.com/Tw1ddle/geometrize-lib-example.git > /dev/null 2>&1
21 git push origin master
22fi
23
24sudo apt update -qq --yes --force-yes
25103 packages can be upgraded. Run 'apt list --upgradable' to see them.
26W: --force-yes is deprecated, use one of the options starting with --allow instead.
27sudo apt install libgl1-mesa-dev --yes --force-yes
28Reading package lists... Done
29Building dependency tree
30Reading state information... Done
31The following additional packages will be installed:
32 libegl-dev libgl-dev libgles-dev libgles1 libgles2 libglvnd-dev libglx-dev libopengl-dev libopengl0
33The following NEW packages will be installed:
34 libegl-dev libgl-dev libgl1-mesa-dev libgles-dev libgles1 libgles2 libglvnd-dev libglx-dev libopengl-dev libopengl0
350 upgraded, 10 newly installed, 0 to remove and 103 not upgraded.
36Need to get 254 kB of archives.
37After this operation, 2888 kB of additional disk space will be used.
38Get:1 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 libglx-dev amd64 1.3.2-1ubuntu0.20.04.2 [14.0 kB]
39Get:2 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 libgl-dev amd64 1.3.2-1
ubuntu0.20.04.2 [97.8 kB]
40Get:3 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 libegl-dev amd64 1.3.2-1ubuntu0.20.04.2 [17.2 kB]
41Get:4 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 libgles1 amd64 1.3.2-1
ubuntu0.20.04.2 [10.3 kB]
42Get:5 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 libgles2 amd64 1.3.2-1ubuntu0.20.04.2 [15.6 kB]
43Get:6 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 libgles-dev amd64 1.3.2-1
ubuntu0.20.04.2 [47.9 kB]
44Get:7 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 libopengl0 amd64 1.3.2-1ubuntu0.20.04.2 [29.2 kB]
45Get:8 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 libopengl-dev amd64 1.3.2-1
ubuntu0.20.04.2 [3584 B]
46Get:9 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 libglvnd-dev amd64 1.3.2-1ubuntu0.20.04.2 [11.6 kB]
47Get:10 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 libgl1-mesa-dev amd64 21.2.6-0ubuntu0.1
20.04.2 [6420 B]
48Fetched 254 kB in 0s (1032 kB/s)
50Selecting previously unselected package libglx-dev:amd64.
51(Reading database ... 285688 files and directories currently installed.)
52Preparing to unpack .../0-libglx-dev_1.3.2-1ubuntu0.20.04.2_amd64.deb ...
53Progress: [ 0%] [..........................................................................................................................................................................................................................] Progress: [ 2%] [#####.....................................................................................................................................................................................................................] Unpacking libglx-dev:amd64 (1.3.2-1
ubuntu0.20.04.2) ...
54Progress: [ 5%] [##########................................................................................................................................................................................................................] Selecting previously unselected package libgl-dev:amd64.
55Preparing to unpack .../1-libgl-dev_1.3.2-1ubuntu0.20.04.2_amd64.deb ...
56Progress: [ 7%] [###############...........................................................................................................................................................................................................] Unpacking libgl-dev:amd64 (1.3.2-1
ubuntu0.20.04.2) ...
57Progress: [ 10%] [#####################.....................................................................................................................................................................................................] Selecting previously unselected package libegl-dev:amd64.
58Preparing to unpack .../2-libegl-dev_1.3.2-1ubuntu0.20.04.2_amd64.deb ...
59Progress: [ 12%] [##########################................................................................................................................................................................................................] Unpacking libegl-dev:amd64 (1.3.2-1
ubuntu0.20.04.2) ...
60Progress: [ 15%] [###############################...........................................................................................................................................................................................] Selecting previously unselected package libgles1:amd64.
61Preparing to unpack .../3-libgles1_1.3.2-1ubuntu0.20.04.2_amd64.deb ...
62Progress: [ 17%] [#####################################.....................................................................................................................................................................................] Unpacking libgles1:amd64 (1.3.2-1
ubuntu0.20.04.2) ...
63Progress: [ 20%] [##########################################................................................................................................................................................................................] Selecting previously unselected package libgles2:amd64.
64Preparing to unpack .../4-libgles2_1.3.2-1ubuntu0.20.04.2_amd64.deb ...
65Progress: [ 22%] [###############################################...........................................................................................................................................................................] Unpacking libgles2:amd64 (1.3.2-1
ubuntu0.20.04.2) ...
66Progress: [ 24%] [#####################################################.....................................................................................................................................................................] Selecting previously unselected package libgles-dev:amd64.
67Preparing to unpack .../5-libgles-dev_1.3.2-1ubuntu0.20.04.2_amd64.deb ...
68Progress: [ 27%] [##########################################################................................................................................................................................................................] Unpacking libgles-dev:amd64 (1.3.2-1
ubuntu0.20.04.2) ...
69Progress: [ 29%] [###############################################################...........................................................................................................................................................] Selecting previously unselected package libopengl0:amd64.
70Preparing to unpack .../6-libopengl0_1.3.2-1ubuntu0.20.04.2_amd64.deb ...
71Progress: [ 32%] [#####################################################################.....................................................................................................................................................] Unpacking libopengl0:amd64 (1.3.2-1
ubuntu0.20.04.2) ...
72Progress: [ 34%] [##########################################################################................................................................................................................................................] Selecting previously unselected package libopengl-dev:amd64.
73Preparing to unpack .../7-libopengl-dev_1.3.2-1ubuntu0.20.04.2_amd64.deb ...
74Progress: [ 37%] [###############################################################################...........................................................................................................................................] Unpacking libopengl-dev:amd64 (1.3.2-1
ubuntu0.20.04.2) ...
75Progress: [ 39%] [#####################################################################################.....................................................................................................................................] Selecting previously unselected package libglvnd-dev:amd64.
76Preparing to unpack .../8-libglvnd-dev_1.3.2-1ubuntu0.20.04.2_amd64.deb ...
77Progress: [ 41%] [##########################################################################################................................................................................................................................] Unpacking libglvnd-dev:amd64 (1.3.2-1
ubuntu0.20.04.2) ...
78Progress: [ 44%] [###############################################################################################...........................................................................................................................] Selecting previously unselected package libgl1-mesa-dev:amd64.
79Preparing to unpack .../9-libgl1-mesa-dev_21.2.6-0ubuntu0.120.04.2_amd64.deb ...
80Progress: [ 46%] [#####################################################################################################.....................................................................................................................] Unpacking libgl1-mesa-dev:amd64 (21.2.6-0ubuntu0.1
20.04.2) ...
81Progress: [ 49%] [##########################################################################################################................................................................................................................] Setting up libopengl0:amd64 (1.3.2-1ubuntu0.20.04.2) ...
82Progress: [ 51%] [###############################################################################################################...........................................................................................................] Progress: [ 54%] [####################################################################################################################......................................................................................................] Setting up libgles2:amd64 (1.3.2-1
ubuntu0.20.04.2) ...
83Progress: [ 56%] [##########################################################################################################################................................................................................................] Progress: [ 59%] [###############################################################################################################################...........................................................................................] Setting up libgles1:amd64 (1.3.2-1ubuntu0.20.04.2) ...
84Progress: [ 61%] [####################################################################################################################################......................................................................................] Progress: [ 63%] [##########################################################################################################################################................................................................................] Setting up libglx-dev:amd64 (1.3.2-1
ubuntu0.20.04.2) ...
85Progress: [ 66%] [###############################################################################################################################################...........................................................................] Progress: [ 68%] [####################################################################################################################################################......................................................................] Setting up libopengl-dev:amd64 (1.3.2-1ubuntu0.20.04.2) ...
86Progress: [ 71%] [##########################################################################################################################################################................................................................] Progress: [ 73%] [###############################################################################################################################################################...........................................................] Setting up libgl-dev:amd64 (1.3.2-1
ubuntu0.20.04.2) ...
87Progress: [ 76%] [####################################################################################################################################################################......................................................] Progress: [ 78%] [##########################################################################################################################################################################................................................] Setting up libegl-dev:amd64 (1.3.2-1ubuntu0.20.04.2) ...
88Progress: [ 80%] [###############################################################################################################################################################################...........................................] Progress: [ 83%] [####################################################################################################################################################################################......................................] Setting up libgles-dev:amd64 (1.3.2-1
ubuntu0.20.04.2) ...
89Progress: [ 85%] [##########################################################################################################################################################################################................................] Progress: [ 88%] [###############################################################################################################################################################################################...........................] Setting up libglvnd-dev:amd64 (1.3.2-1ubuntu0.20.04.2) ...
90Progress: [ 90%] [####################################################################################################################################################################################################......................] Progress: [ 93%] [##########################################################################################################################################################################################################................] Setting up libgl1-mesa-dev:amd64 (21.2.6-0ubuntu0.1
20.04.2) ...
91Progress: [ 95%] [###############################################################################################################################################################################################################...........] Progress: [ 98%] [####################################################################################################################################################################################################################......] Processing triggers for libc-bin (2.31-0ubuntu9.9) ...
93W: --force-yes is deprecated, use one of the options starting with --allow instead.
94export PATH=$HOME/Qt/6.1/gcc_64/bin:$PATH
95Running "before_build" scripts
96cd $HOME/Qt
97ls -a
98. .. 5.15 5.15.2 6.2 6.2.4 6.3 6.3.1 6.4 6.4.0 Docs Examples Licenses Tools latest
99cd $APPVEYOR_BUILD_FOLDER
100qmake geometrize-lib-example.pro
101/opt/appveyor/build-agent/bash-shell.sh: line 51: qmake: command not found
102Command exited with code 127
103Build failed

Using multiple shape types?

The desktop app allows for multiple shape types to be used when processing an image - is that something the lib version can do? Ideally I want to use all of them!

thread question

First of all thanks for your work and for this great library! I find that thread doesn't work properly. As the number of threads increases, the time consuming becomes longer. (-s 1 -t rotated_ellipse -c 100 -m 10) 0.02s(maxthreads=1) 0.07s(maxthreads=2) 0.297074s(maxthreads=4) . And my *pro file is
"""
include(lib/geometrize/geometrize/geometrize.pri)

CONFIG -= qt
CONFIG += warn_on console c++11

TARGET = geometrize_lib_example

HEADERS += lib/args/args.hxx
lib/stb/stb_image.h
lib/stb/stb_image_write.h

SOURCES += main.cpp
"""
Thanks for you help!!!

short ?ions

Hey Sam,

First of all thanks for your work and for this great library! I discovered primitive and geometrize some weeks ago and been trying out your library ever since. really nice stuff!
This is not an issue really but I just have some short questions for you so feel free to close anytime.

  • Since i work mostly in R and there is a seamless R<-->C++ integration through a package called Rcpp - i've been thinking to try my hand at writing R bindings for your cpp lib (if that is ok with you).
    I've never done this before, and don't know much c++ but would like to learn more and thought this would be a great motivation for me to finally dig more into this.

  • I was wondering if one can do static animations in geometrize like in this primitive example?

thanks again for all your work.
all the best,
david

Cannot find any binary in the bucket

Hi,

Wow, this is an impressing project!

Could you tell me if this is still possible to get a binary version of that cli (OSX) ? I am very interested in trying it!

Thanks a lot,
Léon

SVG output is empty

Hey Sam,

first of all congrats on your awesome project! I used your tool on various occasions - I even designed the gift card for my sisters marriage by merging together vectorized images!

My issue

When running packaged binary for Linux (geometrize_lib_example_248_linux_clang++-3) the png output works just fine. But for the SVG output is always empty - only with the root element. Have I missed some dependency or can you hint me on how to debug it? The running binary doesn't output the Failed to write SVG file to: defined in the main.cpp.

<?xml version="1.0" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.2" baseProfile="tiny" width="512" height="384" viewBox="0 0 512 384">

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.