From 93443218d17ce1cb4f2e776f67a8f878480ffa63 Mon Sep 17 00:00:00 2001 From: sz Date: Mon, 20 Mar 2023 21:27:07 -0500 Subject: [PATCH 1/3] Update ndk and targetSdkVersion in build.gradle --- app/build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 57921d3..c69bac9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,13 +3,13 @@ apply plugin: 'com.android.application' android { compileSdkVersion 33 buildToolsVersion "29.0.3" - ndkVersion "22.1.7171670" + ndkVersion "25.2.9519653" defaultConfig { applicationId "org.cimbar.camerafilecopy" minSdkVersion 21 - targetSdkVersion 30 + targetSdkVersion 33 versionCode 8 - versionName "0.5.12" + versionName "0.5.12+a" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" externalNativeBuild { cmake { From c1f74efcecfd4155775ff4aa17e48208b13df96e Mon Sep 17 00:00:00 2001 From: sz Date: Sat, 24 Jun 2023 06:54:13 -0500 Subject: [PATCH 2/3] Squashed 'app/src/cpp/libcimbar/' changes from 3cd792b5..f219e877 f219e877 Merge pull request #75 from sz3/web-fix 20f16012 The GL window height, or width, or both, needs to be divisible by 4? 98368d71 Pass dummy values to configure() to use config defaults 1b09a772 Use Config settings for cimbar_js defaults b392e57b Pin the emscripten/emsdk docker image d9bd2a29 Merge pull request #73 from sz3/bugfix-improve-and-5x5 709a3484 Add back a few test cases, add some comments, and check in the 5x5 tileset b9d9d039 Simplify calculate_cooldown() + a comment for FloodDecodePositions::update() 55fcadb0 gh workflow updates 6baf0c43 Odd emscripten workaround -- not sure if this is the "right way", but it works 9f114732 Fix wasm packaging script 04528bb5 Add the 5x5 tileset to bitmaps.h + missing include dce68331 Fix off-by-one type bug! d452652b Update regression tests 8c891d01 Put back the Config.cpp for broader compiler support... 55956de1 Update more tests? 9204892a Misc fix 4d2943c1 Experimenting with ways to improve the flood decode 6daa9476 3,-5 for adaptiveThreshhold on symbols seems better? 18e54802 Put back the skip param for mean_rgb on larger cell sizes 1ec077b9 Running afoul of constexpr rules 4e33841c Put us back on 8x8 ec74f7c9 For now, put the uint128s back 02d4573e Have ahash_result take a template param for cell size e2b55fce + do all bitextract index magic in "pattern()" function 24a291a2 Add some compile-time magic to auto-generate the bit extract pattern 173087ce Move grid params into their own file? cad107cd Minor tweaks to make it easier to switch between grid sizes f9326023 Special case for running the "ALL" check (9-way compare) on seed locations 92a33ef4 More warnings \o/ 3479d39b Better(?) threshold params, and a thought 99e0f512 Drift cooldown? f3cdabe9 More const, and add more seed positions for the decode? 6849234e These should all be const... f9a9dd8a Scale window size off the size of the image. 3616c367 Pass image_size/anchor_size to extractor... 7766cfd8 Attempt to use 988x988 grid...? c4f87506 A 5x5 that works with both 4 bit and 5 bit c34ae889 Calculate total_cells() and frame capacity, and ... cdd2f5c5 Update ahash_result for 5-bit reads + lots of test fixes for average_hash ec629809 Changes to average_hash... e2cab430 Small changes to average_hash(), decode_color() 731dfb1a Update the bitextractor to deal with reads other than len=8 1fd265d6 Minimal changes for encoding with a grid of 5x5s b0aae780 Merge pull request #68 from sz3/packaging-cimbar-html 6ca0650f Post cimbar_js.html as part of package build. 0906f682 Script to bundle cimbar_js's asm.js build into a single html file c8529e33 Merge pull request #63 from sz3/stdin d17dcf31 -f is now the default 21f99327 A bit silly, but: py3.6 compatibility for now 2ff867d7 Test cli? d646ec72 Have fountain_decoder_sink optionally print its work... 892579ae Have the encoder be stdin-aware too 21cc6a79 :thinking: aad249d4 Read filenames from stdin iff no inputs are provided, + ... 074d813a Make fountain encoding the default. Add StdinLineReader for decodes. 89762c1e An idea git-subtree-dir: app/src/cpp/libcimbar git-subtree-split: f219e877652220702624e5ca06c5d1982060d0bb --- .github/workflows/ci.yml | 20 +- .github/workflows/release.yml | 5 +- CMakeLists.txt | 2 +- DETAILS.md | 2 +- README.md | 9 +- bitmap/2/00.png | Bin 0 -> 112 bytes bitmap/2/01.png | Bin 0 -> 113 bytes bitmap/2/02.png | Bin 0 -> 115 bytes bitmap/2/03.png | Bin 0 -> 114 bytes package-cimbar-html.py | 36 ++++ package-portable-linux.sh | 2 +- package-wasm.sh | 11 +- .../build_image_assets/build_image_assets.cpp | 10 +- src/exe/cimbar/CMakeLists.txt | 1 + src/exe/cimbar/cimbar.cpp | 202 ++++++++++++++---- src/exe/cimbar_extract/cimbar_extract.cpp | 2 +- src/exe/cimbar_send/send.cpp | 14 +- src/lib/bit_file/bitmatrix.h | 36 ++-- .../cimb_translator/AdjacentCellFinder.cpp | 10 +- src/lib/cimb_translator/AdjacentCellFinder.h | 8 +- src/lib/cimb_translator/Cell.h | 24 +-- src/lib/cimb_translator/CellDrift.cpp | 16 +- src/lib/cimb_translator/CellDrift.h | 5 +- src/lib/cimb_translator/CimbDecoder.cpp | 45 ++-- src/lib/cimb_translator/CimbDecoder.h | 7 +- src/lib/cimb_translator/CimbReader.cpp | 27 ++- src/lib/cimb_translator/CimbWriter.cpp | 4 +- src/lib/cimb_translator/Config.cpp | 84 ++------ src/lib/cimb_translator/Config.h | 121 +++++++++-- .../cimb_translator/FloodDecodePositions.cpp | 87 ++++++-- .../cimb_translator/FloodDecodePositions.h | 11 +- src/lib/cimb_translator/GridConf.h | 31 +++ src/lib/cimb_translator/bitmaps.h | 5 +- .../cimb_translator/test/CimbDecoderTest.cpp | 14 +- .../cimb_translator/test/CimbReaderTest.cpp | 24 +-- .../test/FloodDecodePositionsTest.cpp | 46 +++- src/lib/cimbar_js/CMakeLists.txt | 2 +- src/lib/cimbar_js/cimbar_js.cpp | 18 +- src/lib/encoder/Decoder.h | 21 +- src/lib/encoder/SimpleEncoder.h | 12 +- src/lib/encoder/reed_solomon_stream.h | 27 ++- src/lib/encoder/test/DecoderTest.cpp | 6 +- .../encoder/test/reed_solomon_streamTest.cpp | 14 +- src/lib/extractor/Deskewer.cpp | 11 +- src/lib/extractor/Deskewer.h | 14 +- src/lib/extractor/Extractor.cpp | 13 +- src/lib/extractor/Extractor.h | 4 +- src/lib/extractor/test/DeskewerTest.cpp | 2 +- src/lib/extractor/test/ExtractorTest.cpp | 6 +- src/lib/extractor/test/UndistortTest.cpp | 2 +- src/lib/fountain/fountain_decoder_sink.h | 11 +- src/lib/image_hash/ahash_result.h | 49 +++-- src/lib/image_hash/average_hash.h | 63 ++---- src/lib/image_hash/bit_extractor.h | 41 +++- src/lib/image_hash/test/averageHashTest.cpp | 33 ++- src/lib/image_hash/test/bitExtractorTest.cpp | 145 ++++++++++++- src/lib/image_hash/test/fuzzyAhashTest.cpp | 116 ++++++++-- test/py/__init__.py | 0 test/py/helpers.py | 16 ++ test/py/test_cimbar_cli.py | 89 ++++++++ web/main.js | 2 +- 61 files changed, 1167 insertions(+), 471 deletions(-) create mode 100644 bitmap/2/00.png create mode 100644 bitmap/2/01.png create mode 100644 bitmap/2/02.png create mode 100644 bitmap/2/03.png create mode 100644 package-cimbar-html.py create mode 100644 src/lib/cimb_translator/GridConf.h create mode 100644 test/py/__init__.py create mode 100644 test/py/helpers.py create mode 100644 test/py/test_cimbar_cli.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 04301b7..ee21f6e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,20 +10,20 @@ jobs: fail-fast: false matrix: config: - - name: "linux gcc7" - os: ubuntu-18.04 - env: CXX="g++-7" CC="gcc-7" - - name: "linux gcc9" + os: ubuntu-20.04 + env: CXX="g++-9" CC="gcc-9" + + - name: "linux gcc-latest" os: ubuntu-latest - name: "linux clang" - os: ubuntu-18.04 + os: ubuntu-20.04 env: CXX="clang++" CC="clang" extra-packages: "clang" steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: 'recursive' @@ -45,11 +45,15 @@ jobs: working-directory: ${{runner.workspace}}/build run: make test CTEST_OUTPUT_ON_FAILURE=TRUE + - name: Usage test + working-directory: ${{runner.workspace}}/libcimbar/test/py + run: python3 -m unittest + cppcheck: - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Install dependencies run: sudo apt-get install cppcheck diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d7802ae..6903150 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Get the code - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: submodules: 'recursive' @@ -23,7 +23,7 @@ jobs: - name: Run the build process with Docker uses: addnab/docker-run-action@v3 with: - image: emscripten/emsdk:latest + image: emscripten/emsdk:3.1.39 options: -v ${{ github.workspace }}:/usr/src/app shell: bash run: | @@ -39,4 +39,5 @@ jobs: files: | web/cimbar.asmjs.zip web/cimbar.wasm.tar.gz + web/cimbar_js.html diff --git a/CMakeLists.txt b/CMakeLists.txt index 13dcf5d..2010386 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ add_definitions("-DLIBCIMBAR_PROJECT_ROOT=\"${libcimbar_SOURCE_DIR}\"") if("${CMAKE_BUILD_TYPE}" STREQUAL "") set(CMAKE_BUILD_TYPE "RelWithDebInfo") set(CMAKE_C_FLAGS "${CFLAGS} -Wall -std=c99 -Os -fPIC") - set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Wall -g -O2 -fPIC") + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Wall -Wextra -g -O2 -fPIC") endif() if(DEFINED USE_WASM) # wasm build needs OPENCV_DIR defined diff --git a/DETAILS.md b/DETAILS.md index e58718f..d71d971 100644 --- a/DETAILS.md +++ b/DETAILS.md @@ -34,7 +34,7 @@ The above is a 4x4(x4) cimbar grid -- encoding 64 bits of data. A real cimbar im ![an example cimbar code](https://github.com/sz3/cimbar-samples/blob/v0.5/6bit/4color_ecc30_fountain_0.png) -... and contains 1550 tiles for data. For 6-bit cimbar (4 symbol bits, 2 color bits), this means 9300 bytes per image. +... and contains 12400 tiles for data. For 6-bit cimbar (4 symbol bits, 2 color bits), this means 9300 bytes per image. ### Error Correction diff --git a/README.md b/README.md index 2dc9e66..bfb0610 100644 --- a/README.md +++ b/README.md @@ -77,12 +77,17 @@ Encode: * large input files may fill up your disk with pngs! ``` -./cimbar --encode -i inputfile.txt -o outputprefix -f +./cimbar --encode -i inputfile.txt -o outputprefix ``` Decode (extracts file into output directory): ``` -./cimbar outputprefix*.png -o /tmp -f +./cimbar outputprefix*.png -o /tmp +``` + +Decode a series of encoded images from stdin: +``` +echo outputprefix*.png | ./cimbar -o /tmp ``` Encode and animate to window: diff --git a/bitmap/2/00.png b/bitmap/2/00.png new file mode 100644 index 0000000000000000000000000000000000000000..8cd3d0e252f37f7fd5ac646d9c4524c425b9ef71 GIT binary patch literal 112 zcmeAS@N?(olHy`uVBq!ia0vp^tRT$61|)m))t&+=&H|6fVg?4jBOuH;Rhv&5D5&J= z;uyj)GdbnQ|Nr*PQVCAtKl=54$j7Q~lJt4O!~+BjH`cN<*OhLq1*&H7boFyt=akR{ E03#(E^Z)<= literal 0 HcmV?d00001 diff --git a/bitmap/2/01.png b/bitmap/2/01.png new file mode 100644 index 0000000000000000000000000000000000000000..b1b700f5e61340cab7ceaf887d9ddf72bcfa9c43 GIT binary patch literal 113 zcmeAS@N?(olHy`uVBq!ia0vp^tRT$61|)m))t&+=&H|6fVg?4jBOuH;Rhv&5D5&h| z;uyj)GdbnQ|NsB%*+LE+IRFG5z5=mLoRO@`W{xvh7^Y8U;d(8#dK*wVgQu&X%Q~lo FCIGDC9|`~f literal 0 HcmV?d00001 diff --git a/bitmap/2/02.png b/bitmap/2/02.png new file mode 100644 index 0000000000000000000000000000000000000000..12269f4ebd4a800d8685947f89308b981728004a GIT binary patch literal 115 zcmeAS@N?(olHy`uVBq!ia0vp^tRT$61|)m))t&+=&H|6fVg?4jBOuH;Rhv&5D5&b` z;uyj)GdbnQ|Nr*PQVE9y5)%>bP0 Hl+XkKiys{_ literal 0 HcmV?d00001 diff --git a/bitmap/2/03.png b/bitmap/2/03.png new file mode 100644 index 0000000000000000000000000000000000000000..21302d445455b9ab5796d20b7dff933f303a1486 GIT binary patch literal 114 zcmeAS@N?(olHy`uVBq!ia0vp^tRT$61|)m))t&+=&H|6fVg?4jBOuH;Rhv&5D5&D; z;uyj)Gxp?0UIqq^!v@p;*XwC3EuOrsl\n' + script + '\n' + + +def main(): + contents = read_file('index') + main_js = read_script('main_js') + cimbar_js = read_script('cimbar_js') + + contents = contents.replace('