From 196a893bd3451df38548121962502c2833e0a72f Mon Sep 17 00:00:00 2001 From: sz Date: Sun, 18 Feb 2024 00:03:01 -0600 Subject: [PATCH] Cleanup some includes/comments --- src/lib/chromatic_adaptation/color_correction.h | 10 ++++------ src/lib/cimb_translator/CimbReader.cpp | 3 --- src/lib/cimbar_js/cimbar_js.cpp | 4 ++-- src/lib/encoder/Decoder.h | 15 --------------- src/lib/encoder/SimpleEncoder.h | 2 -- 5 files changed, 6 insertions(+), 28 deletions(-) diff --git a/src/lib/chromatic_adaptation/color_correction.h b/src/lib/chromatic_adaptation/color_correction.h index 6efb6841..c00b52dd 100644 --- a/src/lib/chromatic_adaptation/color_correction.h +++ b/src/lib/chromatic_adaptation/color_correction.h @@ -3,8 +3,6 @@ #include -#include - // transforms are in adaptation_transform.h // http://brucelindbloom.com/Eqn_ChromAdapt.html @@ -27,10 +25,10 @@ class color_correction static inline cv::Matx get_moore_penrose_lsm(const cv::Mat& actual, const cv::Mat& desired) { - // 1. TODO: make sure actual and desired dims match? - // 2. the calculation is MoorePenrose least squares mapping: - // in numpy, it's dot(transpose(x), pinv(transpose(y))) - + // inspired by the python colour-science package. It's not complicated, + // but I didn't know that going in. + // See also: + // https://en.wikipedia.org/wiki/Moore-Penrose_inverse cv::Mat x, y, z; cv::transpose(desired, x); cv::transpose(actual, y); diff --git a/src/lib/cimb_translator/CimbReader.cpp b/src/lib/cimb_translator/CimbReader.cpp index a50c10e4..34788e36 100644 --- a/src/lib/cimb_translator/CimbReader.cpp +++ b/src/lib/cimb_translator/CimbReader.cpp @@ -9,10 +9,7 @@ #include "bit_file/bitmatrix.h" #include "chromatic_adaptation/adaptation_transform.h" #include "chromatic_adaptation/color_correction.h" -#include "serialize/format.h" - #include -#include using namespace cimbar; diff --git a/src/lib/cimbar_js/cimbar_js.cpp b/src/lib/cimbar_js/cimbar_js.cpp index 10f24179..2121f083 100644 --- a/src/lib/cimbar_js/cimbar_js.cpp +++ b/src/lib/cimbar_js/cimbar_js.cpp @@ -69,8 +69,8 @@ int next_frame() return 0; // we generate 5x the amount of required symbol blocks -- unless everything fits in a single frame. - // color blocks will contribute to this total, but only symbols used for the initial calculation. - // ... this way, if the color decode is failing, we don't get "stuck" rendering a single frame. + // color blocks will contribute to this total, but only symbols are used for the initial calculation. + // ... this way, if the color decode is failing, it won't get "stuck" failing to read a single frame. unsigned required = _fes->blocks_required(); if (required > cimbar::Config::fountain_chunks_per_frame(cimbar::Config::symbol_bits(), _legacyMode)) required = required*5; diff --git a/src/lib/encoder/Decoder.h b/src/lib/encoder/Decoder.h index 8ed51a24..c7cbbb3b 100644 --- a/src/lib/encoder/Decoder.h +++ b/src/lib/encoder/Decoder.h @@ -160,13 +160,6 @@ inline unsigned Decoder::do_decode_coupled(CimbReader& reader, STREAM& ostream) return bb.flush(rss); } - -// seems like we want to take a file or img, and have an output sink -// output sync could be template param? -// we'd decode the full message (via bit_writer) to a temp buffer -- probably a stringstream -// then we'd direct the stringstream to our sink -// which would either be a filestream, or a multi-channel fountain sink - template inline unsigned Decoder::decode(const MAT& img, STREAM& ostream, bool should_preprocess, int color_correction) { @@ -177,15 +170,7 @@ inline unsigned Decoder::decode(const MAT& img, STREAM& ostream, bool should_pre template inline unsigned Decoder::decode_fountain(const MAT& img, FOUNTAINSTREAM& ostream, bool should_preprocess, int color_correction) { - // reader takes cimbar::Config::color_mode() ? CimbReader reader(img, _decoder, should_preprocess, color_correction); - - // maybe give aligned_stream a callback function that can poke the CimbReader on flush()? - // and then in do_decode(), after the first flush, call CimbReader::try_to_make_new_ccm(), - // ... maybe a replacement for the existing updateColorCorrection()? (called in constructor, would now happen later)... - // which reads the values from the image (using what the aligned_stream gave it -- if anything, and maybe the cellpositions from FloodFillDecode?) - // iff we got enough data from aligned_stream to sample enough colors, try_to_make_new_ccm() pushes the updated ccm to CimbDecoder's threadlocal - // if not, we use whatever we previously had in CimbDecoder's threadlocal...? aligned_stream aligner(ostream, ostream.chunk_size(), 0, std::bind(&CimbReader::update_metadata, &reader, std::placeholders::_1, std::placeholders::_2)); return do_decode(reader, aligner); } diff --git a/src/lib/encoder/SimpleEncoder.h b/src/lib/encoder/SimpleEncoder.h index 339ff5d5..64227d83 100644 --- a/src/lib/encoder/SimpleEncoder.h +++ b/src/lib/encoder/SimpleEncoder.h @@ -13,8 +13,6 @@ #include #include -#include - class SimpleEncoder { public: