Making mosaic images with ffmpeg
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
778 B

#include "downscale.hpp"
#include <image_io.hpp>
#include <algorithm>
downscale downscale::pre_calculate(const av::frame& frame){
// ffmpeg doesnt let us downscale all the way to 5 at once :(
auto const image = to_raw_rgb_image(frame, 5, 5);
downscale ret;
ret.data.assign(image.data.size(), 0);
std::copy(image.data.begin(), image.data.end(), ret.data.begin());
return ret;
}
downscale downscale::calculate(const av::frame& frame){
return pre_calculate(frame);
}
double square(double x){
return x*x;
}
double downscale::distance_to(const downscale& fingerprint) const {
assert(data.size() == fingerprint.data.size());
double distance = 0;
for(size_t i = 0; i < data.size(); ++i){
distance += square(data[i] - fingerprint.data[i]);
}
return distance;
}