tux3 / evolve Goto Github PK
View Code? Open in Web Editor NEWImage vectorizer throught evolution
License: MIT License
Image vectorizer throught evolution
License: MIT License
At https://github.com/tux3/Evolve/blob/master/mutation.cpp#L41
QVector::takeAt()
function was introduced in Qt 5.2.
Poly poly = newPolys.takeAt(source);
Equivalent to
Poly poly = newPolys.at(source);
newPolys.remove(source);
Just updated from git. Was a new method implemented? Either the polygon count is bugged and says 5 all the time or maybe it's just using only 5 polygons? When I started the render it jumped up to around 30 but then leveled out to 5.
It would be nice to be able to drag out a bounding box on either the original or best image and have this set as the focus area.
start with a random grid of joined polygons with random colours
move intersection vertices until image matches
creates image with no gaps between polygons and no polygon overlaps
A few things need to be explained to the user, like what the clean and optimize DNA options do.
add opencl acceleration for comparisons, renders and mutations.
add check to make sure polygons have no vertices outside bounding box (same size as original image)
split image into a quadtree of regions with similar detail level
for each region, launch a thread and evolve a solution (give more processor time to more detailed regions)
evolve lots of dna in parallel.
create a generation set with lots of dna strands
mate the most fit dna strands together
mutate the most popular dna strands
I understand this project is probably abandoned but here's a patch if you want to build it in Clang on OS X
Pretty fun
diff --git a/Evolve.pro b/Evolve.pro
index 9ed32f1..b81b409 100644
--- a/Evolve.pro
+++ b/Evolve.pro
@@ -37,5 +37,5 @@ FORMS += widget.ui \
CONFIG += c++11
QMAKE_CXXFLAGS_RELEASE += -O3 -flto -march=native -mmmx # Crashes on some computers
-QMAKE_CXXFLAGS_DEBUG += -Og -g -march=native -mmmx # Crashes on some computers
+QMAKE_CXXFLAGS_DEBUG += -march=native -mmmx # Crashes on some computers
#QMAKE_CXXFLAGS_DEBUG += -Og
diff --git a/settings.cpp b/settings.cpp
index 6eb53ea..20e2bce 100644
--- a/settings.cpp
+++ b/settings.cpp
@@ -1,7 +1,7 @@
#include "settings.h"
bool AUTOFOCUS_ENABLED = false;
-int AUTOFOCUS_SUBDIVS = 4, AUTOFOCUS_DELAY=1000;
+int AUTOFOCUS_DELAY=1000;
int N_POLY_POINTS = 6;
int N_COLOR_VAR = 5;
@@ -9,7 +9,6 @@ int N_POS_VAR = 15;
int SHAPE_OPT_FREQ = 0;
int GUI_REFRESH_RATE = 4;
int AUTOFOCUS_RES = 2;
-int N_CORES = 4;
int FOCUS_LEFT=0, FOCUS_RIGHT=100, FOCUS_TOP=0, FOCUS_BOTTOM=100;
diff --git a/settings.h b/settings.h
index 1f48a06..0c40518 100644
--- a/settings.h
+++ b/settings.h
@@ -2,7 +2,8 @@
#define SETTINGS_H
extern bool AUTOFOCUS_ENABLED;
-extern int AUTOFOCUS_SUBDIVS, AUTOFOCUS_DELAY;
+const int AUTOFOCUS_SUBDIVS = 4;
+extern int AUTOFOCUS_DELAY;
extern int N_POLY_POINTS;
extern int N_COLOR_VAR;
@@ -14,7 +15,7 @@ extern int GUI_REFRESH_RATE;
extern int AUTOFOCUS_RES;
extern int FOCUS_LEFT, FOCUS_RIGHT, FOCUS_TOP, FOCUS_BOTTOM;
-extern int N_CORES;
+const int N_CORES = 4;
extern int POLYS_MIN, POLYS_MAX;
diff --git a/settingswidget.cpp b/settingswidget.cpp
index 83fdafd..aa9d437 100644
--- a/settingswidget.cpp
+++ b/settingswidget.cpp
@@ -64,11 +64,11 @@ void SettingsWidget::okClicked()
FOCUS_BOTTOM = ui->focusBottom->value();
SHAPE_OPT_FREQ = ui->shapeOptFreqSpin->value();
GUI_REFRESH_RATE = ui->guiRefreshSpin->value();
- N_CORES = ui->coreSpin->value();
+ /*N_CORES = ui->coreSpin->value();*/
POLYS_MIN = ui->minPolySpin->value();
POLYS_MAX = ui->maxPolySpin->value();
AUTOFOCUS_ENABLED = ui->autofocusEnable->isChecked();
- AUTOFOCUS_SUBDIVS = ui->autofocusSubdivs->value();
+ /*AUTOFOCUS_SUBDIVS = ui->autofocusSubdivs->value();*/
AUTOFOCUS_DELAY = ui->autofocusDelay->value();
Widget::setAutofocus(AUTOFOCUS_ENABLED);
close();
diff --git a/widget.cpp b/widget.cpp
index 1106e4c..c1c6ab3 100644
--- a/widget.cpp
+++ b/widget.cpp
@@ -3,6 +3,7 @@
#include "settings.h"
#include "settingswidget.h"
#include "analysis.h"
+#include <xmmintrin.h>
#include <QDataStream>
#include <QString>
#include <QPixmap>
@@ -164,8 +165,8 @@ quint64 Widget::computeFitness(const QImage& target)
// Sum of the differences of each pixel's color
for (unsigned j=0; j+8<BPL; j+=8)
{
- __m64 mmOrig = _m_from_int64(*(quint64*)(origData+curLine+j));
- __m64 mmTarget = _m_from_int64(*(quint64*)(targetData+curLine+j));
+ __m64 mmOrig = _m_from_int(*(quint64*)(origData+curLine+j));
+ __m64 mmTarget = _m_from_int(*(quint64*)(targetData+curLine+j));
tmp = _m_psadbw(mmOrig, mmTarget);
mmFitness = _mm_add_si64(mmFitness, tmp);
}
Should be able to stop at a given fitness
ffmpeg -i input.mp4 frame%04d.png
for f in *.png; do
./Evolve "$f"
done
ffmpeg -i %05d.render.png output.mp4
I've been thinking about audio a bit.
Instead of polygons, we could have sounds, each sound would have a waveform (sine, saw, square wave), length, pitch and startpoint.
Then these could evolve similar to the image version, with the resulting sound checked against the original.
If there is no image loaded and you drag where the image is normally, the program crashes.
add mutation types:
completely random mutation (fresh dna)
move a vertex
change a polygon colour
delete a polygon
add a polygon
move polygon up stack
move polygon down stack
add setting for maximum number of polygons in rendered image
bug - image resizes when dragging focus bounding box
Making a focus box by dragging from the bottom right to upper left doesn't work.
After hitting 15000 polys the image will continue increasing in generation but will be no longer generate any polys.
[parker@x3720 Evolve]$ QT_STYLE_OVERRIDE=gtk ./Evolve
QPainter::begin: Paint device returned engine == 0, type: 2
QPainter::setPen: Painter not active
QPainter::drawRects: Painter not active
QPainter::end: Painter not active, aborted
Floating point exception (core dumped)
Latest git
Arch x86_64
qt 5.4.1-2
Don't know what is so special about certain images, but with some the programm crashes
Win7 x64, also im not the only one who has this issue
If you export the DNA and then reimport it, the image is darker than before, as if some polygons had different brightness or alpha, the fitness value is also lower than before. If you then start the process, many areas of the image will be reconstructed respectively.
Another example to show this:
If you export a PNG and an SVG, then export and reimport the DNA, and then export a second png and a second SVG, you will notice that the two PNGs look different. The second one is darker, as mentioned before. The SVGs, however, looks exactly the same and both show the darker version that the second PNG shows.
This is really a pity because the program is generelly really nice, but its most interesting features, the SVG and DNA export both seem to have this bug.
setting focus box dimensions to 0 or negative crashes application
this image randomly stops on the dev branch and freezes on focus in master
The all at once method is intensive while focusing on square tends to provide a quicker result. Maybe have a way to split the image into a grid and process one cell at a time.
There should be a count of how many times it has found a more beneficial mutation, similar to the web evolver's mutation count. It would be nice when the polygon count has hit its limit and you don't really know if it's still working or has malfunctioned but still increases the generation.
add a function to the fitness calculation so that images with the same fitness but less polygons have higher overall fitness
some kind of decentralised computing thing for sharing render compute time
Evolve it's crashing too much.
An option to autosave the .dna file every n seconds would be good.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.