Compare images in fitness function and benchmark them

This commit is contained in:
Joscha 2017-04-26 18:16:00 +00:00
parent 0183d4737c
commit d38e45dac8
7 changed files with 189 additions and 11 deletions

25
src/Fitness.hpp Normal file
View file

@ -0,0 +1,25 @@
#pragma once
#include "Chromosome.hpp"
#include <SFML/Graphics.hpp>
class Fitness
{
public:
Fitness();
Fitness(sf::Texture target, float scale=0.5);
bool loadShader(std::string filename);
double of(Chromosome chr);
sf::Texture target; // base image to compare against
sf::RenderTexture tex; // big RenderWindow containg the Chromosome to be evaluated
sf::RenderTexture comp; // smaller RenderWindow which is downloaded as Image
private:
sf::Sprite sprite; // sprite to render tex to comp
sf::Shader compshdr; // shader to perform pixel-wise image diff with
sf::View view; // reduces tex to comp size while drawing
};