Compare images in fitness function and benchmark them
This commit is contained in:
parent
0183d4737c
commit
d38e45dac8
7 changed files with 189 additions and 11 deletions
25
src/Fitness.hpp
Normal file
25
src/Fitness.hpp
Normal 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
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue