I checked the work times of all functions and this one is the by far longest one (60 to 80 milliseconds). What are the faster options to implement this?
That's not surprising given that the main work, the "Classify" function, is part of that code.
Best to get a profiler to check which exact part of the code takes the longest.
One optimization you can make is to not take/use a whole
std::vector to pass two floats.
Constructing a vector is expensive and you'll be using quite a bit more memory than two floats.
Either pass the floats directly, or use something like a tuple or even
sf::Vector2f is a better option.
Side note: You shouldn't be using C-style casts anymore. Use
static_cast<float> instead of
(float).
The most recommended/fastest way is to use your own one dimensional array/vector of pixel values (e.g.
std::vector<sf::UInt8>), where four values represent one color (RGBA).
You'll have to do the image wrapping etc. with math, as it's a one dimensional vector.
Then use that data and call
update() on the texture.
Finally, you don't have to call
setTexture() if all you want is to set the texture rect, you can call
setTextureRect().
And it goes without saying, make sure you're running everything in release mode with optimizations.