Skip to content

Commit

Permalink
Special case for running the "ALL" check (9-way compare) on seed loca…
Browse files Browse the repository at this point in the history
…tions

The idea being that we might be 1px off in both dimensions (frankly, it
might be worse than that...), and that it doesn't do us any harm to run
the extra checks in this one instance.

Probably
  • Loading branch information
sz3 committed Jun 1, 2023
1 parent 92a33ef commit f932602
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
7 changes: 5 additions & 2 deletions src/lib/cimb_translator/CellDrift.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,17 @@ void CellDrift::updateDrift(int dx, int dy)
// static
uint8_t CellDrift::calculate_cooldown(uint8_t previous, uint8_t idx)
{
// previous xor idx == 6??
if (idx % 2 == 0)
return 0xFF;
// if idx % 2 == 1 and previous xor idx == 6
// return 0xFF; // ?
if (previous == 1 and idx == 7)
return 0xFF;
if (previous == 3 and idx == 5)
return 0xFF;
if (previous == 5 and idx == 3)
return 0xFF;
if (previous == 1 and idx == 7)
if (previous == 7 and idx == 1)
return 0xFF;
return idx;
}
5 changes: 3 additions & 2 deletions src/lib/cimb_translator/CimbDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,13 @@ unsigned CimbDecoder::get_best_symbol(image_hash::ahash_result& results, unsigne
unsigned CimbDecoder::decode_symbol(const cv::Mat& cell, unsigned& drift_offset, unsigned& best_distance, unsigned cooldown) const
{
image_hash::ahash_result results = image_hash::fuzzy_ahash(cell, _ahashThreshold, image_hash::ahash_result::FAST);
return get_best_symbol(results, drift_offset, best_distance);
return get_best_symbol(results, drift_offset, best_distance, cooldown);
}

unsigned CimbDecoder::decode_symbol(const bitmatrix& cell, unsigned& drift_offset, unsigned& best_distance, unsigned cooldown) const
{
image_hash::ahash_result results = image_hash::fuzzy_ahash(cell, image_hash::ahash_result::FAST);
int checkRule = cooldown == 0xFE? image_hash::ahash_result::ALL : image_hash::ahash_result::FAST;
image_hash::ahash_result results = image_hash::fuzzy_ahash(cell, checkRule);
return get_best_symbol(results, drift_offset, best_distance, cooldown);
}

Expand Down
6 changes: 3 additions & 3 deletions src/lib/cimb_translator/CimbDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ class CimbDecoder

void update_color_correction(cv::Matx<float, 3, 3>&& ccm);

unsigned get_best_symbol(image_hash::ahash_result& results, unsigned& drift_offset, unsigned& best_distance, unsigned cooldown=~0U) const;
unsigned decode_symbol(const cv::Mat& cell, unsigned& drift_offset, unsigned& best_distance, unsigned cooldown=~0U) const;
unsigned decode_symbol(const bitmatrix& cell, unsigned& drift_offset, unsigned& best_distance, unsigned cooldown=~0U) const;
unsigned get_best_symbol(image_hash::ahash_result& results, unsigned& drift_offset, unsigned& best_distance, unsigned cooldown=0xFF) const;
unsigned decode_symbol(const cv::Mat& cell, unsigned& drift_offset, unsigned& best_distance, unsigned cooldown=0xFF) const;
unsigned decode_symbol(const bitmatrix& cell, unsigned& drift_offset, unsigned& best_distance, unsigned cooldown=0xFF) const;

unsigned get_best_color(float r, float g, float b) const;
unsigned decode_color(const Cell& cell) const;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/cimb_translator/CimbReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace {
{
// will this need to change for smaller tiles? probably?

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

cv::Mat symbols;
cv::cvtColor(img, symbols, cv::COLOR_RGB2GRAY);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/cimb_translator/FloodDecodePositions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void FloodDecodePositions::reset()
for (unsigned i = 0; i < _positions.size(); ++i)
{
_remaining.push_back(true);
_instructions.push_back({CellDrift(), 0xFF, 0xFF});
_instructions.push_back({CellDrift(), 0xFE, 0xFE});
}

// seed
Expand Down

0 comments on commit f932602

Please sign in to comment.