Skip to content

Commit

Permalink
Better(?) threshold params, and a thought
Browse files Browse the repository at this point in the history
  • Loading branch information
sz3 committed Jun 1, 2023
1 parent 99e0f51 commit 3479d39
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/lib/cimb_translator/CimbReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ namespace {
{
// will this need to change for smaller tiles? probably?

int blockSize = 3; // default: no preprocessing
int blockSize = 7; // default: no preprocessing

cv::Mat symbols;
cv::cvtColor(img, symbols, cv::COLOR_RGB2GRAY);
if (needs_sharpen)
{
sharpenSymbolGrid(symbols, symbols);
blockSize = 7;
blockSize = 3;
}
cv::adaptiveThreshold(symbols, symbols, 255, cv::ADAPTIVE_THRESH_MEAN_C, cv::THRESH_BINARY, blockSize, 0);
cv::adaptiveThreshold(symbols, symbols, 255, cv::ADAPTIVE_THRESH_MEAN_C, cv::THRESH_BINARY, blockSize, -10);

bitbuffer bb(std::pow(Config::image_size(), 2) / 8);
bitmatrix::mat_to_bitbuffer(symbols, bb.get_writer());
Expand Down Expand Up @@ -124,6 +124,10 @@ unsigned CimbReader::read(PositionData& pos)
int y = xy.second + drift.y();
bitmatrix cell(_grayscale, _image.cols, _image.rows, x-1, y-1);

// before we get the main cell, try the single-channel (red?) version?
// e.g. do pull the redCell, do a popcnt on the middle pixels, and iff it's above a threshhold, pass it to decode_symbol() as the cell we use
// if redCell is below the threshhold, use the standard all-channel version

unsigned drift_offset = 0;
unsigned error_distance;
unsigned bits = _decoder.decode_symbol(cell, drift_offset, error_distance, cooldown);
Expand Down

0 comments on commit 3479d39

Please sign in to comment.