Skip to content

Commit

Permalink
Subtree merge of libcimbar -- sz3/libcimbar#81 (faebb87fc80dbe399b1ec…
Browse files Browse the repository at this point in the history
…4685c6f193c8612e1a5)
  • Loading branch information
sz3 committed Nov 30, 2023
2 parents 92a9a80 + 0367145 commit 2036e66
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 13 deletions.
9 changes: 6 additions & 3 deletions app/src/cpp/libcimbar/src/lib/cimb_translator/CimbReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@ namespace {
template <typename MAT>
bitbuffer preprocessSymbolGrid(const MAT& img, bool needs_sharpen)
{
int blockSize = 3; // default: no preprocessing
int blockSize = 5; // default: no preprocessing

cv::Mat symbols;
cv::cvtColor(img, symbols, cv::COLOR_RGB2GRAY);
if (needs_sharpen)
sharpenSymbolGrid(symbols, symbols); // we used to change blockSize for this case -- may one day be a useful trick again?
cv::adaptiveThreshold(symbols, symbols, 255, cv::ADAPTIVE_THRESH_MEAN_C, cv::THRESH_BINARY, blockSize, -5);
{
blockSize = 7;
sharpenSymbolGrid(symbols, symbols);
}
cv::adaptiveThreshold(symbols, symbols, 255, cv::ADAPTIVE_THRESH_MEAN_C, cv::THRESH_BINARY, blockSize, 0);

bitbuffer bb(std::pow(Config::image_size(), 2) / 8);
bitmatrix::mat_to_bitbuffer(symbols, bb.get_writer());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ TEST_CASE( "CimbReaderTest/testSample", "[unit]" )
++count;
}

string expected = "0=0 99=8 600=33 710=28 711=30 821=8 822=22 823=19 934=55 11688=55 11799=25 "
"11900=28 12000=23 12100=0 12200=5 12201=0 12298=32 12299=34 12300=30 12301=32 "
"12398=10 12399=15";
string expected = "0=0 99=8 11680=3 11681=32 11900=28 11901=25 11904=12 11995=2 11996=8 11998=6 "
"11999=54 12001=29 12004=6 12099=2 12195=57 12196=1 12200=5 12201=0 12298=32 "
"12299=34 12300=30 12399=15";
assertEquals( expected, turbo::str::join(res) );

PositionData pos;
Expand Down Expand Up @@ -109,8 +109,9 @@ TEST_CASE( "CimbReaderTest/testSampleMessy", "[unit]" )
++count;
}

string expected = "0=0 99=8 600=33 711=30 11462=2 11573=33 11574=0 11685=52 11686=17 11687=41 "
"11688=55 11797=30 11798=15 11799=25 12200=5 12298=46 12299=34 12300=30 12301=32 12397=38 12398=10 12399=15";
string expected = "0=0 1=28 99=8 100=28 600=33 601=38 711=30 712=57 11464=53 11576=32 11577=44 "
"11687=41 11688=55 11689=32 11690=48 11798=15 11799=25 12297=46 12298=32 "
"12299=34 12300=30 12399=15";
assertEquals( expected, turbo::str::join(res) );

PositionData pos;
Expand Down Expand Up @@ -200,7 +201,7 @@ TEST_CASE( "CimbReaderTest/testCCM.VeryNecessary", "[unit]" )
" 0.023812667, 0.98703396, -0.0048082001;\n"
" 0, 0, 1.0017186]", ss.str());

std::array<unsigned, 6> expectedColors = {0, 0, 0, 0, 0, 3}; // it's wrong, but it's consistent!
std::array<unsigned, 6> expectedColors = {0, 0, 0, 0, 0, 0}; // it's wrong, but it's consistent!
for (unsigned i = 0; i < expectedColors.size(); ++i)
{
PositionData pos;
Expand Down
2 changes: 1 addition & 1 deletion app/src/cpp/libcimbar/src/lib/encoder/test/DecoderTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ TEST_CASE( "DecoderTest/testDecode.Sample", "[unit]" )
assertEquals( 9300, bytesDecoded );

if (CV_VERSION_MAJOR == 4)
assertEquals( "0f74a76cb1f59df7a42449a3527d464d913d12a03bffa51d6f53828724c3feb1", get_hash(decodedFile) );
assertEquals( "2040c157884c476def842f7854621a7655182e5f11a34ade563616d93cb93455", get_hash(decodedFile) );
}
Binary file added app/src/cpp/libcimbar/web/icon-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/cpp/libcimbar/web/icon-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion app/src/cpp/libcimbar/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
<head>
<title>Cimbar Encoder</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no" />
<meta name="viewport" content="width=device-width, user-scalable=no">
<link rel="manifest" href="pwa.json">
</head>
<body>

Expand Down
13 changes: 13 additions & 0 deletions app/src/cpp/libcimbar/web/pwa.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"lang": "en",
"dir": "ltr",
"name": "Cimbar Encoder",
"short_name": "cimbar.org",
"icons": [{"src":"icon-192x192.png","sizes":"192x192","type":"image/png"},{"src":"icon-512x512.png","sizes":"512x512","type":"image/png"}],
"scope": "/",
"start_url": "index.html",
"display": "fullscreen",
"theme_color": "aliceblue",
"background_color": "black"
}

5 changes: 3 additions & 2 deletions app/src/cpp/libcimbar/web/sw.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@

var _cacheName = 'cimbar-js-v0.5.8.c';
var _cacheName = 'cimbar-js-v0.5.14';
var _cacheFiles = [
'/',
'/index.html',
'/cimbar_js.js',
'/cimbar_js.wasm',
'/favicon.ico',
'/main.js'
'/main.js',
'/pwa.json'
];

// fetch files
Expand Down

0 comments on commit 2036e66

Please sign in to comment.