Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support new cimbar format "mode B", minor UI change = version 0.6.0f #31

Merged
merged 8 commits into from
Feb 26, 2024

Conversation

sz3
Copy link
Owner

@sz3 sz3 commented Feb 26, 2024

Format/design notes:

  • mode B has split symbol and color decodes, meaning even if the colors are completely wrong we can still make progress
  • the new format also allows better color correction => better performance under a larger variety of conditions
    • there are some narrow circumstances where the old mode 4C might still be better
  • removal of 8-color support (for now?)
    • it never worked very well. It might make a come back at a later date

Graphical app updates:

  • instead of "4/8", the toggle at the bottom right corner of the app is now "4C/B". An 8 kind of looks like a B, but I went above and beyond the call of duty to change it.
  • adjusted the "extract success but failed full decode" color introduced in 0.5.15. It is now yellow. Very exciting.

Bugfix:

  • fixed a race condition in how the color correction matrix was being updated

See also:

This will differentiate mode "4C" (the original 4-color 8x8 config) with
mode "B" (the new 4-color 8x8 config), but also allows room to express
other potential modes:

"8C" would be initial 8-color 8x8 config (removing support from this
from the app for simplicity's sake. It doesn't work too well anyway)

mode "S" will likely be the 4-color 5x5 config I've been working on --
but that's not quite ready yet.

For now, toggling between modes is a user action. I would like to
experiment with auto-detection.

Still using the old graphics for now.
With new graphics!
a0178c280 Merge pull request #92 from sz3/0.6-mode-switch
4f73a9eeb Update sample image in README
656588b03 Add color change back for menu icon based on mode selection
ad8cda73f Cleanup some includes/comments
390041eb7 Update docs for mode B!
95afff4d9 Switch ccm matrix to use a thread_local
347d23190 Less && in package-wasm, so we can re-run the script with (some) impunity
dbf77a2d6 Update cimbar.js with 0.6 modes
7b54894a8 Merge pull request #91 from sz3/mode-b
7206b91db Use new samples submodule rev
196a893bd Cleanup some includes/comments
55299de5f `fountain_chunks_per_frame()` config function needs to return "10" for 0.5.x
9f6600dcc Add toggle for old "4c" mode in the cimbar_js and the cli tools
af823fd39 Update tests, and add back some "legacy" (0.5.x = "4c") support for encoder
a05d414a9 Disable color decode "skip" logic
8c3b0a728 Make new color correction mode the default
88c30e02d Use Moore-Penrose least squares to compute our CCM
2f491eff6 Changes for the second-pass CCM+color decode
fcb214d1f Working towards proper color correction
be36c0275 Add FountainHeader logic to CimbReader
36676d70d Update FountainMetadata to include the block_id
2c6319dcf Change default encode_id to 109, and return to older color calc?
2e7e3aacd Change calc for required frames we generate for small files
6b58b251b Flush symbols/colors separately
80a668c25 Tweaks to Encoder default params
33b6cef4c Reintroduce the legacy decoder function
55dbf6842 First pass at decoder for split symbols/colors
4f9622f4a Simplify loop
e7fdfe382 First pass at splitting symbol and color channels, encoder edition
db0812c89 WIP to vary fountain chunk size by number of symbol bits...
4067532a2 color_mode for encoder?
32b9ffa84 Experiment with a different color calculation?

git-subtree-dir: app/src/cpp/libcimbar
git-subtree-split: a0178c280030d62b7fd0c695288304a62c9b9b54
Trying to minimize upgrade pain -- mode B will be the default
eventually, but not yet. My current hope is that I can get auto-detect
logic working, making the "default" academic (on the decoder side at
least).
A temporary measure. But if mode B isn't the default, it doesn't make
much sense to lean on its color correction logic to "prime the pump" for
4C...
I've taken to adding a letter at the end when something goes awry with
the initial release bits.
@@ -8,8 +8,8 @@ android {
applicationId "org.cimbar.camerafilecopy"
minSdkVersion 21
targetSdkVersion 30
versionCode 11
versionName "0.5.15"
versionCode 13
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't talk about what happened to version 12...

(ok, it's just that the default was mode B, and I concluded that might be a problem)

, _dec(cimbar::Config::ecc_bytes(), _colorBits)
inline MultiThreadedDecoder::MultiThreadedDecoder(std::string data_path, bool legacy_mode)
: _legacyMode(legacy_mode)
, _dec(cimbar::Config::ecc_bytes(), cimbar::Config::color_bits(), legacy_mode? 0 : 1, legacy_mode)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These ternarys (ternaries?) are kinda gross, but fine for now?

@@ -97,7 +96,8 @@ inline bool MultiThreadedDecoder::add(cv::Mat mat)
// if extracted image is small, we'll need to run some filters on it
clock_t begin = clock();
bool should_preprocess = (res == Extractor::NEEDS_SHARPEN);
unsigned decodeRes = _dec.decode_fountain(img, _writer, should_preprocess);
int color_correction = _legacyMode? 1 : 2;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notably, this means that mode 4C will not benefit from the color correction matrix generated by mode B. I went back and forth on this, and probably will remove it once mode B is the default (if not sooner 🤔 ).

Mode B's CCM will pretty much always be better, if it exists.

@@ -53,7 +53,7 @@ namespace {

cv::Scalar color = cv::Scalar(255,255,255);
if (in_progress == 1)
color = cv::Scalar(255,100,100);
color = cv::Scalar(255,244,94); // 0,191,255
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you can see, blue is also an option. I decided to throw our colorblind friends a bone and not use red vs green.

{
++_calls;

// get params from raw address
Mat &mat = *(Mat *) matAddr;
string dataPath = jstring_to_cppstr(env, dataPathObj);
int colorBits = (int)colorBitsJ;
int modeVal = (int)modeInt;
bool legacyMode = modeVal <= 8; // current scheme: old 4c = 4, old 8c = 8, new = bigger number
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These "modeVal" numbers (4, 8, 68) are CFC only at the moment, and might change in the future. libcimbar currently has no such concept, but if we adopt one there we'll probably mirror it here.

mColorSwitch = (ToggleButton) findViewById(R.id.color_switch);
mColorSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
mModeSwitch = (ToggleButton) findViewById(R.id.mode_switch);
mModeSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to try to add mode autodetection for 0.6.1.

@sz3 sz3 changed the title Support new cimbar format "mode B", update interface = version 0.6.0f Support new cimbar format "mode B", minor UI change = version 0.6.0f Feb 26, 2024
@sz3 sz3 merged commit c47755e into master Feb 26, 2024
@sz3 sz3 deleted the mode-b-and-other-goodness branch February 26, 2024 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant