├── app ├── .gitignore ├── src │ ├── cpp │ │ ├── libcimbar │ │ │ ├── test │ │ │ │ ├── py │ │ │ │ │ ├── __init__.py │ │ │ │ │ └── helpers.py │ │ │ │ ├── TestHelpers.h │ │ │ │ └── unittest.h │ │ │ ├── src │ │ │ │ ├── third_party_lib │ │ │ │ │ ├── libcorrect │ │ │ │ │ │ ├── .gitignore │ │ │ │ │ │ ├── src │ │ │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ │ │ ├── reed-solomon │ │ │ │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ │ │ │ └── encode.c │ │ │ │ │ │ │ └── convolutional │ │ │ │ │ │ │ │ ├── sse │ │ │ │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ │ │ │ ├── encode.c │ │ │ │ │ │ │ │ └── convolutional.c │ │ │ │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ │ │ │ ├── metric.c │ │ │ │ │ │ │ │ └── error_buffer.c │ │ │ │ │ │ ├── include │ │ │ │ │ │ │ ├── correct │ │ │ │ │ │ │ │ ├── reed-solomon │ │ │ │ │ │ │ │ │ ├── decode.h │ │ │ │ │ │ │ │ │ ├── encode.h │ │ │ │ │ │ │ │ │ ├── reed-solomon.h │ │ │ │ │ │ │ │ │ └── polynomial.h │ │ │ │ │ │ │ │ ├── util │ │ │ │ │ │ │ │ │ ├── error-sim-sse.h │ │ │ │ │ │ │ │ │ ├── error-sim-fec.h │ │ │ │ │ │ │ │ │ └── error-sim-shim.h │ │ │ │ │ │ │ │ ├── convolutional │ │ │ │ │ │ │ │ │ ├── sse │ │ │ │ │ │ │ │ │ │ └── convolutional.h │ │ │ │ │ │ │ │ │ ├── error_buffer.h │ │ │ │ │ │ │ │ │ ├── metric.h │ │ │ │ │ │ │ │ │ ├── lookup.h │ │ │ │ │ │ │ │ │ ├── bit.h │ │ │ │ │ │ │ │ │ └── convolutional.h │ │ │ │ │ │ │ │ ├── portable.h │ │ │ │ │ │ │ │ └── convolutional.h │ │ │ │ │ │ │ └── correct-sse.h │ │ │ │ │ │ ├── .travis.yml │ │ │ │ │ │ ├── util │ │ │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ │ │ ├── error-sim-sse.c │ │ │ │ │ │ │ ├── error-sim-fec.c │ │ │ │ │ │ │ └── error-sim-shim.c │ │ │ │ │ │ ├── tests │ │ │ │ │ │ │ ├── include │ │ │ │ │ │ │ │ ├── rs_tester_fec.h │ │ │ │ │ │ │ │ ├── rs_tester_fec_shim.h │ │ │ │ │ │ │ │ └── rs_tester.h │ │ │ │ │ │ │ ├── rs_tester_fec_shim.c │ │ │ │ │ │ │ └── rs_tester_fec.c │ │ │ │ │ │ ├── appveyor.yml │ │ │ │ │ │ ├── LICENSE │ │ │ │ │ │ ├── tools │ │ │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ │ │ └── find_rs_primitive_poly.c │ │ │ │ │ │ └── .appveyor-install-tools.cmd │ │ │ │ │ ├── intx │ │ │ │ │ │ └── CMakeLists.txt │ │ │ │ │ ├── base91 │ │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ │ └── LICENSE │ │ │ │ │ ├── cxxopts │ │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ │ └── LICENSE │ │ │ │ │ ├── libpopcnt │ │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ │ └── LICENSE │ │ │ │ │ ├── zstd │ │ │ │ │ │ ├── decompress │ │ │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ │ │ └── zstd_ddict.h │ │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ │ ├── common │ │ │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ │ │ ├── xxhash.c │ │ │ │ │ │ │ ├── debug.c │ │ │ │ │ │ │ ├── allocations.h │ │ │ │ │ │ │ └── zstd_common.c │ │ │ │ │ │ ├── compress │ │ │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ │ │ ├── zstd_compress_superblock.h │ │ │ │ │ │ │ ├── zstd_fast.h │ │ │ │ │ │ │ ├── zstd_double_fast.h │ │ │ │ │ │ │ └── zstd_compress_literals.h │ │ │ │ │ │ └── LICENSE │ │ │ │ │ ├── wirehair │ │ │ │ │ │ ├── .gitattributes │ │ │ │ │ │ ├── .gitignore │ │ │ │ │ │ ├── LICENSE │ │ │ │ │ │ └── CMakeLists.txt │ │ │ │ │ ├── PicoSHA2 │ │ │ │ │ │ └── LICENSE │ │ │ │ │ └── fmt │ │ │ │ │ │ └── LICENSE.rst │ │ │ │ ├── lib │ │ │ │ │ ├── gui │ │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ │ ├── mat_to_gl.h │ │ │ │ │ │ ├── gl_program.h │ │ │ │ │ │ └── gl_shader.h │ │ │ │ │ ├── bit_file │ │ │ │ │ │ ├── test │ │ │ │ │ │ │ ├── test.cpp │ │ │ │ │ │ │ └── CMakeLists.txt │ │ │ │ │ │ └── CMakeLists.txt │ │ │ │ │ ├── encoder │ │ │ │ │ │ ├── test │ │ │ │ │ │ │ ├── test.cpp │ │ │ │ │ │ │ └── CMakeLists.txt │ │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ │ ├── ReedSolomon.h │ │ │ │ │ │ ├── DecoderPlus.h │ │ │ │ │ │ └── escrow_buffer_writer.h │ │ │ │ │ ├── fountain │ │ │ │ │ │ ├── test │ │ │ │ │ │ │ ├── test.cpp │ │ │ │ │ │ │ └── CMakeLists.txt │ │ │ │ │ │ ├── FountainInit.h │ │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ │ └── FountainEncoder.h │ │ │ │ │ ├── serialize │ │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ │ ├── format.h │ │ │ │ │ │ └── str_join.h │ │ │ │ │ ├── util │ │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ │ ├── bytebuf.h │ │ │ │ │ │ ├── vec_xy.h │ │ │ │ │ │ ├── byte_istream.h │ │ │ │ │ │ ├── ConfigScope.h │ │ │ │ │ │ ├── null_stream.h │ │ │ │ │ │ ├── MakeTempDirectory.h │ │ │ │ │ │ ├── Timer.h │ │ │ │ │ │ ├── loop_iterator.h │ │ │ │ │ │ └── File.h │ │ │ │ │ ├── cimbar_js │ │ │ │ │ │ ├── test │ │ │ │ │ │ │ ├── test.cpp │ │ │ │ │ │ │ └── CMakeLists.txt │ │ │ │ │ │ ├── cimbar_js.h │ │ │ │ │ │ └── cimbar_recv_js.h │ │ │ │ │ ├── compression │ │ │ │ │ │ ├── test │ │ │ │ │ │ │ ├── test.cpp │ │ │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ │ │ └── zstd_header_checkTest.cpp │ │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ │ ├── zstd_header_check.h │ │ │ │ │ │ └── zstd_dstream.h │ │ │ │ │ ├── extractor │ │ │ │ │ │ ├── test │ │ │ │ │ │ │ ├── test.cpp │ │ │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ │ │ ├── DeskewerTest.cpp │ │ │ │ │ │ │ ├── SimpleCameraCalibrationTest.cpp │ │ │ │ │ │ │ ├── UndistortTest.cpp │ │ │ │ │ │ │ ├── ExtractorTest.cpp │ │ │ │ │ │ │ ├── CornersTest.cpp │ │ │ │ │ │ │ └── ScanStateTest.cpp │ │ │ │ │ │ ├── Deskewer.cpp │ │ │ │ │ │ ├── Extractor.cpp │ │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ │ ├── DistortionParameters.h │ │ │ │ │ │ ├── DeskewerPlus.h │ │ │ │ │ │ ├── Midpoints.h │ │ │ │ │ │ ├── EdgeScanState.h │ │ │ │ │ │ ├── Extractor.h │ │ │ │ │ │ ├── ExtractorPlus.h │ │ │ │ │ │ ├── Deskewer.h │ │ │ │ │ │ ├── Undistort.h │ │ │ │ │ │ └── SimpleCameraCalibration.h │ │ │ │ │ ├── image_hash │ │ │ │ │ │ ├── test │ │ │ │ │ │ │ ├── test.cpp │ │ │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ │ │ └── averageHashTest.cpp │ │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ │ └── hamming_distance.h │ │ │ │ │ ├── cimb_translator │ │ │ │ │ │ ├── test │ │ │ │ │ │ │ ├── test.cpp │ │ │ │ │ │ │ ├── CellPositionsTest.cpp │ │ │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ │ │ ├── LinearDecodePositionsTest.cpp │ │ │ │ │ │ │ ├── CimbEncoderTest.cpp │ │ │ │ │ │ │ ├── CellDriftTest.cpp │ │ │ │ │ │ │ └── CimbWriterTest.cpp │ │ │ │ │ │ ├── PositionData.h │ │ │ │ │ │ ├── Common.h │ │ │ │ │ │ ├── CellDrift.h │ │ │ │ │ │ ├── CimbEncoder.h │ │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ │ ├── CimbWriter.h │ │ │ │ │ │ ├── CellDrift.cpp │ │ │ │ │ │ ├── AdjacentCellFinder.h │ │ │ │ │ │ ├── CellPositions.h │ │ │ │ │ │ ├── CimbEncoder.cpp │ │ │ │ │ │ ├── CimbReader.h │ │ │ │ │ │ ├── Interleave.h │ │ │ │ │ │ ├── LinearDecodePositions.h │ │ │ │ │ │ └── FloodDecodePositions.h │ │ │ │ │ └── chromatic_adaptation │ │ │ │ │ │ ├── test │ │ │ │ │ │ ├── test.cpp │ │ │ │ │ │ └── CMakeLists.txt │ │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ │ └── adaptation_transform.h │ │ │ │ └── exe │ │ │ │ │ ├── build_image_assets │ │ │ │ │ └── CMakeLists.txt │ │ │ │ │ ├── cimbar_send │ │ │ │ │ └── CMakeLists.txt │ │ │ │ │ ├── cimbar_recv2 │ │ │ │ │ └── CMakeLists.txt │ │ │ │ │ ├── cimbar_extract │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ └── cimbar_extract.cpp │ │ │ │ │ ├── cimbar │ │ │ │ │ └── CMakeLists.txt │ │ │ │ │ └── cimbar_recv │ │ │ │ │ └── CMakeLists.txt │ │ │ ├── bitmap │ │ │ │ ├── 2 │ │ │ │ │ ├── 00.png │ │ │ │ │ ├── 01.png │ │ │ │ │ ├── 02.png │ │ │ │ │ └── 03.png │ │ │ │ ├── 4 │ │ │ │ │ ├── 00.png │ │ │ │ │ ├── 01.png │ │ │ │ │ ├── 02.png │ │ │ │ │ ├── 03.png │ │ │ │ │ ├── 04.png │ │ │ │ │ ├── 05.png │ │ │ │ │ ├── 06.png │ │ │ │ │ ├── 07.png │ │ │ │ │ ├── 08.png │ │ │ │ │ ├── 09.png │ │ │ │ │ ├── 0a.png │ │ │ │ │ ├── 0b.png │ │ │ │ │ ├── 0c.png │ │ │ │ │ ├── 0d.png │ │ │ │ │ ├── 0e.png │ │ │ │ │ └── 0f.png │ │ │ │ ├── anchor-dark.png │ │ │ │ ├── anchor-light.png │ │ │ │ ├── guide-vertical-dark.png │ │ │ │ ├── anchor-secondary-dark.png │ │ │ │ ├── anchor-secondary-light.png │ │ │ │ ├── guide-horizontal-dark.png │ │ │ │ ├── guide-horizontal-light.png │ │ │ │ └── guide-vertical-light.png │ │ │ ├── web │ │ │ │ ├── favicon.ico │ │ │ │ ├── icon-192x192.png │ │ │ │ ├── icon-512x512.png │ │ │ │ ├── test │ │ │ │ │ ├── test.md │ │ │ │ │ └── run-in-browser.js │ │ │ │ ├── pwa.json │ │ │ │ ├── pwa-recv.json │ │ │ │ ├── sw.js │ │ │ │ ├── wasmgz.sh │ │ │ │ ├── recv-sw.js │ │ │ │ └── test_recv.html │ │ │ ├── .gitmodules │ │ │ ├── .gitignore │ │ │ ├── package-cimbar-html.py │ │ │ ├── package-wasm.sh │ │ │ ├── package-portable-linux.sh │ │ │ ├── .github │ │ │ │ └── workflows │ │ │ │ │ ├── release.yml │ │ │ │ │ └── ci.yml │ │ │ ├── CMakeLists.txt │ │ │ └── WASM.md │ │ ├── concurrent │ │ │ ├── CMakeLists.txt │ │ │ └── monitor.h │ │ ├── cfc-cpp │ │ │ └── CMakeLists.txt │ │ └── CMakeLists.txt │ └── main │ │ ├── res │ │ ├── drawable-hdpi │ │ │ ├── ic_mode4c.png │ │ │ ├── ic_modeb.png │ │ │ ├── ic_modebm.png │ │ │ └── ic_modeguess.png │ │ ├── drawable-ldpi │ │ │ ├── ic_mode4c.png │ │ │ ├── ic_modeb.png │ │ │ ├── ic_modebm.png │ │ │ └── ic_modeguess.png │ │ ├── drawable-mdpi │ │ │ ├── ic_mode4c.png │ │ │ ├── ic_modeb.png │ │ │ ├── ic_modebm.png │ │ │ └── ic_modeguess.png │ │ ├── drawable-xhdpi │ │ │ ├── ic_mode4c.png │ │ │ ├── ic_modeb.png │ │ │ ├── ic_modebm.png │ │ │ └── ic_modeguess.png │ │ ├── drawable-xxhdpi │ │ │ ├── ic_modeb.png │ │ │ ├── ic_mode4c.png │ │ │ ├── ic_modebm.png │ │ │ └── ic_modeguess.png │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher_round.png │ │ ├── values │ │ │ ├── strings.xml │ │ │ ├── colors.xml │ │ │ ├── attrs.xml │ │ │ └── styles.xml │ │ ├── drawable │ │ │ └── modesel.xml │ │ └── layout │ │ │ └── activity_main.xml │ │ └── AndroidManifest.xml ├── proguard-rules.pro └── build.gradle ├── fastlane └── metadata │ └── android │ ├── de │ └── short_description.txt │ ├── ru │ ├── short_description.txt │ └── full_description.txt │ └── en-US │ ├── short_description.txt │ ├── images │ ├── icon.png │ ├── featureGraphic.png │ └── phoneScreenshots │ │ ├── 1.jpg │ │ └── 2.jpg │ └── full_description.txt ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── settings.gradle ├── .gitignore ├── LICENSE └── gradle.properties /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/test/py/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/libcorrect/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | -------------------------------------------------------------------------------- /fastlane/metadata/android/de/short_description.txt: -------------------------------------------------------------------------------- 1 | Datenübertragung per Kamera – auch im Flugmodus -------------------------------------------------------------------------------- /fastlane/metadata/android/ru/short_description.txt: -------------------------------------------------------------------------------- 1 | Передача данных через камеру, даже в авиарежиме. 2 | -------------------------------------------------------------------------------- /fastlane/metadata/android/en-US/short_description.txt: -------------------------------------------------------------------------------- 1 | use your camera to transfer data – even in airplane mode -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/bitmap/2/00.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/cpp/libcimbar/bitmap/2/00.png -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/bitmap/2/01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/cpp/libcimbar/bitmap/2/01.png -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/bitmap/2/02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/cpp/libcimbar/bitmap/2/02.png -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/bitmap/2/03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/cpp/libcimbar/bitmap/2/03.png -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/bitmap/4/00.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/cpp/libcimbar/bitmap/4/00.png -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/bitmap/4/01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/cpp/libcimbar/bitmap/4/01.png -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/bitmap/4/02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/cpp/libcimbar/bitmap/4/02.png -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/bitmap/4/03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/cpp/libcimbar/bitmap/4/03.png -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/bitmap/4/04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/cpp/libcimbar/bitmap/4/04.png -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/bitmap/4/05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/cpp/libcimbar/bitmap/4/05.png -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/bitmap/4/06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/cpp/libcimbar/bitmap/4/06.png -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/bitmap/4/07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/cpp/libcimbar/bitmap/4/07.png -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/bitmap/4/08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/cpp/libcimbar/bitmap/4/08.png -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/bitmap/4/09.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/cpp/libcimbar/bitmap/4/09.png -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/bitmap/4/0a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/cpp/libcimbar/bitmap/4/0a.png -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/bitmap/4/0b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/cpp/libcimbar/bitmap/4/0b.png -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/bitmap/4/0c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/cpp/libcimbar/bitmap/4/0c.png -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/bitmap/4/0d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/cpp/libcimbar/bitmap/4/0d.png -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/bitmap/4/0e.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/cpp/libcimbar/bitmap/4/0e.png -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/bitmap/4/0f.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/cpp/libcimbar/bitmap/4/0f.png -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/web/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/cpp/libcimbar/web/favicon.ico -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/web/icon-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/cpp/libcimbar/web/icon-192x192.png -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/web/icon-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/cpp/libcimbar/web/icon-512x512.png -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/bitmap/anchor-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/cpp/libcimbar/bitmap/anchor-dark.png -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/bitmap/anchor-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/cpp/libcimbar/bitmap/anchor-light.png -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/gui/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | add_library(gui INTERFACE) 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_mode4c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/main/res/drawable-hdpi/ic_mode4c.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_modeb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/main/res/drawable-hdpi/ic_modeb.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_modebm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/main/res/drawable-hdpi/ic_modebm.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-ldpi/ic_mode4c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/main/res/drawable-ldpi/ic_mode4c.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-ldpi/ic_modeb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/main/res/drawable-ldpi/ic_modeb.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-ldpi/ic_modebm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/main/res/drawable-ldpi/ic_modebm.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_mode4c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/main/res/drawable-mdpi/ic_mode4c.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_modeb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/main/res/drawable-mdpi/ic_modeb.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_modebm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/main/res/drawable-mdpi/ic_modebm.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_mode4c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/main/res/drawable-xhdpi/ic_mode4c.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_modeb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/main/res/drawable-xhdpi/ic_modeb.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_modebm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/main/res/drawable-xhdpi/ic_modebm.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_modeb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/main/res/drawable-xxhdpi/ic_modeb.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_modeguess.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/main/res/drawable-hdpi/ic_modeguess.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-ldpi/ic_modeguess.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/main/res/drawable-ldpi/ic_modeguess.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_modeguess.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/main/res/drawable-mdpi/ic_modeguess.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_mode4c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/main/res/drawable-xxhdpi/ic_mode4c.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_modebm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/main/res/drawable-xxhdpi/ic_modebm.png -------------------------------------------------------------------------------- /fastlane/metadata/android/en-US/images/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/fastlane/metadata/android/en-US/images/icon.png -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/libcorrect/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(convolutional) 2 | add_subdirectory(reed-solomon) 3 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_modeguess.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/main/res/drawable-xhdpi/ic_modeguess.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_modeguess.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/main/res/drawable-xxhdpi/ic_modeguess.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "samples"] 2 | path = samples 3 | url = https://github.com/sz3/cimbar-samples 4 | ignore = dirty 5 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/bitmap/guide-vertical-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/cpp/libcimbar/bitmap/guide-vertical-dark.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/bitmap/anchor-secondary-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/cpp/libcimbar/bitmap/anchor-secondary-dark.png -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/bitmap/anchor-secondary-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/cpp/libcimbar/bitmap/anchor-secondary-light.png -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/bitmap/guide-horizontal-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/cpp/libcimbar/bitmap/guide-horizontal-dark.png -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/bitmap/guide-horizontal-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/cpp/libcimbar/bitmap/guide-horizontal-light.png -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/bitmap/guide-vertical-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/cpp/libcimbar/bitmap/guide-vertical-light.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /fastlane/metadata/android/en-US/images/featureGraphic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/fastlane/metadata/android/en-US/images/featureGraphic.png -------------------------------------------------------------------------------- /fastlane/metadata/android/en-US/images/phoneScreenshots/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/fastlane/metadata/android/en-US/images/phoneScreenshots/1.jpg -------------------------------------------------------------------------------- /fastlane/metadata/android/en-US/images/phoneScreenshots/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sz3/cfc/HEAD/fastlane/metadata/android/en-US/images/phoneScreenshots/2.jpg -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name='CameraFileCopy' 2 | include ':app' 3 | 4 | include ':opencv' 5 | project(':opencv').projectDir = new File(opencvsdk + '/sdk') 6 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/intx/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | set(SOURCES 4 | intx.hpp 5 | ) 6 | 7 | add_library(intx INTERFACE) 8 | 9 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/base91/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | set(SOURCES 4 | base.hpp 5 | ) 6 | 7 | add_library(base91 INTERFACE) 8 | 9 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/web/test/test.md: -------------------------------------------------------------------------------- 1 | # (cd .. && python3 -m http.server 8080 &) 2 | # (cd .. && npx http-server &) 3 | npm install --save-dev puppeteer qunit 4 | node run-in-browser.js 5 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/cxxopts/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | set(SOURCES 4 | cxxopts.hpp 5 | ) 6 | 7 | add_library(cxxopts INTERFACE) 8 | 9 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/libpopcnt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | set(SOURCES 4 | libpopcnt.h 5 | ) 6 | 7 | add_library(libpopcnt INTERFACE) 8 | 9 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/libcorrect/src/reed-solomon/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SRCFILES polynomial.c reed-solomon.c encode.c decode.c) 2 | add_library(correct-reed-solomon OBJECT ${SRCFILES}) 3 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/libcorrect/src/convolutional/sse/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SRCFILES lookup.c convolutional.c encode.c decode.c) 2 | add_library(correct-convolutional-sse OBJECT ${SRCFILES}) 3 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | CameraFileCopy 3 | Mode 4C 4 | Mode B 5 | 6 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/bit_file/test/test.cpp: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #define CATCH_CONFIG_MAIN 3 | #include "catch.hpp" 4 | 5 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/encoder/test/test.cpp: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #define CATCH_CONFIG_MAIN 3 | #include "catch.hpp" 4 | 5 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/fountain/test/test.cpp: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #define CATCH_CONFIG_MAIN 3 | #include "catch.hpp" 4 | 5 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/serialize/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | set(SOURCES 4 | format.h 5 | str.h 6 | str_join.h 7 | ) 8 | 9 | add_library(serialize INTERFACE) 10 | 11 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/util/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | set(SOURCES 4 | File.h 5 | MakeTempDirectory.h 6 | Timer.h 7 | ) 8 | 9 | add_library(util INTERFACE) 10 | 11 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/libcorrect/include/correct/reed-solomon/decode.h: -------------------------------------------------------------------------------- 1 | #include "correct/reed-solomon.h" 2 | #include "correct/reed-solomon/field.h" 3 | #include "correct/reed-solomon/polynomial.h" 4 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/libcorrect/include/correct/reed-solomon/encode.h: -------------------------------------------------------------------------------- 1 | #include "correct/reed-solomon.h" 2 | #include "correct/reed-solomon/field.h" 3 | #include "correct/reed-solomon/polynomial.h" 4 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/cimbar_js/test/test.cpp: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #define CATCH_CONFIG_MAIN 3 | #include "catch.hpp" 4 | 5 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/compression/test/test.cpp: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #define CATCH_CONFIG_MAIN 3 | #include "catch.hpp" 4 | 5 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/extractor/test/test.cpp: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #define CATCH_CONFIG_MAIN 3 | #include "catch.hpp" 4 | 5 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/image_hash/test/test.cpp: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #define CATCH_CONFIG_MAIN 3 | #include "catch.hpp" 4 | 5 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/libcorrect/include/correct/reed-solomon/reed-solomon.h: -------------------------------------------------------------------------------- 1 | #include "correct/reed-solomon.h" 2 | #include "correct/reed-solomon/field.h" 3 | #include "correct/reed-solomon/polynomial.h" 4 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/cimb_translator/test/test.cpp: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #define CATCH_CONFIG_MAIN 3 | #include "catch.hpp" 4 | 5 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/chromatic_adaptation/test/test.cpp: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #define CATCH_CONFIG_MAIN 3 | #include "catch.hpp" 4 | 5 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/serialize/format.h: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #pragma once 3 | 4 | #define FMT_HEADER_ONLY 5 | #include "fmt/format.h" 6 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #6200EE 4 | #3700B3 5 | #03DAC5 6 | 7 | -------------------------------------------------------------------------------- /app/src/cpp/concurrent/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | set(SOURCES 4 | monitor.h 5 | thread_pool.h 6 | ) 7 | 8 | include_directories( 9 | ${CMAKE_CURRENT_SOURCE_DIR} 10 | ) 11 | 12 | add_library(concurrent INTERFACE) 13 | 14 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/bit_file/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | set(SOURCES 4 | bitreader.h 5 | bitbuffer.h 6 | ) 7 | 8 | add_library(bit_file INTERFACE) 9 | 10 | if(NOT DEFINED DISABLE_TESTS) 11 | add_subdirectory(test) 12 | endif() 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/cimb_translator/PositionData.h: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #pragma once 3 | 4 | struct PositionData 5 | { 6 | unsigned i = 0; 7 | int x = 0; 8 | int y = 0; 9 | }; 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/libcorrect/src/convolutional/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SRCFILES bit.c metric.c history_buffer.c error_buffer.c lookup.c convolutional.c encode.c decode.c) 2 | add_library(correct-convolutional OBJECT ${SRCFILES}) 3 | if(HAVE_SSE) 4 | add_subdirectory(sse) 5 | endif() 6 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/.gitignore: -------------------------------------------------------------------------------- 1 | .cmake/ 2 | CMakeFiles/ 3 | Testing/ 4 | build*/ 5 | dist/ 6 | opencv4/ 7 | web/test/node_modules/ 8 | web/cimbar_js.js 9 | web/cimbar_js.wasm 10 | CMakeCache.txt 11 | CMakeLists.txt.* 12 | CTestTestfile.cmake 13 | Makefile 14 | callgrind.out* 15 | cmake_install.cmake 16 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/chromatic_adaptation/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | set(SOURCES 4 | adaptation_transform.h 5 | color_correction.h 6 | ) 7 | 8 | add_library(chromatic_adaptation INTERFACE) 9 | 10 | if(NOT DEFINED DISABLE_TESTS) 11 | add_subdirectory(test) 12 | endif() 13 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/libcorrect/.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | matrix: 3 | include: 4 | - os: linux 5 | dist: trusty 6 | - os: osx 7 | script: 8 | - mkdir build 9 | - cd build 10 | - cmake .. 11 | - make shim 12 | - make check CTEST_OUTPUT_ON_FAILURE=TRUE 13 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/compression/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | set(SOURCES 4 | zstd_compressor.h 5 | zstd_decompressor.h 6 | zstd_header_check.h 7 | ) 8 | 9 | add_library(compression INTERFACE) 10 | 11 | if(NOT DEFINED DISABLE_TESTS) 12 | add_subdirectory(test) 13 | endif() 14 | 15 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/image_hash/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | set(SOURCES 4 | ahash_result.h 5 | average_hash.h 6 | bit_extractor.h 7 | hamming_distance.h 8 | ) 9 | 10 | add_library(image_hash INTERFACE) 11 | 12 | if(NOT DEFINED DISABLE_TESTS) 13 | add_subdirectory(test) 14 | endif() 15 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/exe/build_image_assets/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | project(build_image_assets) 4 | 5 | set (SOURCES 6 | build_image_assets.cpp 7 | ) 8 | 9 | add_executable ( 10 | build_image_assets 11 | ${SOURCES} 12 | ) 13 | 14 | target_link_libraries(build_image_assets 15 | 16 | 17 | ) 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/fountain/FountainInit.h: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #pragma once 3 | 4 | #include "wirehair/wirehair.h" 5 | 6 | namespace FountainInit { 7 | static bool init() 8 | { 9 | static WirehairResult res = wirehair_init(); 10 | return !res; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/zstd/decompress/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SRCFILES huf_decompress.c zstd_ddict.h zstd_decompress_block.h zstd_decompress_internal.h 2 | huf_decompress_amd64.S zstd_ddict.c zstd_decompress_block.c zstd_decompress.c) 3 | add_library(zstd-decompress OBJECT ${SRCFILES}) 4 | 5 | target_compile_options(zstd-decompress PUBLIC "-DZSTD_DISABLE_ASM") 6 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/util/bytebuf.h: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #pragma once 3 | 4 | #include 5 | 6 | namespace cimbar { 7 | 8 | struct bytebuf : public std::streambuf 9 | { 10 | bytebuf(char* data, size_t len) 11 | { 12 | setg(data, data, data + len); 13 | } 14 | }; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/libcorrect/util/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(error_sim OBJECT error-sim.c) 2 | 3 | add_library(error_sim_shim OBJECT error-sim.c error-sim-shim.c) 4 | 5 | if(HAVE_LIBFEC) 6 | add_library(error_sim_fec OBJECT error-sim.c error-sim-fec.c) 7 | endif() 8 | 9 | if(HAVE_SSE) 10 | add_library(error_sim_sse OBJECT error-sim.c error-sim-sse.c) 11 | endif() 12 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/encoder/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | set(SOURCES 4 | Decoder.h 5 | DecoderPlus.h 6 | Encoder.h 7 | EncoderPlus.h 8 | ReedSolomon.h 9 | aligned_stream.h 10 | escrow_buffer_writer.h 11 | reed_solomon_stream.h 12 | ) 13 | 14 | add_library(encoder INTERFACE) 15 | 16 | if(NOT DEFINED DISABLE_TESTS) 17 | add_subdirectory(test) 18 | endif() 19 | 20 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/image_hash/hamming_distance.h: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #pragma once 3 | 4 | #include "libpopcnt/libpopcnt.h" 5 | 6 | namespace image_hash 7 | { 8 | template 9 | inline unsigned hamming_distance(Integer a, Integer b) 10 | { 11 | return popcnt64(a xor b); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/libcorrect/include/correct/util/error-sim-sse.h: -------------------------------------------------------------------------------- 1 | #include "correct/util/error-sim.h" 2 | 3 | #include "correct-sse.h" 4 | 5 | size_t conv_correct_sse_enclen(void *conv_v, size_t msg_len); 6 | void conv_correct_sse_encode(void *conv_v, uint8_t *msg, size_t msg_len, uint8_t *encoded); 7 | ssize_t conv_correct_sse_decode(void *conv_v, uint8_t *soft, size_t soft_len, uint8_t *msg); 8 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/util/vec_xy.h: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #pragma once 3 | 4 | namespace cimbar { 5 | 6 | struct vec_xy 7 | { 8 | unsigned x = 0; 9 | unsigned y = 0; 10 | 11 | unsigned width() const 12 | { 13 | return x; 14 | }; 15 | 16 | unsigned height() const 17 | { 18 | return y; 19 | } 20 | }; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/web/pwa.json: -------------------------------------------------------------------------------- 1 | { 2 | "lang": "en", 3 | "dir": "ltr", 4 | "name": "cimbar.org Send", 5 | "short_name": "cimbar.org", 6 | "icons": [{"src":"icon-192x192.png","sizes":"192x192","type":"image/png"},{"src":"icon-512x512.png","sizes":"512x512","type":"image/png"}], 7 | "scope": "/", 8 | "start_url": "index.html", 9 | "display": "fullscreen", 10 | "theme_color": "aliceblue", 11 | "background_color": "black" 12 | } 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/zstd/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | project(zstd C) 3 | 4 | add_subdirectory(common) 5 | add_subdirectory(compress) 6 | add_subdirectory(decompress) 7 | 8 | set(zstd_obj_files $ $ $) 9 | 10 | add_library(zstd ${zstd_obj_files}) 11 | 12 | target_compile_options(zstd PUBLIC "-DZSTD_STATIC_LINKING_ONLY") 13 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/fountain/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | set(SOURCES 4 | concurrent_fountain_decoder_sink.h 5 | FountainDecoder.h 6 | FountainEncoder.h 7 | FountainInit.h 8 | FountainMetadata.h 9 | fountain_decoder_sink.h 10 | fountain_decoder_stream.h 11 | fountain_encoder_stream.h 12 | ) 13 | 14 | add_library(fountain INTERFACE) 15 | 16 | if(NOT DEFINED DISABLE_TESTS) 17 | add_subdirectory(test) 18 | endif() 19 | 20 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/util/byte_istream.h: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #pragma once 3 | 4 | #include "bytebuf.h" 5 | #include 6 | 7 | namespace cimbar { 8 | 9 | struct byte_istream : std::istream 10 | { 11 | byte_istream(const char* data, unsigned len) 12 | : std::istream(&_buf) 13 | , _buf((char*)data, len) 14 | { 15 | } 16 | 17 | bytebuf _buf; 18 | }; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/bit_file/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | project(bit_file_test) 4 | 5 | set (SOURCES 6 | test.cpp 7 | bitbufferTest.cpp 8 | bitreaderTest.cpp 9 | ) 10 | 11 | include_directories( 12 | ${libcimbar_SOURCE_DIR}/test 13 | ${libcimbar_SOURCE_DIR}/test/lib 14 | ${CMAKE_CURRENT_SOURCE_DIR}/.. 15 | ) 16 | 17 | add_executable ( 18 | bit_file_test 19 | ${SOURCES} 20 | ) 21 | 22 | add_test(bit_file_test bit_file_test) 23 | 24 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/libcorrect/include/correct/util/error-sim-fec.h: -------------------------------------------------------------------------------- 1 | #include "correct/util/error-sim.h" 2 | 3 | #include 4 | 5 | void conv_fec27_decode(void *conv_v, uint8_t *soft, size_t soft_len, uint8_t *msg); 6 | void conv_fec29_decode(void *conv_v, uint8_t *soft, size_t soft_len, uint8_t *msg); 7 | void conv_fec39_decode(void *conv_v, uint8_t *soft, size_t soft_len, uint8_t *msg); 8 | void conv_fec615_decode(void *conv_v, uint8_t *soft, size_t soft_len, uint8_t *msg); 9 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/libcorrect/include/correct/convolutional/sse/convolutional.h: -------------------------------------------------------------------------------- 1 | #include "correct/convolutional/convolutional.h" 2 | #include "correct/convolutional/sse/lookup.h" 3 | // BIG HEAPING TODO sort out the include mess 4 | #include "correct-sse.h" 5 | #ifdef _MSC_VER 6 | #include 7 | #else 8 | #include 9 | #endif 10 | 11 | 12 | struct correct_convolutional_sse { 13 | correct_convolutional base_conv; 14 | oct_lookup_t oct_lookup; 15 | }; 16 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/test/py/helpers.py: -------------------------------------------------------------------------------- 1 | from os.path import join, realpath, dirname 2 | from tempfile import TemporaryDirectory 3 | 4 | CIMBAR_SRC = realpath(join(dirname(realpath(__file__)), '..', '..')) 5 | BIN_DIR = join(CIMBAR_SRC, 'dist', 'bin') 6 | 7 | 8 | class TestDirMixin(): 9 | def setUp(self): 10 | self.working_dir = TemporaryDirectory() 11 | super().setUp() 12 | 13 | def tearDown(self): 14 | super().tearDown() 15 | with self.working_dir: 16 | pass -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/libcorrect/include/correct/util/error-sim-shim.h: -------------------------------------------------------------------------------- 1 | #include "correct/util/error-sim.h" 2 | #include "fec_shim.h" 3 | 4 | ssize_t conv_shim27_decode(void *conv_v, uint8_t *soft, size_t soft_len, uint8_t *msg); 5 | ssize_t conv_shim29_decode(void *conv_v, uint8_t *soft, size_t soft_len, uint8_t *msg); 6 | ssize_t conv_shim39_decode(void *conv_v, uint8_t *soft, size_t soft_len, uint8_t *msg); 7 | ssize_t conv_shim615_decode(void *conv_v, uint8_t *soft, size_t soft_len, uint8_t *msg); 8 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/wirehair/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/zstd/common/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SRCFILES allocations.h debug.c error_private.c fse.h pool.c threading.c xxhash.h zstd_internal.h 2 | bits.h compiler.h debug.h error_private.h huf.h pool.h threading.h zstd_common.c zstd_trace.h 3 | bitstream.h cpu.h entropy_common.c fse_decompress.c mem.h portability_macros.h xxhash.c zstd_deps.h 4 | ) 5 | add_library(zstd-common OBJECT ${SRCFILES}) 6 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/util/ConfigScope.h: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #pragma once 3 | 4 | #include "cimb_translator/Config.h" 5 | 6 | class ConfigScope : cimbar::Config 7 | { 8 | public: 9 | using cimbar::Config::active_conf; 10 | 11 | ConfigScope(int mode_val=0) 12 | { 13 | cimbar::Config::update(mode_val); 14 | } 15 | 16 | ~ConfigScope() 17 | { 18 | // reset 19 | cimbar::Config::update(); 20 | } 21 | 22 | protected: 23 | }; 24 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/libcorrect/tests/include/rs_tester_fec.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | void rs_fec_encode(void *encoder, uint8_t *msg, size_t msg_length, 7 | uint8_t *msg_out); 8 | void rs_fec_decode(void *decoder, uint8_t *encoded, size_t encoded_length, 9 | uint8_t *erasure_locations, size_t erasure_length, 10 | uint8_t *msg, size_t pad_length, size_t num_roots); 11 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/libcorrect/tests/include/rs_tester_fec_shim.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "fec_shim.h" 6 | void rs_fec_encode(void *encoder, uint8_t *msg, size_t msg_length, 7 | uint8_t *msg_out); 8 | void rs_fec_decode(void *decoder, uint8_t *encoded, size_t encoded_length, 9 | uint8_t *erasure_locations, size_t erasure_length, 10 | uint8_t *msg, size_t pad_length, size_t num_roots); 11 | -------------------------------------------------------------------------------- /app/src/cpp/cfc-cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.4.1) 2 | 3 | add_library(cfc-cpp 4 | SHARED 5 | 6 | jni.cpp 7 | MultiThreadedDecoder.h 8 | ) 9 | 10 | find_library(log-lib 11 | 12 | log 13 | ) 14 | 15 | target_link_libraries(cfc-cpp 16 | 17 | cimb_translator 18 | extractor 19 | 20 | correct_static 21 | wirehair 22 | zstd 23 | ${OPENCV_LIBS} 24 | ${log-lib} 25 | ) 26 | 27 | target_compile_options(cfc-cpp PUBLIC "-DZSTD_STATIC_LINKING_ONLY") 28 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/util/null_stream.h: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #pragma once 3 | 4 | class null_stream 5 | { 6 | public: 7 | null_stream() 8 | {} 9 | 10 | null_stream& write(const char*, unsigned length) 11 | { 12 | _count += length; 13 | return *this; 14 | } 15 | 16 | bool good() const 17 | { 18 | return true; 19 | } 20 | 21 | long tellp() const 22 | { 23 | return _count; 24 | } 25 | 26 | protected: 27 | long _count = 0; 28 | }; 29 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/libcorrect/src/convolutional/sse/encode.c: -------------------------------------------------------------------------------- 1 | #include "correct/convolutional/sse/convolutional.h" 2 | 3 | size_t correct_convolutional_sse_encode_len(correct_convolutional_sse *conv, size_t msg_len) { 4 | return correct_convolutional_encode_len(&conv->base_conv, msg_len); 5 | } 6 | 7 | size_t correct_convolutional_sse_encode(correct_convolutional_sse *conv, const uint8_t *msg, size_t msg_len, uint8_t *encoded) { 8 | return correct_convolutional_encode(&conv->base_conv, msg, msg_len, encoded); 9 | } 10 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/web/pwa-recv.json: -------------------------------------------------------------------------------- 1 | { 2 | "lang": "en", 3 | "dir": "ltr", 4 | "name": "cimbar.org Receiver", 5 | "short_name": "cimbar recv", 6 | "icons": [{"src":"icon-192x192.png","sizes":"192x192","type":"image/png"},{"src":"icon-512x512.png","sizes":"512x512","type":"image/png","purpose": "any"},{"src":"icon-512x512-maskable.png","sizes":"512x512","type":"image/png","purpose": "maskable"}], 7 | "scope": "/", 8 | "start_url": "recv.html", 9 | "display": "fullscreen", 10 | "theme_color": "aliceblue", 11 | "background_color": "black" 12 | } 13 | 14 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/extractor/Deskewer.cpp: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #include "Deskewer.h" 3 | #include "cimb_translator/Config.h" 4 | 5 | Deskewer::Deskewer(cimbar::vec_xy image_size, unsigned anchor_size) 6 | : _imageSize({ 7 | image_size.width()? image_size.width() : cimbar::Config::image_size_x(), 8 | image_size.height()? image_size.height() : cimbar::Config::image_size_y()}) 9 | , _anchorSize(anchor_size? anchor_size : cimbar::Config::anchor_size()) 10 | { 11 | } 12 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/libcorrect/include/correct/convolutional/error_buffer.h: -------------------------------------------------------------------------------- 1 | #include "correct/convolutional.h" 2 | 3 | typedef struct { 4 | unsigned int index; 5 | distance_t *errors[2]; 6 | unsigned int num_states; 7 | 8 | const distance_t *read_errors; 9 | distance_t *write_errors; 10 | } error_buffer_t; 11 | 12 | error_buffer_t *error_buffer_create(unsigned int num_states); 13 | void error_buffer_destroy(error_buffer_t *buf); 14 | void error_buffer_reset(error_buffer_t *buf); 15 | void error_buffer_swap(error_buffer_t *buf); 16 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/extractor/Extractor.cpp: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #include "Extractor.h" 3 | 4 | #include "cimb_translator/Config.h" 5 | 6 | Extractor::Extractor(cimbar::vec_xy image_size, unsigned anchor_size) 7 | : _imageSize({ 8 | image_size.width()? image_size.width() : cimbar::Config::image_size_x(), 9 | image_size.height()? image_size.height() : cimbar::Config::image_size_y()}) 10 | , _anchorSize(anchor_size? anchor_size : cimbar::Config::anchor_size()) 11 | { 12 | } 13 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/extractor/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | set(SOURCES 4 | Anchor.h 5 | Corners.h 6 | Deskewer.cpp 7 | Deskewer.h 8 | DistortionParameters.h 9 | EdgeScanState.h 10 | Extractor.cpp 11 | Extractor.h 12 | Geometry.h 13 | Midpoints.h 14 | Point.h 15 | ScanState.h 16 | Scanner.cpp 17 | Scanner.h 18 | SimpleCameraCalibration.cpp 19 | SimpleCameraCalibration.h 20 | Undistort.h 21 | ) 22 | 23 | add_library(extractor STATIC ${SOURCES}) 24 | 25 | if(NOT DEFINED DISABLE_TESTS) 26 | add_subdirectory(test) 27 | endif() 28 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/exe/cimbar_send/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | project(cimbar_send) 4 | 5 | set (SOURCES 6 | send.cpp 7 | ) 8 | 9 | add_executable ( 10 | cimbar_send 11 | ${SOURCES} 12 | ) 13 | 14 | target_link_libraries(cimbar_send 15 | 16 | cimbar_js 17 | ) 18 | 19 | add_custom_command( 20 | TARGET cimbar_send POST_BUILD 21 | COMMAND ${CMAKE_COMMAND} -E copy $ cimbar_send.dbg 22 | COMMAND ${CMAKE_STRIP} -g $ 23 | ) 24 | 25 | install( 26 | TARGETS cimbar_send 27 | DESTINATION bin 28 | ) 29 | 30 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/exe/cimbar_recv2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | project(cimbar_recv2) 4 | 5 | set (SOURCES 6 | recv2.cpp 7 | ) 8 | 9 | add_executable ( 10 | cimbar_recv2 11 | ${SOURCES} 12 | ) 13 | 14 | target_link_libraries(cimbar_recv2 15 | 16 | cimbar_js 17 | extractor 18 | 19 | GL 20 | glfw 21 | ${OPENCV_LIBS} 22 | opencv_videoio 23 | ) 24 | 25 | add_custom_command( 26 | TARGET cimbar_recv2 POST_BUILD 27 | COMMAND ${CMAKE_COMMAND} -E copy $ cimbar_recv2.dbg 28 | COMMAND ${CMAKE_STRIP} -g $ 29 | ) 30 | 31 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/chromatic_adaptation/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | project(chromatic_adaptation_test) 4 | 5 | set (SOURCES 6 | test.cpp 7 | color_correctionTest.cpp 8 | ) 9 | 10 | include_directories( 11 | ${libcimbar_SOURCE_DIR}/test 12 | ${libcimbar_SOURCE_DIR}/test/lib 13 | ${CMAKE_CURRENT_SOURCE_DIR}/.. 14 | ) 15 | 16 | add_executable ( 17 | chromatic_adaptation_test 18 | ${SOURCES} 19 | ) 20 | 21 | add_test(chromatic_adaptation_test chromatic_adaptation_test) 22 | 23 | target_link_libraries(chromatic_adaptation_test 24 | 25 | ${OPENCV_LIBS} 26 | ) 27 | 28 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/cimb_translator/Common.h: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #pragma once 3 | 4 | #include 5 | #include 6 | 7 | namespace cimbar 8 | { 9 | using RGB = std::tuple; 10 | 11 | cv::Mat load_img(std::string path); 12 | 13 | std::tuple getColor(unsigned index, unsigned num_colors, unsigned color_mode); 14 | cv::Mat getTile(unsigned symbol_bits, unsigned symbol, bool dark=true, unsigned num_colors=4, unsigned color=0, unsigned color_mode=1); 15 | } 16 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/image_hash/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | project(image_hash_test) 4 | 5 | set (SOURCES 6 | test.cpp 7 | averageHashTest.cpp 8 | bitExtractorTest.cpp 9 | fuzzyAhashTest.cpp 10 | ) 11 | 12 | include_directories( 13 | ${libcimbar_SOURCE_DIR}/test 14 | ${libcimbar_SOURCE_DIR}/test/lib 15 | ${CMAKE_CURRENT_SOURCE_DIR}/.. 16 | ) 17 | 18 | add_executable ( 19 | image_hash_test 20 | ${SOURCES} 21 | ) 22 | 23 | add_test(image_hash_test image_hash_test) 24 | 25 | target_link_libraries(image_hash_test 26 | cimb_translator 27 | 28 | ${OPENCV_LIBS} 29 | ) 30 | 31 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/test/TestHelpers.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "serialize/format.h" 4 | #include 5 | 6 | namespace TestCimbar 7 | { 8 | inline std::string getSample(std::string filename) 9 | { 10 | return std::string(LIBCIMBAR_PROJECT_ROOT) + "/samples/" + filename; 11 | } 12 | 13 | inline cv::Mat loadSample(std::string filename) 14 | { 15 | cv::Mat mat = cv::imread(getSample(filename)); 16 | cv::cvtColor(mat, mat, cv::COLOR_BGR2RGB); 17 | return mat; 18 | } 19 | 20 | inline std::string getProjectDir() 21 | { 22 | return std::string(LIBCIMBAR_PROJECT_ROOT); 23 | } 24 | } 25 | 26 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/compression/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | project(compression_test) 4 | 5 | set (SOURCES 6 | test.cpp 7 | zstd_compressorTest.cpp 8 | zstd_decompressorTest.cpp 9 | zstd_header_checkTest.cpp 10 | ) 11 | 12 | include_directories( 13 | ${libcimbar_SOURCE_DIR}/test 14 | ${libcimbar_SOURCE_DIR}/test/lib 15 | ${CMAKE_CURRENT_SOURCE_DIR}/.. 16 | ) 17 | 18 | add_executable ( 19 | compression_test 20 | ${SOURCES} 21 | ) 22 | 23 | add_test(compression_test compression_test) 24 | 25 | target_link_libraries(compression_test 26 | zstd 27 | 28 | ${CPPFILESYSTEM} 29 | ) 30 | 31 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/libcorrect/include/correct/portable.h: -------------------------------------------------------------------------------- 1 | #ifdef __GNUC__ 2 | #define HAVE_BUILTINS 3 | #endif 4 | 5 | 6 | #ifdef HAVE_BUILTINS 7 | #define popcount __builtin_popcount 8 | #define prefetch __builtin_prefetch 9 | #else 10 | 11 | static inline int popcount(int x) { 12 | /* taken from the helpful http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel */ 13 | x = x - ((x >> 1) & 0x55555555); 14 | x = (x & 0x33333333) + ((x >> 2) & 0x33333333); 15 | return ((x + (x >> 4) & 0x0f0f0f0f) * 0x01010101) >> 24; 16 | } 17 | 18 | static inline void prefetch(void *x) {} 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/exe/cimbar_extract/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | project(cimbar_extract) 4 | 5 | set (SOURCES 6 | cimbar_extract.cpp 7 | ) 8 | 9 | add_executable ( 10 | cimbar_extract 11 | ${SOURCES} 12 | ) 13 | 14 | target_link_libraries(cimbar_extract 15 | 16 | extractor 17 | 18 | ${OPENCV_LIBS} 19 | ) 20 | 21 | add_custom_command( 22 | TARGET cimbar_extract POST_BUILD 23 | COMMAND ${CMAKE_COMMAND} -E copy $ cimbar_extract.dbg 24 | COMMAND ${CMAKE_STRIP} -g $ 25 | ) 26 | 27 | install( 28 | TARGETS cimbar_extract 29 | DESTINATION bin 30 | ) 31 | 32 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/extractor/DistortionParameters.h: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #pragma once 3 | 4 | #include 5 | 6 | class DistortionParameters 7 | { 8 | public: 9 | cv::Mat camera; 10 | cv::Mat distortion; 11 | 12 | public: 13 | DistortionParameters() 14 | : camera() 15 | , distortion() 16 | {} 17 | 18 | DistortionParameters(const cv::Mat& camera, const cv::Mat& distortion) 19 | : camera(camera) 20 | , distortion(distortion) 21 | {} 22 | 23 | operator bool() const 24 | { 25 | return camera.cols > 0; 26 | } 27 | }; 28 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/exe/cimbar/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | project(cimbar_decode) 4 | 5 | set (SOURCES 6 | cimbar.cpp 7 | ) 8 | 9 | add_executable ( 10 | cimbar 11 | ${SOURCES} 12 | ) 13 | 14 | target_link_libraries(cimbar 15 | 16 | cimb_translator 17 | extractor 18 | 19 | correct_static 20 | wirehair 21 | zstd 22 | ${OPENCV_LIBS} 23 | ${CPPFILESYSTEM} 24 | ) 25 | 26 | add_custom_command( 27 | TARGET cimbar POST_BUILD 28 | COMMAND ${CMAKE_COMMAND} -E copy $ cimbar.dbg 29 | COMMAND ${CMAKE_STRIP} -g $ 30 | ) 31 | 32 | install( 33 | TARGETS cimbar 34 | DESTINATION bin 35 | ) 36 | 37 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/exe/cimbar_recv/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | project(cimbar_recv) 4 | 5 | set (SOURCES 6 | recv.cpp 7 | ) 8 | 9 | add_executable ( 10 | cimbar_recv 11 | ${SOURCES} 12 | ) 13 | 14 | target_link_libraries(cimbar_recv 15 | 16 | cimbar_js 17 | extractor 18 | 19 | GL 20 | glfw 21 | ${OPENCV_LIBS} 22 | opencv_videoio 23 | ) 24 | 25 | add_custom_command( 26 | TARGET cimbar_recv POST_BUILD 27 | COMMAND ${CMAKE_COMMAND} -E copy $ cimbar_recv.dbg 28 | COMMAND ${CMAKE_STRIP} -g $ 29 | ) 30 | 31 | install( 32 | TARGETS cimbar_recv 33 | DESTINATION bin 34 | ) 35 | 36 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/cimbar_js/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | project(cimbar_js_test) 4 | 5 | set (SOURCES 6 | test.cpp 7 | cimbar_jsTest.cpp 8 | cimbar_recv_jsTest.cpp 9 | ) 10 | 11 | include_directories( 12 | ${libcimbar_SOURCE_DIR}/test 13 | ${libcimbar_SOURCE_DIR}/test/lib 14 | ${CMAKE_CURRENT_SOURCE_DIR}/.. 15 | ) 16 | 17 | add_executable ( 18 | cimbar_js_test 19 | ${SOURCES} 20 | ) 21 | 22 | add_test(cimbar_js_test cimbar_js_test) 23 | 24 | target_link_libraries(cimbar_js_test 25 | 26 | cimbar_js 27 | cimb_translator 28 | extractor 29 | 30 | correct_static 31 | wirehair 32 | zstd 33 | ${OPENCV_LIBS} 34 | ) 35 | 36 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/zstd/compress/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SRCFILES clevels.h huf_compress.c zstd_compress_sequences.c zstd_double_fast.c zstd_lazy.h zstdmt_compress.h 2 | zstd_compress.c zstd_compress_sequences.h zstd_double_fast.h zstd_ldm.c zstd_opt.c 3 | fse_compress.c zstd_compress_internal.h zstd_compress_superblock.c zstd_fast.c zstd_ldm_geartab.h zstd_opt.h 4 | hist.c zstd_compress_literals.c zstd_compress_superblock.h zstd_fast.h zstd_ldm.h 5 | hist.h zstd_compress_literals.h zstd_cwksp.h zstd_lazy.c zstdmt_compress.c) 6 | add_library(zstd-compress OBJECT ${SRCFILES}) 7 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/fountain/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | project(fountain_test) 4 | 5 | set (SOURCES 6 | test.cpp 7 | FountainEncodingTest.cpp 8 | FountainMetadataTest.cpp 9 | fountain_sinkTest.cpp 10 | fountain_sinkSpecialTest.cpp 11 | fountain_streamTest.cpp 12 | ) 13 | 14 | include_directories( 15 | ${libcimbar_SOURCE_DIR}/test 16 | ${libcimbar_SOURCE_DIR}/test/lib 17 | ${CMAKE_CURRENT_SOURCE_DIR}/.. 18 | ) 19 | 20 | add_executable ( 21 | fountain_test 22 | ${SOURCES} 23 | ) 24 | 25 | add_test(fountain_test fountain_test) 26 | 27 | target_link_libraries(fountain_test 28 | wirehair 29 | zstd 30 | 31 | ${CPPFILESYSTEM} 32 | ) 33 | 34 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/libcorrect/util/error-sim-sse.c: -------------------------------------------------------------------------------- 1 | #include "correct/util/error-sim-sse.h" 2 | 3 | size_t conv_correct_sse_enclen(void *conv_v, size_t msg_len) { 4 | return correct_convolutional_sse_encode_len((correct_convolutional_sse *)conv_v, msg_len); 5 | } 6 | 7 | void conv_correct_sse_encode(void *conv_v, uint8_t *msg, size_t msg_len, uint8_t *encoded) { 8 | correct_convolutional_sse_encode((correct_convolutional_sse *)conv_v, msg, msg_len, encoded); 9 | } 10 | 11 | ssize_t conv_correct_sse_decode(void *conv_v, uint8_t *soft, size_t soft_len, uint8_t *msg) { 12 | return correct_convolutional_sse_decode_soft((correct_convolutional_sse *)conv_v, soft, soft_len, msg); 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/modesel.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 9 | 12 | 13 | 15 | 16 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/cimb_translator/CellDrift.h: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #pragma once 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class CellDrift 9 | { 10 | public: 11 | CellDrift(int x=0, int y=0); 12 | 13 | inline static const std::array, 9> driftPairs = {{ 14 | {-1, -1}, {0, -1}, {1, -1}, {-1, 0}, {0, 0}, {1, 0}, {-1, 1}, {0, 1}, {1, 1} 15 | }}; 16 | 17 | static uint8_t calculate_cooldown(uint8_t previous, uint8_t idx); 18 | 19 | int x() const; 20 | int y() const; 21 | 22 | void updateDrift(int dx, int dy); 23 | 24 | protected: 25 | int _x; 26 | int _y; 27 | }; 28 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/extractor/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | project(extractor_test) 4 | 5 | set (SOURCES 6 | test.cpp 7 | CornersTest.cpp 8 | DeskewerTest.cpp 9 | ExtractorTest.cpp 10 | ScanStateTest.cpp 11 | ScannerTest.cpp 12 | SimpleCameraCalibrationTest.cpp 13 | UndistortTest.cpp 14 | ) 15 | 16 | include_directories( 17 | ${libcimbar_SOURCE_DIR}/test 18 | ${libcimbar_SOURCE_DIR}/test/lib 19 | ${CMAKE_CURRENT_SOURCE_DIR}/.. 20 | ) 21 | 22 | add_executable ( 23 | extractor_test 24 | ${SOURCES} 25 | ) 26 | 27 | add_test(extractor_test extractor_test) 28 | 29 | target_link_libraries(extractor_test 30 | extractor 31 | 32 | ${OPENCV_LIBS} 33 | ${CPPFILESYSTEM} 34 | ) 35 | 36 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/cimb_translator/CimbEncoder.h: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #pragma once 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | class CimbEncoder 10 | { 11 | public: 12 | CimbEncoder(unsigned symbol_bits, unsigned color_bits, bool dark=true, unsigned color_mode=1); 13 | 14 | cv::Mat load_tile(unsigned symbol_bits, unsigned index); 15 | bool load_tiles(unsigned symbol_bits); 16 | 17 | const cv::Mat& encode(unsigned bits) const; 18 | 19 | protected: 20 | std::vector _tiles; 21 | unsigned _numSymbols; 22 | unsigned _numColors; 23 | bool _dark; 24 | unsigned _colorMode; 25 | }; 26 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/extractor/test/DeskewerTest.cpp: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #include "unittest.h" 3 | #include "TestHelpers.h" 4 | 5 | #include "DeskewerPlus.h" 6 | #include "image_hash/average_hash.h" 7 | #include 8 | 9 | TEST_CASE( "DeskewerTest/testSimple", "[unit]" ) 10 | { 11 | Corners corners({312, 519}, {323, 2586}, {2405, 461}, {2425, 2594}); 12 | DeskewerPlus de({1024, 1024}, 30); 13 | 14 | cv::Mat actual = de.deskew(TestCimbar::getSample("6bit/4_30_f0_big.jpg"), corners); 15 | assertEquals(cv::Size(1024, 1024), actual.size()); 16 | 17 | assertEquals( 0x6e483730782fee5c, image_hash::average_hash(actual) ); 18 | } 19 | 20 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/serialize/str_join.h: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #pragma once 3 | 4 | #include 5 | 6 | namespace turbo { 7 | namespace str 8 | { 9 | template 10 | inline std::string join(const Iter& start, const Iter& end, char delim=' ') 11 | { 12 | std::stringstream ss; 13 | Iter it = start; 14 | if (it != end) 15 | ss << *it++; 16 | for (; it != end; ++it) 17 | ss << delim << *it; 18 | return ss.str(); 19 | } 20 | 21 | template 22 | inline std::string join(const Type& container, char delim=' ') 23 | { 24 | return join(container.begin(), container.end(), delim); 25 | } 26 | } 27 | }// namespace turbo 28 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/libcorrect/src/convolutional/metric.c: -------------------------------------------------------------------------------- 1 | #include "correct/convolutional/metric.h" 2 | 3 | // measure the square of the euclidean distance between x and y 4 | // since euclidean dist is sqrt(a^2 + b^2 + ... + n^2), the square is just 5 | // a^2 + b^2 + ... + n^2 6 | distance_t metric_soft_distance_quadratic(unsigned int hard_x, const uint8_t *soft_y, size_t len) { 7 | distance_t dist = 0; 8 | for (unsigned int i = 0; i < len; i++) { 9 | // first, convert hard_x to a soft measurement (0 -> 0, 1 - > 255) 10 | unsigned int soft_x = (hard_x & 1) ? 255 : 0; 11 | hard_x >>= 1; 12 | int d = soft_y[i] - soft_x; 13 | dist += d*d; 14 | } 15 | return dist >> 3; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/cimb_translator/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | set(SOURCES 4 | bitmaps.h 5 | AdjacentCellFinder.cpp 6 | AdjacentCellFinder.h 7 | Cell.h 8 | CellDrift.cpp 9 | CellDrift.h 10 | CellPositions.cpp 11 | CellPositions.h 12 | CimbDecoder.cpp 13 | CimbDecoder.h 14 | CimbEncoder.cpp 15 | CimbEncoder.h 16 | CimbReader.cpp 17 | CimbReader.h 18 | CimbWriter.cpp 19 | CimbWriter.h 20 | Common.cpp 21 | Common.h 22 | Config.h 23 | FloodDecodePositions.cpp 24 | FloodDecodePositions.h 25 | GridConf.h 26 | Interleave.h 27 | LinearDecodePositions.h 28 | PositionData.h 29 | ) 30 | 31 | add_library(cimb_translator STATIC ${SOURCES}) 32 | 33 | if(NOT DEFINED DISABLE_TESTS) 34 | add_subdirectory(test) 35 | endif() 36 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/encoder/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | project(encoder_test) 4 | 5 | set (SOURCES 6 | test.cpp 7 | DecoderTest.cpp 8 | EncoderTest.cpp 9 | EncoderRoundTripTest.cpp 10 | aligned_streamTest.cpp 11 | escrow_buffer_writerTest.cpp 12 | reed_solomon_streamTest.cpp 13 | ) 14 | 15 | include_directories( 16 | ${libcimbar_SOURCE_DIR}/test 17 | ${libcimbar_SOURCE_DIR}/test/lib 18 | ${CMAKE_CURRENT_SOURCE_DIR}/.. 19 | ) 20 | 21 | add_executable ( 22 | encoder_test 23 | ${SOURCES} 24 | ) 25 | 26 | add_test(encoder_test encoder_test) 27 | 28 | target_link_libraries(encoder_test 29 | 30 | cimb_translator 31 | extractor 32 | 33 | correct_static 34 | wirehair 35 | zstd 36 | ${OPENCV_LIBS} 37 | ${CPPFILESYSTEM} 38 | ) 39 | 40 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/util/MakeTempDirectory.h: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #pragma once 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class MakeTempDirectory 9 | { 10 | public: 11 | MakeTempDirectory(bool cleanup=true) 12 | : _cleanup(cleanup) 13 | { 14 | _path = std::tmpnam(nullptr); 15 | std::filesystem::create_directory(_path); 16 | } 17 | 18 | ~MakeTempDirectory() 19 | { 20 | if (_cleanup) 21 | { 22 | std::error_code ec; 23 | std::filesystem::remove_all(_path, ec); 24 | } 25 | } 26 | 27 | std::filesystem::path path() const 28 | { 29 | return _path; 30 | } 31 | 32 | protected: 33 | bool _cleanup; 34 | std::filesystem::path _path; 35 | }; 36 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/libcorrect/include/correct/convolutional.h: -------------------------------------------------------------------------------- 1 | #ifndef CORRECT_CONVOLUTIONAL 2 | #define CORRECT_CONVOLUTIONAL 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "correct.h" 13 | #include "correct/portable.h" 14 | 15 | typedef unsigned int shift_register_t; 16 | typedef uint16_t polynomial_t; 17 | typedef uint64_t path_t; 18 | typedef uint8_t soft_t; 19 | static const soft_t soft_max = UINT8_MAX; 20 | 21 | typedef uint16_t distance_t; 22 | static const distance_t distance_max = UINT16_MAX; 23 | 24 | typedef enum { 25 | CORRECT_SOFT_LINEAR, 26 | CORRECT_SOFT_QUADRATIC, 27 | } soft_measurement_t; 28 | #endif 29 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/cimb_translator/CimbWriter.h: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #pragma once 3 | 4 | #include "CellPositions.h" 5 | #include "CimbEncoder.h" 6 | #include "util/vec_xy.h" 7 | 8 | class CimbWriter 9 | { 10 | public: 11 | CimbWriter(unsigned symbol_bits, unsigned color_bits, bool dark=true, unsigned color_mode=1, cimbar::vec_xy size={}); 12 | 13 | bool write(unsigned bits); 14 | bool done() const; 15 | 16 | cv::Mat image() const; 17 | 18 | unsigned num_cells() const; 19 | 20 | protected: 21 | void paste(const cv::Mat& img, int x, int y); 22 | 23 | protected: 24 | cv::Mat _image; 25 | CellPositions _positions; 26 | CimbEncoder _encoder; 27 | unsigned _offsetX = 0; 28 | unsigned _offsetY = 0; 29 | }; 30 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/compression/zstd_header_check.h: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #pragma once 3 | 4 | #include "zstd/zstd.h" 5 | #include 6 | 7 | namespace cimbar { 8 | 9 | class zstd_header_check 10 | { 11 | public: 12 | static std::string get_filename(const unsigned char* data, size_t len) 13 | { 14 | if (!ZSTD_isSkippableFrame(data, len)) 15 | return ""; 16 | 17 | std::string res; 18 | res.resize(500, '\0'); 19 | size_t sz = ZSTD_readSkippableFrame(res.data(), res.size(), nullptr, data, len); 20 | if (sz <= 1) 21 | return ""; 22 | 23 | switch (res[0]) 24 | { 25 | case 1: 26 | return std::string(&res[1], sz-1); 27 | default: 28 | break; 29 | } 30 | return ""; 31 | } 32 | 33 | }; 34 | 35 | } 36 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/cimb_translator/test/CellPositionsTest.cpp: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #include "unittest.h" 3 | 4 | #include "CellPositions.h" 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | TEST_CASE( "CellPositionsTest/testSimple", "[unit]" ) 11 | { 12 | CellPositions cells(cimbar::vec_xy{9, 9}, cimbar::vec_xy{112, 112}, 8, cimbar::vec_xy{6, 6}); 13 | 14 | // test first coordinate. We'll just count the rest. 15 | assertFalse( cells.done() ); 16 | CellPositions::coordinate xy = cells.next(); 17 | assertEquals(62, xy.first); 18 | assertEquals(8, xy.second); 19 | 20 | unsigned count = 1; 21 | while (!cells.done()) 22 | { 23 | cells.next(); 24 | ++count; 25 | } 26 | 27 | assertEquals(12400, count); 28 | } 29 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/libcorrect/include/correct/convolutional/metric.h: -------------------------------------------------------------------------------- 1 | #include "correct/convolutional.h" 2 | 3 | // measure the hamming distance of two bit strings 4 | // implemented as population count of x XOR y 5 | static inline distance_t metric_distance(unsigned int x, unsigned int y) { 6 | return popcount(x ^ y); 7 | } 8 | 9 | static inline distance_t metric_soft_distance_linear(unsigned int hard_x, const uint8_t *soft_y, size_t len) { 10 | distance_t dist = 0; 11 | for (unsigned int i = 0; i < len; i++) { 12 | unsigned int soft_x = ((int8_t)(0) - (hard_x & 1)) & 0xff; 13 | hard_x >>= 1; 14 | int d = soft_y[i] - soft_x; 15 | dist += (d < 0) ? -d : d; 16 | } 17 | return dist; 18 | } 19 | 20 | distance_t metric_soft_distance_quadratic(unsigned int hard_x, const uint8_t *soft_y, size_t len); 21 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/cimb_translator/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | project(cimb_translator_test) 4 | 5 | set (SOURCES 6 | test.cpp 7 | AdjacentCellFinderTest.cpp 8 | CellTest.cpp 9 | CellDriftTest.cpp 10 | CellPositionsTest.cpp 11 | CimbDecoderTest.cpp 12 | CimbEncoderTest.cpp 13 | CimbReaderTest.cpp 14 | CimbWriterTest.cpp 15 | FloodDecodePositionsTest.cpp 16 | InterleaveTest.cpp 17 | LinearDecodePositionsTest.cpp 18 | ) 19 | 20 | include_directories( 21 | ${libcimbar_SOURCE_DIR}/test 22 | ${libcimbar_SOURCE_DIR}/test/lib 23 | ${CMAKE_CURRENT_SOURCE_DIR}/.. 24 | ) 25 | 26 | add_executable ( 27 | cimb_translator_test 28 | ${SOURCES} 29 | ) 30 | 31 | add_test(cimb_translator_test cimb_translator_test) 32 | 33 | target_link_libraries(cimb_translator_test 34 | cimb_translator 35 | 36 | ${OPENCV_LIBS} 37 | ) 38 | 39 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/cimbar_js/cimbar_js.h: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #ifndef CIMBAR_JS_API_H 3 | #define CIMBAR_JS_API_H 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | int cimbare_init_window(int width, int height); 10 | int cimbare_rotate_window(bool rotate); 11 | int cimbare_render(); 12 | int cimbare_next_frame(); 13 | int cimbare_init_encode(const char* filename, unsigned fnsize, int encode_id); 14 | int cimbare_encode_bufsize(); 15 | int cimbare_encode(const unsigned char* buffer, unsigned size); 16 | int cimbare_configure(int mode_val, int compression); 17 | float cimbare_get_aspect_ratio(); 18 | 19 | // internal usage 20 | bool cimbare_auto_scale_window(); 21 | int cimbare_get_frame_buff(unsigned char** buff); 22 | 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | 27 | #endif // CIMBAR_JS_API_H 28 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/zstd/common/xxhash.c: -------------------------------------------------------------------------------- 1 | /* 2 | * xxHash - Fast Hash algorithm 3 | * Copyright (c) Meta Platforms, Inc. and affiliates. 4 | * 5 | * You can contact the author at : 6 | * - xxHash homepage: https://cyan4973.github.io/xxHash/ 7 | * - xxHash source repository : https://github.com/Cyan4973/xxHash 8 | * 9 | * This source code is licensed under both the BSD-style license (found in the 10 | * LICENSE file in the root directory of this source tree) and the GPLv2 (found 11 | * in the COPYING file in the root directory of this source tree). 12 | * You may select, at your option, one of the above-listed licenses. 13 | */ 14 | 15 | 16 | 17 | /* 18 | * xxhash.c instantiates functions defined in xxhash.h 19 | */ 20 | 21 | #define XXH_STATIC_LINKING_ONLY /* access advanced declarations */ 22 | #define XXH_IMPLEMENTATION /* access definitions */ 23 | 24 | #include "xxhash.h" 25 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/util/Timer.h: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #pragma once 3 | 4 | #include 5 | 6 | class TimeAccumulator 7 | { 8 | public: 9 | TimeAccumulator() 10 | {} 11 | 12 | void increment(clock_t num) 13 | { 14 | _total += num; 15 | _ticks += 1; 16 | } 17 | 18 | double avg() const 19 | { 20 | if (_ticks == 0) 21 | return 0; 22 | return _total/_ticks; 23 | } 24 | 25 | clock_t ticks() const 26 | { 27 | return _ticks; 28 | } 29 | 30 | protected: 31 | clock_t _total = 0; 32 | clock_t _ticks = 0; 33 | }; 34 | 35 | class Timer 36 | { 37 | public: 38 | Timer(TimeAccumulator& accum) 39 | : _accum(accum) 40 | , _start(clock()) 41 | {} 42 | 43 | ~Timer() 44 | { 45 | _accum.increment(clock() - _start); 46 | } 47 | 48 | protected: 49 | TimeAccumulator& _accum; 50 | clock_t _start; 51 | }; 52 | -------------------------------------------------------------------------------- /app/src/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.4.1) 2 | 3 | project ( cfc ) 4 | 5 | set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -mllvm -inline-threshold=1500 -flto=thin") 6 | set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -mllvm -inline-threshold=1500 -flto=thin") 7 | 8 | # opencv stuff 9 | add_library( lib_opencv SHARED IMPORTED ) 10 | set_target_properties(lib_opencv PROPERTIES IMPORTED_LOCATION ${OpenCV_DIR}/libs/${ANDROID_ABI}/libopencv_java4.so) 11 | 12 | set( DISABLE_TESTS true ) 13 | set( OPENCV_LIBS "lib_opencv" ) 14 | 15 | # our stuff 16 | set (PROJECTS 17 | cfc-cpp 18 | concurrent 19 | libcimbar 20 | ) 21 | 22 | include_directories( 23 | ${OpenCV_DIR}/jni/include 24 | . 25 | libcimbar/src/lib 26 | libcimbar/src/third_party_lib 27 | ) 28 | 29 | foreach(proj ${PROJECTS}) 30 | add_subdirectory(${proj} build/${proj}) 31 | endforeach() 32 | 33 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/extractor/DeskewerPlus.h: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #pragma once 3 | 4 | #include "Deskewer.h" 5 | 6 | #include 7 | 8 | class DeskewerPlus : public Deskewer 9 | { 10 | public: 11 | using Deskewer::Deskewer; 12 | using Deskewer::deskew; 13 | 14 | cv::Mat deskew(std::string img, const Corners& corners); 15 | bool save(const cv::Mat& img, std::string path); 16 | 17 | protected: 18 | }; 19 | 20 | inline cv::Mat DeskewerPlus::deskew(std::string img, const Corners& corners) 21 | { 22 | cv::Mat mat = cv::imread(img); 23 | cv::cvtColor(mat, mat, cv::COLOR_BGR2RGB); 24 | return Deskewer::deskew(mat, corners); 25 | } 26 | 27 | inline bool DeskewerPlus::save(const cv::Mat& img, std::string path) 28 | { 29 | cv::Mat bgr; 30 | cv::cvtColor(img, bgr, cv::COLOR_RGB2BGR); 31 | return cv::imwrite(path, img); 32 | } 33 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/cimb_translator/test/LinearDecodePositionsTest.cpp: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #include "unittest.h" 3 | 4 | #include "LinearDecodePositions.h" 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | TEST_CASE( "LinearDecodePositionsTest/testSimple", "[unit]" ) 11 | { 12 | LinearDecodePositions cells(cimbar::vec_xy{9, 9}, cimbar::vec_xy{112, 112}, 8, cimbar::vec_xy{6, 6}); 13 | 14 | // test first coordinate. We'll just count the rest. 15 | assertFalse( cells.done() ); 16 | auto [i, xy, drift] = cells.next(); 17 | assertEquals(62, xy.first); 18 | assertEquals(8, xy.second); 19 | assertEquals(i, 0); 20 | 21 | unsigned count = 1; 22 | while (!cells.done()) 23 | { 24 | auto [i, xy, drift] = cells.next(); 25 | assertEquals(i, count); 26 | ++count; 27 | } 28 | 29 | assertEquals(12400, count); 30 | } 31 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/test/unittest.h: -------------------------------------------------------------------------------- 1 | #include "catch.hpp" 2 | 3 | #define assertMsg(expr,msg) {bool _res_ = expr; if(!_res_) FAIL(msg); REQUIRE(_res_);} 4 | #define assertTrue(expr) REQUIRE(expr) 5 | #define assertFalse(expr) REQUIRE_FALSE(expr) 6 | #define assertEquals(x,y) REQUIRE((x) == (y)) 7 | #define assertMatch(x,y) assertMsg(std::regex_match(y, std::regex(x)), x + std::string(" does not match ") + y) 8 | #define assertIn(x,y) REQUIRE(std::find(y.begin(), y.end(), x) != y.end()) 9 | #define assertStringsEqual(x,y) REQUIRE(std::string(x) == std::string(y)) 10 | #define assertStringContains(x,y) assertMsg(std::string(y).find(x) != std::string::npos, std::string(y) + " did not contain " + std::string(x)) 11 | #define assertInRange(x,y,z) REQUIRE(x <= y); REQUIRE(y <= z) 12 | #define assertAlmostEquals(x,y) assertInRange(x-1,y,x+1) 13 | #define assertNull(expr) REQUIRE(expr == (void*)NULL) 14 | #define assertNotNull(expr) REQUIRE(expr != (void*)NULL) 15 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/chromatic_adaptation/adaptation_transform.h: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #pragma once 3 | 4 | #include 5 | 6 | namespace adaptation_transform 7 | { 8 | struct bradford 9 | { 10 | const cv::Matx& operator()() const 11 | { 12 | static cv::Matx transform( 13 | 0.8951000, 0.2664000, -0.1614000, 14 | -0.7502000, 1.7135000, 0.0367000, 15 | 0.0389000, -0.0685000, 1.0296000 16 | ); 17 | return transform; 18 | } 19 | }; 20 | 21 | struct von_kries 22 | { 23 | const cv::Matx& operator()() const 24 | { 25 | static cv::Matx transform( 26 | 0.4002400, 0.7076000, -0.0808100, 27 | -0.2263000, 1.1653200, 0.0457000, 28 | 0.0000000, 0.0000000, 0.9182200 29 | ); 30 | return transform; 31 | } 32 | }; 33 | } 34 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/cimb_translator/test/CimbEncoderTest.cpp: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #include "unittest.h" 3 | 4 | #include "CimbEncoder.h" 5 | 6 | #include "cimb_translator/Common.h" 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | using std::string; 13 | 14 | TEST_CASE( "CimbEncoderTest/testSimple", "[unit]" ) 15 | { 16 | CimbEncoder cw(4, 0); 17 | cv::Mat res = cw.encode(14); 18 | 19 | cv::Mat expected = cimbar::getTile(4, 14, true); 20 | REQUIRE(cv::sum(expected != res) == cv::Scalar(0,0,0,0)); 21 | } 22 | 23 | TEST_CASE( "CimbEncoderTest/testColor", "[unit]" ) 24 | { 25 | CimbEncoder cw(4, 3); 26 | cv::Mat res = cw.encode(55); 27 | 28 | cv::Mat expected = cimbar::getTile(4, 7, true, 8, 3); // 3*16 + 7 == 55 29 | REQUIRE(cv::sum(expected != res) == cv::Scalar(0,0,0,0)); 30 | } 31 | 32 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/libcorrect/src/convolutional/sse/convolutional.c: -------------------------------------------------------------------------------- 1 | #include "correct/convolutional/sse/convolutional.h" 2 | 3 | correct_convolutional_sse *correct_convolutional_sse_create(size_t rate, 4 | size_t order, 5 | const polynomial_t *poly) { 6 | correct_convolutional_sse *conv = malloc(sizeof(correct_convolutional_sse)); 7 | correct_convolutional *init_conv = _correct_convolutional_init(&conv->base_conv, rate, order, poly); 8 | if (!init_conv) { 9 | free(conv); 10 | conv = NULL; 11 | } 12 | return conv; 13 | } 14 | 15 | void correct_convolutional_sse_destroy(correct_convolutional_sse *conv) { 16 | if (conv->base_conv.has_init_decode) { 17 | oct_lookup_destroy(conv->oct_lookup); 18 | } 19 | _correct_convolutional_teardown(&conv->base_conv); 20 | free(conv); 21 | } 22 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/base91/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011..2016 r-lyeh (https://github.com/r-lyeh) 2 | 3 | This software is provided 'as-is', without any express or implied 4 | warranty. In no event will the authors be held liable for any damages 5 | arising from the use of this software. 6 | 7 | Permission is granted to anyone to use this software for any purpose, 8 | including commercial applications, and to alter it and redistribute it 9 | freely, subject to the following restrictions: 10 | 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 2. Altered source versions must be plainly marked as such, and must not be 16 | misrepresented as being the original software. 17 | 3. This notice may not be removed or altered from any source distribution. 18 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/package-cimbar-html.py: -------------------------------------------------------------------------------- 1 | 2 | def get_path(name): 3 | fns = { 4 | 'index': 'web/index.html', 5 | 'cimbar_js': 'web/cimbar_js.js', 6 | 'main_js': 'web/main.js', 7 | 'output': 'web/cimbar_js.html', 8 | } 9 | return fns[name] 10 | 11 | 12 | def read_file(name): 13 | with open(get_path(name), 'rt') as f: 14 | return f.read() 15 | 16 | 17 | def read_script(name): 18 | script = read_file(name) 19 | return ' 26 | 27 | 28 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /app/src/cpp/concurrent/monitor.h: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #pragma once 3 | 4 | #include 5 | #include 6 | 7 | namespace turbo { 8 | class monitor 9 | { 10 | public: 11 | monitor() 12 | : _flag(false) 13 | , _cancelled(false) 14 | {} 15 | 16 | bool wait() 17 | { 18 | std::unique_lock lock(_mutex); 19 | if (_flag) 20 | { 21 | _flag = false; 22 | return !_cancelled; 23 | } 24 | _cv.wait(lock); 25 | return !_cancelled; 26 | } 27 | 28 | bool wait_for(unsigned ms) 29 | { 30 | std::unique_lock lock(_mutex); 31 | if (_flag) 32 | { 33 | _flag = false; 34 | return !_cancelled; 35 | } 36 | return _cv.wait_for(lock, std::chrono::milliseconds(ms)) != std::cv_status::timeout && !_cancelled; 37 | } 38 | 39 | void notify_one() 40 | { 41 | _cv.notify_one(); 42 | } 43 | 44 | void notify_all() 45 | { 46 | _cv.notify_all(); 47 | } 48 | 49 | void signal_all() 50 | { 51 | signal_all_internal(false); 52 | } 53 | 54 | void cancel() 55 | { 56 | signal_all_internal(true); 57 | } 58 | 59 | protected: 60 | void signal_all_internal(bool cancelled) 61 | { 62 | std::unique_lock lock(_mutex); 63 | _flag = true; 64 | _cancelled = cancelled; 65 | notify_all(); 66 | } 67 | 68 | protected: 69 | bool _flag; 70 | bool _cancelled; 71 | std::condition_variable _cv; 72 | std::mutex _mutex; 73 | }; 74 | } // namespace turbo 75 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/libpopcnt/LICENSE: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2016 - 2019, Kim Walisch 4 | Copyright (c) 2016 - 2019, Wojciech Muła 5 | 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | 1. Redistributions of source code must retain the above copyright notice, this 12 | list of conditions and the following disclaimer. 13 | 2. Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 21 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/libcorrect/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016, Brian Armstrong 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | 8 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | 10 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 11 | 12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 13 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/zstd/decompress/zstd_ddict.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under both the BSD-style license (found in the 6 | * LICENSE file in the root directory of this source tree) and the GPLv2 (found 7 | * in the COPYING file in the root directory of this source tree). 8 | * You may select, at your option, one of the above-listed licenses. 9 | */ 10 | 11 | 12 | #ifndef ZSTD_DDICT_H 13 | #define ZSTD_DDICT_H 14 | 15 | /*-******************************************************* 16 | * Dependencies 17 | *********************************************************/ 18 | #include "../common/zstd_deps.h" /* size_t */ 19 | #include "../zstd.h" /* ZSTD_DDict, and several public functions */ 20 | 21 | 22 | /*-******************************************************* 23 | * Interface 24 | *********************************************************/ 25 | 26 | /* note: several prototypes are already published in `zstd.h` : 27 | * ZSTD_createDDict() 28 | * ZSTD_createDDict_byReference() 29 | * ZSTD_createDDict_advanced() 30 | * ZSTD_freeDDict() 31 | * ZSTD_initStaticDDict() 32 | * ZSTD_sizeof_DDict() 33 | * ZSTD_estimateDDictSize() 34 | * ZSTD_getDictID_fromDict() 35 | */ 36 | 37 | const void* ZSTD_DDict_dictContent(const ZSTD_DDict* ddict); 38 | size_t ZSTD_DDict_dictSize(const ZSTD_DDict* ddict); 39 | 40 | void ZSTD_copyDDictParameters(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict); 41 | 42 | 43 | 44 | #endif /* ZSTD_DDICT_H */ 45 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/zstd/compress/zstd_double_fast.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under both the BSD-style license (found in the 6 | * LICENSE file in the root directory of this source tree) and the GPLv2 (found 7 | * in the COPYING file in the root directory of this source tree). 8 | * You may select, at your option, one of the above-listed licenses. 9 | */ 10 | 11 | #ifndef ZSTD_DOUBLE_FAST_H 12 | #define ZSTD_DOUBLE_FAST_H 13 | 14 | #if defined (__cplusplus) 15 | extern "C" { 16 | #endif 17 | 18 | #include "../common/mem.h" /* U32 */ 19 | #include "zstd_compress_internal.h" /* ZSTD_CCtx, size_t */ 20 | 21 | void ZSTD_fillDoubleHashTable(ZSTD_matchState_t* ms, 22 | void const* end, ZSTD_dictTableLoadMethod_e dtlm, 23 | ZSTD_tableFillPurpose_e tfp); 24 | size_t ZSTD_compressBlock_doubleFast( 25 | ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM], 26 | void const* src, size_t srcSize); 27 | size_t ZSTD_compressBlock_doubleFast_dictMatchState( 28 | ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM], 29 | void const* src, size_t srcSize); 30 | size_t ZSTD_compressBlock_doubleFast_extDict( 31 | ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM], 32 | void const* src, size_t srcSize); 33 | 34 | 35 | #if defined (__cplusplus) 36 | } 37 | #endif 38 | 39 | #endif /* ZSTD_DOUBLE_FAST_H */ 40 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/encoder/DecoderPlus.h: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #pragma once 3 | 4 | #include "Decoder.h" 5 | #include "util/File.h" 6 | 7 | #include 8 | #include 9 | 10 | class DecoderPlus : public Decoder 11 | { 12 | public: 13 | using Decoder::Decoder; 14 | using Decoder::decode; 15 | 16 | unsigned decode(std::string filename, std::string output); 17 | 18 | bool load_ccm(std::string filename); 19 | bool save_ccm(std::string filename); 20 | }; 21 | 22 | inline unsigned DecoderPlus::decode(std::string filename, std::string output) 23 | { 24 | cv::Mat img = cv::imread(filename); 25 | cv::cvtColor(img, img, cv::COLOR_BGR2RGB); 26 | 27 | std::ofstream f(output); 28 | return Decoder::decode(img, f, false); 29 | } 30 | 31 | inline bool DecoderPlus::load_ccm(std::string filename) 32 | { 33 | File f(filename); 34 | std::string data = f.read_all(); 35 | if (data.size() < 3*3*4) 36 | return false; 37 | 38 | cv::Mat temp(3, 3, CV_32F, data.data()); 39 | 40 | _decoder.update_color_correction(temp); 41 | return true; 42 | } 43 | 44 | inline bool DecoderPlus::save_ccm(std::string filename) 45 | { 46 | if (not _decoder.get_ccm().active()) 47 | return false; 48 | 49 | cv::Mat temp(_decoder.get_ccm().mat()); 50 | 51 | File f(filename, true); 52 | if (f.write(reinterpret_cast(temp.data), temp.rows * temp.cols * temp.elemSize()) == 0) // len will be 9*elemsize, but... 53 | return false; 54 | return true; 55 | } 56 | 57 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/fmt/LICENSE.rst: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 - present, Victor Zverovich and {fmt} contributors 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | --- Optional exception to the license --- 23 | 24 | As an exception, if, as a result of your compiling your source code, portions 25 | of this Software are embedded into a machine-executable object form of such 26 | source code, you may redistribute such embedded portions in such object form 27 | without including the above copyright and permission notices. 28 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 34 5 | buildToolsVersion "30.0.3" 6 | ndkVersion "25.2.9519653" 7 | defaultConfig { 8 | applicationId "org.cimbar.camerafilecopy" 9 | minSdkVersion 21 10 | targetSdkVersion 35 11 | versionCode 21 12 | versionName "0.6.3" 13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 14 | ndk { 15 | abiFilters "arm64-v8a" 16 | } 17 | externalNativeBuild { 18 | cmake { 19 | //arguments "-DCMAKE_BUILD_TYPE=Release" 20 | cppFlags "-frtti -fexceptions -std=c++17" 21 | abiFilters 'arm64-v8a' 22 | arguments "-DOpenCV_DIR=" + opencvsdk + "/sdk/native" 23 | } 24 | } 25 | setProperty("archivesBaseName", "CameraFileCopy") 26 | } 27 | buildTypes { 28 | release { 29 | minifyEnabled false 30 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 31 | } 32 | } 33 | externalNativeBuild { 34 | cmake { 35 | path "src/cpp/CMakeLists.txt" 36 | version "3.16.3+" 37 | } 38 | } 39 | } 40 | 41 | dependencies { 42 | implementation fileTree(dir: 'libs', include: ['*.jar']) 43 | implementation 'androidx.appcompat:appcompat:1.1.0' 44 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 45 | implementation project(path: ':opencv') 46 | } 47 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/extractor/Undistort.h: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #pragma once 3 | 4 | #include "DistortionParameters.h" 5 | #include 6 | 7 | template 8 | class Undistort 9 | { 10 | public: 11 | Undistort() {} 12 | 13 | Undistort(int width, int height, const DistortionParameters& params) 14 | { 15 | set_distortion_params(width, height, params); 16 | } 17 | 18 | template 19 | static DistortionParameters get_distortion_parameters(const MAT& img) 20 | { 21 | return CAMERA_CALIBRATOR().scan(img); 22 | } 23 | 24 | template 25 | bool undistort(const MAT& img, MAT& out) 26 | { 27 | if (!_params) 28 | { 29 | if ( !set_distortion_params(img.cols, img.rows, get_distortion_parameters(img)) ) 30 | return false; 31 | } 32 | 33 | cv::remap(img, out, _map1, _map2, cv::INTER_LINEAR, cv::BORDER_CONSTANT); 34 | return true; 35 | } 36 | 37 | bool set_distortion_params(int width, int height, const DistortionParameters& params) 38 | { 39 | if (!params) 40 | return false; 41 | 42 | _params = params; 43 | cv::initUndistortRectifyMap(_params.camera, _params.distortion, cv::Mat(), _params.camera, cv::Size(width, height), CV_32FC1, _map1, _map2); 44 | return true; 45 | } 46 | 47 | void reset_distortion_params() 48 | { 49 | _params = {}; 50 | _map1.release(); 51 | _map2.release(); 52 | } 53 | 54 | protected: 55 | DistortionParameters _params; 56 | cv::Mat _map1; 57 | cv::Mat _map2; 58 | }; 59 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/encoder/escrow_buffer_writer.h: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #pragma once 3 | 4 | #include 5 | #include 6 | 7 | class escrow_buffer_writer 8 | { 9 | public: 10 | escrow_buffer_writer(unsigned char* bufspace, unsigned bufcount, unsigned bufsize) 11 | : _bufspace(bufspace) 12 | , _bufcount(bufcount) 13 | , _bufsize(bufsize) 14 | { 15 | } 16 | 17 | bool good() const 18 | { 19 | return _good; 20 | } 21 | 22 | unsigned chunk_size() const 23 | { 24 | return _bufsize; 25 | } 26 | 27 | long tellp() const 28 | { 29 | return _totalCount; 30 | } 31 | 32 | unsigned buffers_in_use() const 33 | { 34 | return _bufIdx; 35 | } 36 | 37 | escrow_buffer_writer& write(const char* data, unsigned length) 38 | { 39 | // TODO: should this also act on multiples of `length`? 40 | 41 | // we can only write if the bufsize matches 42 | // and if we have buffers left 43 | if (length != _bufsize or _bufIdx>= _bufcount) 44 | _good = false; 45 | 46 | if (!good()) 47 | return *this; 48 | 49 | std::copy(data, data+length, _bufspace+(_bufIdx*_bufsize)); 50 | 51 | _totalCount += length; 52 | ++_bufIdx; 53 | return *this; 54 | } 55 | 56 | escrow_buffer_writer& operator<<(const std::string& buffer) 57 | { 58 | return write(buffer.data(), buffer.size()); 59 | } 60 | 61 | protected: 62 | unsigned char* _bufspace; 63 | unsigned _bufcount; 64 | unsigned _bufsize; 65 | 66 | unsigned _bufIdx = 0; 67 | long _totalCount = 0; 68 | bool _good = true; 69 | }; 70 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/libcorrect/src/convolutional/error_buffer.c: -------------------------------------------------------------------------------- 1 | #include "correct/convolutional/error_buffer.h" 2 | 3 | error_buffer_t *error_buffer_create(unsigned int num_states) { 4 | error_buffer_t *buf = calloc(1, sizeof(error_buffer_t)); 5 | 6 | // how large are the error buffers? 7 | buf->num_states = num_states; 8 | 9 | // save two error metrics, one for last round and one for this 10 | // (double buffer) 11 | // the error metric is the aggregated number of bit errors found 12 | // at a given path which terminates at a particular shift register state 13 | buf->errors[0] = calloc(sizeof(distance_t), num_states); 14 | buf->errors[1] = calloc(sizeof(distance_t), num_states); 15 | 16 | // which buffer are we using, 0 or 1? 17 | buf->index = 0; 18 | 19 | buf->read_errors = buf->errors[0]; 20 | buf->write_errors = buf->errors[1]; 21 | 22 | return buf; 23 | } 24 | 25 | void error_buffer_destroy(error_buffer_t *buf) { 26 | free(buf->errors[0]); 27 | free(buf->errors[1]); 28 | free(buf); 29 | } 30 | 31 | void error_buffer_reset(error_buffer_t *buf) { 32 | memset(buf->errors[0], 0, buf->num_states * sizeof(distance_t)); 33 | memset(buf->errors[1], 0, buf->num_states * sizeof(distance_t)); 34 | buf->index = 0; 35 | buf->read_errors = buf->errors[0]; 36 | buf->write_errors = buf->errors[1]; 37 | } 38 | 39 | void error_buffer_swap(error_buffer_t *buf) { 40 | buf->read_errors = buf->errors[buf->index]; 41 | buf->index = (buf->index + 1) % 2; 42 | buf->write_errors = buf->errors[buf->index]; 43 | } 44 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/libcorrect/tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(rs_find_primitive_poly EXCLUDE_FROM_ALL find_rs_primitive_poly.c) 2 | target_link_libraries(rs_find_primitive_poly correct_static) 3 | set(all_tools ${all_tools} rs_find_primitive_poly) 4 | 5 | if(HAVE_LIBFEC) 6 | add_executable(conv_find_libfec_poly EXCLUDE_FROM_ALL find_conv_libfec_poly.c) 7 | target_link_libraries(conv_find_libfec_poly correct_static fec) 8 | set(all_tools ${all_tools} conv_find_libfec_poly) 9 | endif() 10 | 11 | if(HAVE_SSE) 12 | add_executable(conv_find_optim_poly EXCLUDE_FROM_ALL find_conv_optim_poly.c $) 13 | target_link_libraries(conv_find_optim_poly correct_static) 14 | set(all_tools ${all_tools} conv_find_optim_poly) 15 | 16 | add_executable(conv_find_optim_poly_annealing EXCLUDE_FROM_ALL find_conv_optim_poly_annealing.c $) 17 | target_link_libraries(conv_find_optim_poly_annealing correct_static) 18 | set(all_tools ${all_tools} conv_find_optim_poly_annealing) 19 | else() 20 | add_executable(conv_find_optim_poly EXCLUDE_FROM_ALL find_conv_optim_poly.c $) 21 | target_link_libraries(conv_find_optim_poly correct_static) 22 | set(all_tools ${all_tools} conv_find_optim_poly) 23 | 24 | add_executable(conv_find_optim_poly_annealing EXCLUDE_FROM_ALL find_conv_optim_poly_annealing.c $) 25 | target_link_libraries(conv_find_optim_poly_annealing correct_static) 26 | set(all_tools ${all_tools} conv_find_optim_poly_annealing) 27 | endif() 28 | 29 | add_custom_target(tools DEPENDS ${all_tools}) 30 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/wirehair/LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2018, Christopher A. Taylor 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/libcorrect/util/error-sim-shim.c: -------------------------------------------------------------------------------- 1 | #include "correct/util/error-sim-shim.h" 2 | 3 | ssize_t conv_shim27_decode(void *conv_v, uint8_t *soft, size_t soft_len, uint8_t *msg) { 4 | init_viterbi27(conv_v, 0); 5 | update_viterbi27_blk(conv_v, soft, soft_len / 2 - 2); 6 | size_t n_decoded_bits = (soft_len / 2) - 8; 7 | chainback_viterbi27(conv_v, msg, n_decoded_bits, 0); 8 | return (n_decoded_bits % 8) ? (n_decoded_bits / 8) + 1 : n_decoded_bits / 8; 9 | } 10 | 11 | ssize_t conv_shim29_decode(void *conv_v, uint8_t *soft, size_t soft_len, uint8_t *msg) { 12 | init_viterbi29(conv_v, 0); 13 | update_viterbi29_blk(conv_v, soft, soft_len / 2 - 2); 14 | size_t n_decoded_bits = (soft_len / 2) - 10; 15 | chainback_viterbi29(conv_v, msg, n_decoded_bits, 0); 16 | return (n_decoded_bits % 8) ? (n_decoded_bits / 8) + 1 : n_decoded_bits / 8; 17 | } 18 | 19 | ssize_t conv_shim39_decode(void *conv_v, uint8_t *soft, size_t soft_len, uint8_t *msg) { 20 | init_viterbi39(conv_v, 0); 21 | update_viterbi39_blk(conv_v, soft, soft_len / 3 - 2); 22 | size_t n_decoded_bits = (soft_len / 3) - 10; 23 | chainback_viterbi39(conv_v, msg, n_decoded_bits, 0); 24 | return (n_decoded_bits % 8) ? (n_decoded_bits / 8) + 1 : n_decoded_bits / 8; 25 | } 26 | 27 | ssize_t conv_shim615_decode(void *conv_v, uint8_t *soft, size_t soft_len, uint8_t *msg) { 28 | init_viterbi615(conv_v, 0); 29 | update_viterbi615_blk(conv_v, soft, soft_len / 6 - 2); 30 | size_t n_decoded_bits = (soft_len / 6) - 16; 31 | chainback_viterbi615(conv_v, msg, n_decoded_bits, 0); 32 | return (n_decoded_bits % 8) ? (n_decoded_bits / 8) + 1 : n_decoded_bits / 8; 33 | } 34 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/zstd/LICENSE: -------------------------------------------------------------------------------- 1 | BSD License 2 | 3 | For Zstandard software 4 | 5 | Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without modification, 8 | are permitted provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | * Neither the name Facebook, nor Meta, nor the names of its contributors may 18 | be used to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 25 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 28 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/util/File.h: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #pragma once 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | class File 11 | { 12 | public: 13 | static std::string basename(const std::string& fullpath) 14 | { 15 | return std::filesystem::path(fullpath).filename().string(); 16 | } 17 | 18 | public: 19 | File(std::string filename, bool write=false) 20 | { 21 | _fp = fopen(filename.c_str(), write? "wb" : "rb"); 22 | } 23 | 24 | std::string read_all() 25 | { 26 | std::string res; 27 | std::array buffer; 28 | while (1) 29 | { 30 | unsigned bytesRead = read(buffer.data(), buffer.size()); 31 | if (!bytesRead) 32 | break; 33 | res += std::string(buffer.data(), bytesRead); 34 | } 35 | return res; 36 | } 37 | 38 | unsigned read(char* buffer, unsigned length) 39 | { 40 | if (!good()) 41 | return 0; 42 | 43 | unsigned res = fread(buffer, sizeof(char), length, _fp); 44 | if (res != length) 45 | close(); 46 | return res; 47 | } 48 | 49 | virtual unsigned write(const char* buffer, unsigned length) 50 | { 51 | if (!good()) 52 | return 0; 53 | 54 | unsigned res = fwrite(buffer, sizeof(char), length, _fp); 55 | if (res != length) 56 | close(); 57 | return res; 58 | } 59 | 60 | virtual ~File() 61 | { 62 | close(); 63 | } 64 | 65 | bool close() 66 | { 67 | if (_fp != NULL) 68 | { 69 | fclose(_fp); 70 | _fp = NULL; 71 | return true; 72 | } 73 | return false; 74 | } 75 | 76 | bool good() const 77 | { 78 | return _fp != NULL; 79 | } 80 | 81 | protected: 82 | FILE* _fp; 83 | }; 84 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/extractor/test/ExtractorTest.cpp: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #include "unittest.h" 3 | #include "TestHelpers.h" 4 | 5 | #include "ExtractorPlus.h" 6 | #include "image_hash/average_hash.h" 7 | #include "util/MakeTempDirectory.h" 8 | #include 9 | #include 10 | #include 11 | 12 | TEST_CASE( "ExtractorTest/testExtract", "[unit]" ) 13 | { 14 | MakeTempDirectory tempdir; 15 | 16 | std::string imgPath = tempdir.path() / "ex.jpg"; 17 | ExtractorPlus ext({1024, 1024}, 30); 18 | ext.extract(TestCimbar::getSample("6bit/4_30_f0_big.jpg"), imgPath); 19 | 20 | cv::Mat out = cv::imread(imgPath); 21 | cv::cvtColor(out, out, cv::COLOR_BGR2RGB); 22 | assertEquals( 0x2cab639cfa72624, image_hash::average_hash(out) ); 23 | } 24 | 25 | TEST_CASE( "ExtractorTest/testExtractMid", "[unit]" ) 26 | { 27 | MakeTempDirectory tempdir; 28 | 29 | std::string imgPath = tempdir.path() / "ex.jpg"; 30 | ExtractorPlus ext({1024, 1024}, 30); 31 | ext.extract(TestCimbar::getSample("6bit/4_30_f2_734.jpg"), imgPath); 32 | 33 | cv::Mat out = cv::imread(imgPath); 34 | cv::cvtColor(out, out, cv::COLOR_BGR2RGB); 35 | assertEquals( 0xc7f8205e686bc02, image_hash::average_hash(out) ); 36 | } 37 | 38 | TEST_CASE( "ExtractorTest/testExtractUpscale", "[unit]" ) 39 | { 40 | MakeTempDirectory tempdir; 41 | 42 | std::string imgPath = tempdir.path() / "exup.jpg"; 43 | ExtractorPlus ext({1024, 1024}, 30); 44 | ext.extract(TestCimbar::getSample("6bit/4_30_f0_627.jpg"), imgPath); 45 | 46 | cv::Mat out = cv::imread(imgPath); 47 | cv::cvtColor(out, out, cv::COLOR_BGR2RGB); 48 | assertEquals( 0x29c64eaca3356394, image_hash::average_hash(out) ); 49 | } 50 | 51 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/cimb_translator/Interleave.h: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #pragma once 3 | 4 | #include 5 | 6 | namespace Interleave 7 | { 8 | inline std::vector interleave_indices(unsigned size, unsigned num_chunks, unsigned partitions) 9 | { 10 | std::vector indices; 11 | if (num_chunks == 0) 12 | { 13 | for (unsigned i = 0; i < size; ++i) 14 | indices.push_back(i); 15 | return indices; 16 | } 17 | 18 | unsigned partitionSize = size/partitions; 19 | for (unsigned part = 0; part < size; part+=partitionSize) 20 | for (unsigned chunk = 0; chunk < num_chunks; ++chunk) 21 | for (unsigned i = chunk; i < partitionSize; i+=num_chunks) 22 | indices.push_back(i + part); 23 | return indices; 24 | } 25 | 26 | inline std::vector interleave_reverse(unsigned size, unsigned num_chunks, unsigned partitions) 27 | { 28 | std::vector indices = interleave_indices(size, num_chunks, partitions); 29 | std::vector inverted(indices.size(), 0); 30 | for (unsigned src = 0; src < indices.size(); ++src) 31 | { 32 | unsigned dst = indices[src]; 33 | inverted[dst] = src; 34 | } 35 | return inverted; 36 | } 37 | 38 | template 39 | inline std::vector interleave(const std::vector& positions, unsigned num_chunks, unsigned partitions) 40 | { 41 | std::vector res; 42 | 43 | std::vector indices = interleave_indices(positions.size(), num_chunks, partitions); 44 | for (unsigned i = 0; i < indices.size(); ++i) 45 | { 46 | unsigned interleaveIdx = indices[i]; 47 | res.push_back(positions[interleaveIdx]); 48 | } 49 | return res; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/libcorrect/src/reed-solomon/encode.c: -------------------------------------------------------------------------------- 1 | #include "correct/reed-solomon/encode.h" 2 | 3 | ssize_t correct_reed_solomon_encode(correct_reed_solomon *rs, const uint8_t *msg, size_t msg_length, uint8_t *encoded) { 4 | if (msg_length > rs->message_length) { 5 | return -1; 6 | } 7 | 8 | size_t pad_length = rs->message_length - msg_length; 9 | for (unsigned int i = 0; i < msg_length; i++) { 10 | // message goes from high order to low order but libcorrect polynomials go low to high 11 | // so we reverse on the way in and on the way out 12 | // we'd have to do a copy anyway so this reversal should be free 13 | rs->encoded_polynomial.coeff[rs->encoded_polynomial.order - (i + pad_length)] = msg[i]; 14 | } 15 | 16 | // 0-fill the rest of the coefficients -- this length will always be > 0 17 | // because the order of this poly is block_length and the msg_length <= message_length 18 | // e.g. 255 and 223 19 | memset(rs->encoded_polynomial.coeff + (rs->encoded_polynomial.order + 1 - pad_length), 0, pad_length); 20 | memset(rs->encoded_polynomial.coeff, 0, (rs->encoded_polynomial.order + 1 - rs->message_length)); 21 | 22 | polynomial_mod(rs->field, rs->encoded_polynomial, rs->generator, rs->encoded_remainder); 23 | 24 | // now return byte order to highest order to lowest order 25 | for (unsigned int i = 0; i < msg_length; i++) { 26 | encoded[i] = rs->encoded_polynomial.coeff[rs->encoded_polynomial.order - (i + pad_length)]; 27 | } 28 | 29 | for (unsigned int i = 0; i < rs->min_distance; i++) { 30 | encoded[msg_length + i] = rs->encoded_remainder.coeff[rs->min_distance - (i + 1)]; 31 | } 32 | 33 | return rs->block_length; 34 | } 35 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/cimb_translator/LinearDecodePositions.h: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #pragma once 3 | 4 | #include "CellDrift.h" 5 | #include "CellPositions.h" 6 | #include 7 | 8 | class LinearDecodePositions 9 | { 10 | public: 11 | using iter = std::tuple; 12 | 13 | public: 14 | LinearDecodePositions(cimbar::vec_xy spacing, cimbar::vec_xy dimensions, int offset, cimbar::vec_xy marker_size); 15 | 16 | size_t count() const; 17 | void reset(); 18 | 19 | bool done() const; 20 | iter next(); 21 | int update(unsigned index, const CellDrift& drift, unsigned error_distance); 22 | 23 | protected: 24 | unsigned _index; 25 | CellPositions::positions_list _positions; 26 | CellDrift _drift; 27 | }; 28 | 29 | inline LinearDecodePositions::LinearDecodePositions(cimbar::vec_xy spacing, cimbar::vec_xy dimensions, int offset, cimbar::vec_xy marker_size) 30 | : _positions(CellPositions::compute(spacing, dimensions, offset, marker_size, 0)) 31 | , _drift() 32 | { 33 | reset(); 34 | } 35 | 36 | inline size_t LinearDecodePositions::count() const 37 | { 38 | return _positions.size(); 39 | } 40 | 41 | inline void LinearDecodePositions::reset() 42 | { 43 | _index = 0; 44 | _drift = CellDrift(); 45 | } 46 | 47 | inline bool LinearDecodePositions::done() const 48 | { 49 | return _index >= _positions.size(); 50 | } 51 | 52 | inline LinearDecodePositions::iter LinearDecodePositions::next() 53 | { 54 | unsigned i = _index++; 55 | return {i, _positions[i], _drift}; 56 | } 57 | 58 | inline int LinearDecodePositions::update(unsigned index, const CellDrift& drift, unsigned error_distance) 59 | { 60 | _drift = drift; 61 | return 0; 62 | } 63 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/extractor/test/CornersTest.cpp: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #include "unittest.h" 3 | 4 | #include "Corners.h" 5 | 6 | #include "Geometry.h" 7 | #include "Midpoints.h" 8 | #include 9 | #include 10 | #include 11 | 12 | TEST_CASE( "CornersTest/testSimple", "[unit]" ) 13 | { 14 | Corners corners({1, 1}, {20, 1}, {1, 30}, {40, 40}); 15 | assertEquals(point({1, 1}), corners.top_left()); 16 | assertEquals(point({20, 1}), corners.top_right()); 17 | assertEquals(point({1, 30}), corners.bottom_left()); 18 | assertEquals(point({40, 40}), corners.bottom_right()); 19 | } 20 | 21 | TEST_CASE( "CornersTest/testMidpoints", "[unit]" ) 22 | { 23 | Corners corners({1, 1}, {20, 1}, {1, 30}, {40, 40}); 24 | 25 | Midpoints mp = Geometry::calculate_midpoints(corners); 26 | 27 | assertEquals("9.76387,1", mp.top().str()); 28 | assertEquals("17.6324,34.2647", mp.bottom().str()); 29 | assertEquals("1,11.4214", mp.left().str()); 30 | assertEquals("26.5517,13.7759", mp.right().str()); 31 | } 32 | 33 | 34 | TEST_CASE( "CornersTest/testMidpoints.2", "[unit]" ) 35 | { 36 | Corners corners({69,192}, {840,156}, {148,890}, {809,884}); 37 | 38 | Midpoints mp = Geometry::calculate_midpoints(corners); 39 | // top=(446.66222422083973, 174.36596618424093), 40 | // right=(823.2766663941112, 548.7286085511948), 41 | // bottom=(472.7464269951889, 887.0522260787124), 42 | // left=(111.50273051900028, 567.5304544590152) 43 | assertEquals("446.662,174.366", mp.top().str()); 44 | assertEquals("472.746,887.052", mp.bottom().str()); 45 | assertEquals("111.503,567.53", mp.left().str()); 46 | assertEquals("823.277,548.729", mp.right().str()); 47 | } 48 | 49 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/exe/cimbar_extract/cimbar_extract.cpp: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #include "cimb_translator/Config.h" 3 | #include "extractor/ExtractorPlus.h" 4 | 5 | #include "cxxopts/cxxopts.hpp" 6 | 7 | #include 8 | using std::string; 9 | 10 | int main(int argc, char** argv) 11 | { 12 | cxxopts::Options options("cimbar_extract", "Scan/extract cimbar code from a source image."); 13 | 14 | options.add_options() 15 | ("i,in", "Encoded png/jpg/etc", cxxopts::value()) 16 | ("o,out", "Output image", cxxopts::value()) 17 | ("m,mode", "Select a cimbar mode. B (the default) is new to 0.6.x. 4C is the 0.5.x config. [B,Bm,4C]", cxxopts::value()->default_value("B")) 18 | ("h,help", "Print usage") 19 | ; 20 | options.show_positional_help(); 21 | options.parse_positional({"in", "out"}); 22 | options.positional_help(" "); 23 | 24 | auto result = options.parse(argc, argv); 25 | if (result.count("help") or !result.count("out") or !result.count("in")) 26 | { 27 | std::cout << options.help() << std::endl; 28 | exit(0); 29 | } 30 | 31 | // really, you only need to supply mode for non 1024x1024 configs 32 | unsigned config_mode = 68; 33 | if (result.count("mode")) 34 | { 35 | string mode = result["mode"].as(); 36 | if (mode == "4c" or mode == "4C") 37 | config_mode = 4; 38 | else if (mode == "Bm" or mode == "BM") 39 | config_mode = 67; 40 | } 41 | cimbar::Config::update(config_mode); 42 | 43 | std::string infile = result["in"].as(); 44 | std::string outfile = result["out"].as(); 45 | ExtractorPlus ext; 46 | if (!ext.extract(infile, outfile)) 47 | return 1; 48 | 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/libcorrect/tools/find_rs_primitive_poly.c: -------------------------------------------------------------------------------- 1 | #include "correct/reed-solomon.h" 2 | 3 | size_t block_size = 255; 4 | int power_max = 8; 5 | 6 | // visit all of the elements from the poly 7 | bool trypoly(field_operation_t poly, field_logarithm_t *log) { 8 | memset(log, 0, block_size + 1); 9 | field_operation_t element = 1; 10 | log[0] = (field_logarithm_t)0; 11 | for (field_operation_t i = 1; i < block_size + 1; i++) { 12 | element = element * 2; 13 | element = (element > block_size) ? (element ^ poly) : element; 14 | if (log[element] != 0) { 15 | return false; 16 | } 17 | log[element] = (field_logarithm_t)i; 18 | } 19 | return true; 20 | } 21 | 22 | int main() { 23 | field_logarithm_t *log = malloc((block_size + 1) * sizeof(field_logarithm_t)); 24 | for (field_operation_t i = (block_size + 1); i < (block_size + 1) << 1; i++) { 25 | if (trypoly(i, log)) { 26 | printf("0x%x valid: ", i); 27 | field_operation_t poly = i; 28 | int power = power_max; 29 | while(poly) { 30 | if (poly & (block_size + 1)) { 31 | if (power > 1) { 32 | printf("x^%d", power); 33 | } else if (power) { 34 | printf("x"); 35 | } else { 36 | printf("1"); 37 | } 38 | if (poly & block_size) { 39 | printf(" + "); 40 | } 41 | } 42 | power--; 43 | poly <<= 1; 44 | poly &= (block_size << 1) + 1; 45 | } 46 | printf("\n"); 47 | } 48 | } 49 | free(log); 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/zstd/compress/zstd_compress_literals.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under both the BSD-style license (found in the 6 | * LICENSE file in the root directory of this source tree) and the GPLv2 (found 7 | * in the COPYING file in the root directory of this source tree). 8 | * You may select, at your option, one of the above-listed licenses. 9 | */ 10 | 11 | #ifndef ZSTD_COMPRESS_LITERALS_H 12 | #define ZSTD_COMPRESS_LITERALS_H 13 | 14 | #include "zstd_compress_internal.h" /* ZSTD_hufCTables_t, ZSTD_minGain() */ 15 | 16 | 17 | size_t ZSTD_noCompressLiterals (void* dst, size_t dstCapacity, const void* src, size_t srcSize); 18 | 19 | /* ZSTD_compressRleLiteralsBlock() : 20 | * Conditions : 21 | * - All bytes in @src are identical 22 | * - dstCapacity >= 4 */ 23 | size_t ZSTD_compressRleLiteralsBlock (void* dst, size_t dstCapacity, const void* src, size_t srcSize); 24 | 25 | /* ZSTD_compressLiterals(): 26 | * @entropyWorkspace: must be aligned on 4-bytes boundaries 27 | * @entropyWorkspaceSize : must be >= HUF_WORKSPACE_SIZE 28 | * @suspectUncompressible: sampling checks, to potentially skip huffman coding 29 | */ 30 | size_t ZSTD_compressLiterals (void* dst, size_t dstCapacity, 31 | const void* src, size_t srcSize, 32 | void* entropyWorkspace, size_t entropyWorkspaceSize, 33 | const ZSTD_hufCTables_t* prevHuf, 34 | ZSTD_hufCTables_t* nextHuf, 35 | ZSTD_strategy strategy, int disableLiteralCompression, 36 | int suspectUncompressible, 37 | int bmi2); 38 | 39 | #endif /* ZSTD_COMPRESS_LITERALS_H */ 40 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/extractor/test/ScanStateTest.cpp: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #include "unittest.h" 3 | 4 | #include "ScanState.h" 5 | #include 6 | #include 7 | #include 8 | 9 | TEST_CASE( "ScanStateTest/testScan", "[unit]" ) 10 | { 11 | // ratio is 1:1:4:1:1 12 | // state.process() will return -1 (NOOP) if there is nothing to do. 13 | // but it will return a positive integer (the size of the range) if we found a match. 14 | ScanState_114 state; 15 | assertEquals(ScanState::NOOP, state.process(false)); 16 | assertEquals(ScanState::NOOP, state.process(false)); 17 | assertEquals(ScanState::NOOP, state.process(false)); 18 | assertEquals(ScanState::NOOP, state.process(false)); 19 | assertEquals(ScanState::NOOP, state.process(false)); 20 | assertEquals(ScanState::NOOP, state.process(false)); 21 | assertEquals(ScanState::NOOP, state.process(true)); 22 | assertEquals(ScanState::NOOP, state.process(false)); 23 | assertEquals(ScanState::NOOP, state.process(true)); 24 | assertEquals(ScanState::NOOP, state.process(false)); 25 | assertEquals(ScanState::NOOP, state.process(false)); 26 | 27 | for (int i = 0; i < 3; ++i) 28 | assertEquals(ScanState::NOOP, state.process(true)); 29 | for (int i = 0; i < 3; ++i) 30 | assertEquals(ScanState::NOOP, state.process(false)); 31 | for (int i = 0; i < 12; ++i) 32 | assertEquals(ScanState::NOOP, state.process(true)); 33 | for (int i = 0; i < 3; ++i) 34 | assertEquals(ScanState::NOOP, state.process(false)); 35 | for (int i = 0; i < 3; ++i) 36 | assertEquals(ScanState::NOOP, state.process(true)); 37 | 38 | // found one! 39 | assertEquals( 24, state.process(false) ); 40 | 41 | assertEquals(ScanState::NOOP, state.process(false)); 42 | assertEquals(ScanState::NOOP, state.process(false)); 43 | } 44 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/cimb_translator/FloodDecodePositions.h: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #pragma once 3 | 4 | #include "AdjacentCellFinder.h" 5 | #include "CellDrift.h" 6 | #include "CellPositions.h" 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | class FloodDecodePositions 13 | { 14 | public: 15 | using iter = std::tuple; 16 | // compress these types down to reduce size and cache pressure? 17 | // i.e. with a struct ... 18 | using decode_instructions = std::tuple; // drift, best_prio, cooldown_pos 19 | using decode_prio = std::tuple; // index, prio 20 | 21 | class PrioCompare 22 | { 23 | public: 24 | bool operator()(const decode_prio& a, const decode_prio& b) const 25 | { 26 | return std::get<1>(a) > std::get<1>(b); 27 | } 28 | }; 29 | 30 | public: 31 | FloodDecodePositions(cimbar::vec_xy spacing, cimbar::vec_xy dimensions, int offset, cimbar::vec_xy marker_size); 32 | 33 | size_t size() const; 34 | void reset(); 35 | 36 | bool done() const; 37 | iter next(); 38 | int update(unsigned index, const CellDrift& drift, unsigned error_distance, uint8_t cooldown); 39 | 40 | const CellPositions::positions_list& positions() const; 41 | 42 | protected: 43 | int update_adjacents(const std::array& adj, const CellDrift& drift, unsigned error_distance, uint8_t cooldown); 44 | 45 | protected: 46 | unsigned _index; 47 | unsigned _count; 48 | std::priority_queue, PrioCompare> _heap; 49 | std::vector _remaining; 50 | std::vector _instructions; 51 | CellPositions::positions_list _positions; 52 | AdjacentCellFinder _cellFinder; 53 | int _topWidth; 54 | }; 55 | 56 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/extractor/SimpleCameraCalibration.h: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #pragma once 3 | 4 | #include "Corners.h" 5 | #include "DistortionParameters.h" 6 | #include "Midpoints.h" 7 | #include "Point.h" 8 | #include "Scanner.h" 9 | #include 10 | 11 | // implements CAMERA_CALIBRATOR 12 | class SimpleCameraCalibration 13 | { 14 | public: 15 | SimpleCameraCalibration(); 16 | 17 | template 18 | DistortionParameters scan(const MAT& img); 19 | 20 | protected: 21 | double calculate_distortion_factor(const Corners& corners, const Midpoints& mps, const std::vector>& edges); 22 | 23 | static DistortionParameters naive_radial_undistort(int width, int height, double distortion_factor); 24 | 25 | protected: 26 | int _size; 27 | double _targetRatio; 28 | }; 29 | 30 | template 31 | inline DistortionParameters SimpleCameraCalibration::scan(const MAT& img) 32 | { 33 | Scanner scanner(img); 34 | std::vector anchors = scanner.scan(); 35 | if (anchors.size() < 4) 36 | return {}; 37 | 38 | Corners corners(anchors); 39 | Midpoints mps; 40 | std::vector> edges = scanner.scan_edges(corners, mps); 41 | if (edges.size() < 4) 42 | return {}; 43 | 44 | double distortion_factor = calculate_distortion_factor(corners, mps, edges); 45 | return naive_radial_undistort(img.cols, img.rows, distortion_factor); 46 | } 47 | 48 | inline DistortionParameters SimpleCameraCalibration::naive_radial_undistort(int width, int height, double distortion_factor) 49 | { 50 | // we're treating distortion_factor as being close to k1 51 | DistortionParameters dp; 52 | 53 | dp.camera = (cv::Mat1d(3, 3) << width/4, 0, width/2, 0, height/4, height/2, 0, 0, 1); 54 | dp.distortion = (cv::Mat1d(1, 4) << distortion_factor, 0, 0, 0); 55 | return dp; 56 | } 57 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/zstd/common/allocations.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under both the BSD-style license (found in the 6 | * LICENSE file in the root directory of this source tree) and the GPLv2 (found 7 | * in the COPYING file in the root directory of this source tree). 8 | * You may select, at your option, one of the above-listed licenses. 9 | */ 10 | 11 | /* This file provides custom allocation primitives 12 | */ 13 | 14 | #define ZSTD_DEPS_NEED_MALLOC 15 | #include "zstd_deps.h" /* ZSTD_malloc, ZSTD_calloc, ZSTD_free, ZSTD_memset */ 16 | 17 | #include "mem.h" /* MEM_STATIC */ 18 | #define ZSTD_STATIC_LINKING_ONLY 19 | #include "../zstd.h" /* ZSTD_customMem */ 20 | 21 | #ifndef ZSTD_ALLOCATIONS_H 22 | #define ZSTD_ALLOCATIONS_H 23 | 24 | /* custom memory allocation functions */ 25 | 26 | MEM_STATIC void* ZSTD_customMalloc(size_t size, ZSTD_customMem customMem) 27 | { 28 | if (customMem.customAlloc) 29 | return customMem.customAlloc(customMem.opaque, size); 30 | return ZSTD_malloc(size); 31 | } 32 | 33 | MEM_STATIC void* ZSTD_customCalloc(size_t size, ZSTD_customMem customMem) 34 | { 35 | if (customMem.customAlloc) { 36 | /* calloc implemented as malloc+memset; 37 | * not as efficient as calloc, but next best guess for custom malloc */ 38 | void* const ptr = customMem.customAlloc(customMem.opaque, size); 39 | ZSTD_memset(ptr, 0, size); 40 | return ptr; 41 | } 42 | return ZSTD_calloc(1, size); 43 | } 44 | 45 | MEM_STATIC void ZSTD_customFree(void* ptr, ZSTD_customMem customMem) 46 | { 47 | if (ptr!=NULL) { 48 | if (customMem.customFree) 49 | customMem.customFree(customMem.opaque, ptr); 50 | else 51 | ZSTD_free(ptr); 52 | } 53 | } 54 | 55 | #endif /* ZSTD_ALLOCATIONS_H */ 56 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/image_hash/test/averageHashTest.cpp: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #include "unittest.h" 3 | 4 | #include "average_hash.h" 5 | 6 | #include "cimb_translator/Common.h" 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | using std::string; 15 | 16 | TEST_CASE( "averageHashTest/test5x5.Light", "[unit]" ) 17 | { 18 | cv::Mat tile = cimbar::getTile(2, 0, false); 19 | assertEquals(0x8cef, image_hash::average_hash(tile)); 20 | 21 | tile = cimbar::getTile(2, 1, false); 22 | assertEquals(0xf38c20, image_hash::average_hash(tile)); 23 | } 24 | 25 | TEST_CASE( "averageHashTest/test5x5.Dark", "[unit]" ) 26 | { 27 | cv::Mat tile = cimbar::getTile(2, 0, true); 28 | assertEquals(0x1ff7310, image_hash::average_hash(tile)); 29 | 30 | tile = cimbar::getTile(2, 1, true); 31 | assertEquals(0x10c73df, image_hash::average_hash(tile)); 32 | } 33 | 34 | TEST_CASE( "averageHashTest/test8x8.Light", "[unit]" ) 35 | { 36 | cv::Mat tile = cimbar::getTile(4, 0, false); 37 | assertEquals(0x103070f1f3f7f, image_hash::average_hash(tile)); 38 | 39 | tile = cimbar::getTile(4, 1, false); 40 | assertEquals(0x7f3f1f0f07030100, image_hash::average_hash(tile)); 41 | } 42 | 43 | TEST_CASE( "averageHashTest/test8x8.Dark", "[unit]" ) 44 | { 45 | cv::Mat tile = cimbar::getTile(4, 0, true); 46 | assertEquals(0xfffefcf8f0e0c080, image_hash::average_hash(tile)); 47 | 48 | tile = cimbar::getTile(4, 1, true); 49 | assertEquals(0x80c0e0f0f8fcfeff, image_hash::average_hash(tile)); 50 | } 51 | 52 | TEST_CASE( "averageHashTest/test8x8.Resize", "[unit]" ) 53 | { 54 | cv::Mat tile = cimbar::getTile(4, 0, true); 55 | 56 | cv::Mat big; 57 | cv::resize(tile, big, cv::Size(32, 32)); 58 | assertEquals(0xfffefcf8f0e0c080, image_hash::average_hash(big)); 59 | } 60 | 61 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/libcorrect/include/correct/convolutional/convolutional.h: -------------------------------------------------------------------------------- 1 | #ifndef CORRECT_CONVOLUTIONAL_H 2 | #define CORRECT_CONVOLUTIONAL_H 3 | #include "correct/convolutional.h" 4 | #include "correct/convolutional/bit.h" 5 | #include "correct/convolutional/metric.h" 6 | #include "correct/convolutional/lookup.h" 7 | #include "correct/convolutional/history_buffer.h" 8 | #include "correct/convolutional/error_buffer.h" 9 | 10 | struct correct_convolutional { 11 | const unsigned int *table; // size 2**order 12 | size_t rate; // e.g. 2, 3... 13 | size_t order; // e.g. 7, 9... 14 | unsigned int numstates; // 2**order 15 | bit_writer_t *bit_writer; 16 | bit_reader_t *bit_reader; 17 | 18 | bool has_init_decode; 19 | distance_t *distances; 20 | pair_lookup_t pair_lookup; 21 | soft_measurement_t soft_measurement; 22 | history_buffer *history_buffer; 23 | error_buffer_t *errors; 24 | }; 25 | 26 | correct_convolutional *_correct_convolutional_init(correct_convolutional *conv, 27 | size_t rate, size_t order, 28 | const polynomial_t *poly); 29 | void _correct_convolutional_teardown(correct_convolutional *conv); 30 | 31 | // portable versions 32 | void _convolutional_decode_init(correct_convolutional *conv, unsigned int min_traceback, unsigned int traceback_length, unsigned int renormalize_interval); 33 | void convolutional_decode_warmup(correct_convolutional *conv, unsigned int sets, 34 | const uint8_t *soft); 35 | void convolutional_decode_inner(correct_convolutional *conv, unsigned int sets, 36 | const uint8_t *soft); 37 | void convolutional_decode_tail(correct_convolutional *conv, unsigned int sets, 38 | const uint8_t *soft); 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/zstd/common/zstd_common.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under both the BSD-style license (found in the 6 | * LICENSE file in the root directory of this source tree) and the GPLv2 (found 7 | * in the COPYING file in the root directory of this source tree). 8 | * You may select, at your option, one of the above-listed licenses. 9 | */ 10 | 11 | 12 | 13 | /*-************************************* 14 | * Dependencies 15 | ***************************************/ 16 | #define ZSTD_DEPS_NEED_MALLOC 17 | #include "error_private.h" 18 | #include "zstd_internal.h" 19 | 20 | 21 | /*-**************************************** 22 | * Version 23 | ******************************************/ 24 | unsigned ZSTD_versionNumber(void) { return ZSTD_VERSION_NUMBER; } 25 | 26 | const char* ZSTD_versionString(void) { return ZSTD_VERSION_STRING; } 27 | 28 | 29 | /*-**************************************** 30 | * ZSTD Error Management 31 | ******************************************/ 32 | #undef ZSTD_isError /* defined within zstd_internal.h */ 33 | /*! ZSTD_isError() : 34 | * tells if a return value is an error code 35 | * symbol is required for external callers */ 36 | unsigned ZSTD_isError(size_t code) { return ERR_isError(code); } 37 | 38 | /*! ZSTD_getErrorName() : 39 | * provides error code string from function result (useful for debugging) */ 40 | const char* ZSTD_getErrorName(size_t code) { return ERR_getErrorName(code); } 41 | 42 | /*! ZSTD_getError() : 43 | * convert a `size_t` function result into a proper ZSTD_errorCode enum */ 44 | ZSTD_ErrorCode ZSTD_getErrorCode(size_t code) { return ERR_getErrorCode(code); } 45 | 46 | /*! ZSTD_getErrorString() : 47 | * provides error code string from enum */ 48 | const char* ZSTD_getErrorString(ZSTD_ErrorCode code) { return ERR_getErrorString(code); } 49 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/lib/cimbar_js/cimbar_recv_js.h: -------------------------------------------------------------------------------- 1 | /* This code is subject to the terms of the Mozilla Public License, v.2.0. http://mozilla.org/MPL/2.0/. */ 2 | #ifndef CIMBAR_RECV_JS_API_H 3 | #define CIMBAR_RECV_JS_API_H 4 | 5 | #include 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | unsigned cimbard_get_report(unsigned char* buff, unsigned maxlen); 12 | unsigned cimbard_get_debug(unsigned char* buff, unsigned maxlen); 13 | 14 | // imgsize=width*height*channels for rgba. Other formats are weirder. 15 | // output of scan is stored in `bufspace` 16 | int cimbard_get_bufsize(); 17 | int cimbard_scan_extract_decode(const unsigned char* imgdata, unsigned imgw, unsigned imgh, int format, unsigned char* bufspace, unsigned bufsize); 18 | 19 | // returns id of final file (can be used to get size of `finish_copy`'s buffer) if complete, 0 if success, negative on error 20 | // persists state, the return value (if >0) corresponds to a uint32_t id 21 | int64_t cimbard_fountain_decode(const unsigned char* buffer, unsigned size); 22 | 23 | // get compressed filesize from id 24 | // you probably don't need to use this. 25 | unsigned cimbard_get_filesize(uint32_t id); 26 | 27 | // if fountain_decode returned a >0 value, 28 | // get filename and (partial) contents from reassembled file 29 | // wherever a uint32_t id is passed, it should be in the 30 | // same js shared memory as the fountain_decode() call 31 | // cimbard_decompress_read() will return 0 when all file contents have been read 32 | int cimbard_get_filename(uint32_t id, char* filename, unsigned fnsize); 33 | int cimbard_get_decompress_bufsize(); 34 | int cimbard_decompress_read(uint32_t id, unsigned char* buffer, unsigned size); 35 | 36 | int cimbard_configure_decode(int mode_val); 37 | 38 | // testing usage only! 39 | unsigned char* cimbard_get_reassembled_file_buff(); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | #endif // CIMBAR_RECV_JS_API_H 46 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/wirehair/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(wirehair) 3 | 4 | set(CMAKE_CXX_STANDARD 11) 5 | 6 | set(LIB_SOURCE_FILES 7 | wirehair.cpp 8 | include/wirehair/wirehair.h 9 | gf256.cpp 10 | gf256.h 11 | WirehairCodec.cpp 12 | WirehairCodec.h 13 | WirehairTools.cpp 14 | WirehairTools.h 15 | ) 16 | 17 | set(UNIT_TEST_SOURCE_FILES 18 | test/SiameseTools.cpp 19 | test/SiameseTools.h 20 | test/UnitTest.cpp 21 | ) 22 | 23 | set(GEN_SMALL_DSEEDS 24 | test/SiameseTools.cpp 25 | test/SiameseTools.h 26 | tables/GenerateSmallDenseSeeds.cpp 27 | ) 28 | 29 | set(GEN_PEEL_SEEDS 30 | test/SiameseTools.cpp 31 | test/SiameseTools.h 32 | tables/GeneratePeelSeeds.cpp 33 | ) 34 | 35 | set(GEN_MOST_DSEEDS 36 | test/SiameseTools.cpp 37 | test/SiameseTools.h 38 | tables/GenerateMostDenseSeeds.cpp 39 | ) 40 | 41 | set(GEN_DCOUNTS 42 | test/SiameseTools.cpp 43 | test/SiameseTools.h 44 | tables/GenerateDenseCount.cpp 45 | ) 46 | 47 | set(GEN_TABLES 48 | test/SiameseTools.cpp 49 | test/SiameseTools.h 50 | tables/TableGenerator.cpp 51 | tables/HeavyRowGenerator.cpp 52 | tables/HeavyRowGenerator.h 53 | gf256.cpp 54 | gf256.h 55 | ) 56 | 57 | if(NOT ANDROID AND NOT USE_WASM) 58 | set(ARCH_NATIVE "-march=native") 59 | endif() 60 | 61 | if(MSVC) 62 | else() 63 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARCH_NATIVE}") 64 | endif() 65 | 66 | add_library(wirehair ${LIB_SOURCE_FILES}) 67 | set_target_properties(wirehair PROPERTIES VERSION 2) 68 | set_target_properties(wirehair PROPERTIES SOVERSION 2) 69 | target_include_directories(wirehair PUBLIC ${PROJECT_SOURCE_DIR}/include) 70 | 71 | include(GNUInstallDirs) 72 | 73 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/web/test/run-in-browser.js: -------------------------------------------------------------------------------- 1 | // simple test scaffolding to run qunit in browser 2 | // using puppeteer for now, playwright might be better??? 3 | // copy+paste, ai cross reference, I didn't write this, 4 | // run at your own risk etc (it's pretty simple though) 5 | const puppeteer = require('puppeteer'); 6 | const path = require('path'); 7 | const QUnit = require('qunit'); 8 | 9 | (async () => { 10 | const browser = await puppeteer.launch({ headless: true, args: ['--no-sandbox', '--disable-setuid-sandbox'] }); 11 | const page = await browser.newPage(); 12 | 13 | page.on('console', msg => console.log('BROWSER CONSOLE:', msg.text())); 14 | page.on('pageerror', err => console.error('PAGE ERROR:', err)); 15 | 16 | await page.exposeFunction('onLogMe', (details) => { 17 | if (!details.result) { 18 | details.expected = JSON.stringify(details.expected); 19 | details.actual = JSON.stringify(details.actual); 20 | console.error(details); 21 | } 22 | }); 23 | 24 | // Expose a function to capture QUnit results 25 | await page.exposeFunction('onQUnitDone', (stats) => { 26 | if (stats.failed > 0) { 27 | console.error(stats); 28 | console.error(`QUnit Tests Failed: ${stats.failed} assertions failed.`); 29 | process.exit(stats.failed); // nonzero is failure 30 | } else { 31 | console.log('All QUnit Tests Passed!'); 32 | process.exit(0); 33 | } 34 | }); 35 | 36 | // Navigate to your QUnit test page 37 | const testPagePath = '/test_recv.html'; 38 | await page.goto(`http://localhost:8080/${testPagePath}`); 39 | 40 | // Wait for QUnit to finish 41 | await page.evaluate(() => { 42 | return new Promise(resolve => { 43 | QUnit.log(details => { 44 | window.onLogMe(details); 45 | }); 46 | 47 | QUnit.done(stats => { 48 | window.onQUnitDone(stats); 49 | resolve(); 50 | }); 51 | }); 52 | }); 53 | 54 | await browser.close(); 55 | })(); 56 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/src/third_party_lib/libcorrect/.appveyor-install-tools.cmd: -------------------------------------------------------------------------------- 1 | @echo on 2 | 3 | if NOT EXIST C:\projects\tools ( 4 | mkdir C:\projects\tools 5 | ) 6 | cd C:\projects\tools 7 | 8 | ::########################################################################### 9 | :: Setup Compiler 10 | ::########################################################################### 11 | if NOT EXIST llvm-installer.exe ( 12 | appveyor DownloadFile http://prereleases.llvm.org/win-snapshots/LLVM-5.0.0-r306282-win32.exe -FileName llvm-installer.exe 13 | ) 14 | 15 | START /WAIT llvm-installer.exe /S /D=C:\"projects\tools\LLVM-install" 16 | @set PATH="C:\projects\tools\LLVM-install\bin";%PATH% 17 | clang-cl -v 18 | 19 | if DEFINED MINGW_PATH rename "C:\Program Files\Git\usr\bin\sh.exe" "sh-ignored.exe" 20 | if DEFINED MINGW_PATH @set "PATH=%PATH:C:\Program Files (x86)\Git\bin=%" 21 | if DEFINED MINGW_PATH @set "PATH=%PATH%;%MINGW_PATH%" 22 | if DEFINED MINGW_PATH g++ -v 23 | 24 | ::########################################################################### 25 | :: Install a recent CMake 26 | ::########################################################################### 27 | if NOT EXIST cmake ( 28 | appveyor DownloadFile https://cmake.org/files/v3.7/cmake-3.7.2-win64-x64.zip -FileName cmake.zip 29 | 7z x cmake.zip -oC:\projects\tools > nul 30 | move C:\projects\tools\cmake-* C:\projects\tools\cmake 31 | rm cmake.zip 32 | ) 33 | @set PATH=C:\projects\tools\cmake\bin;%PATH% 34 | cmake --version 35 | 36 | ::########################################################################### 37 | :: Install Ninja 38 | ::########################################################################### 39 | if NOT EXIST ninja ( 40 | appveyor DownloadFile https://github.com/ninja-build/ninja/releases/download/v1.6.0/ninja-win.zip -FileName ninja.zip 41 | 7z x ninja.zip -oC:\projects\tools\ninja > nul 42 | rm ninja.zip 43 | ) 44 | @set PATH=C:\projects\tools\ninja;%PATH% 45 | ninja --version 46 | 47 | @echo off 48 | -------------------------------------------------------------------------------- /app/src/cpp/libcimbar/.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: ci 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | name: ${{ matrix.config.name }} 8 | runs-on: ${{ matrix.config.os }} 9 | strategy: 10 | fail-fast: true 11 | matrix: 12 | config: 13 | - name: "linux gcc9" 14 | os: ubuntu-22.04 15 | env: CXX="g++-9" CC="gcc-9" 16 | 17 | - name: "linux gcc-latest" 18 | os: ubuntu-latest 19 | 20 | - name: "linux clang14" 21 | os: ubuntu-22.04 22 | env: CXX="clang++" CC="clang" 23 | extra-packages: "clang" 24 | 25 | - name: "linux clang-latest" 26 | os: ubuntu-latest 27 | env: CXX="clang++" CC="clang" 28 | extra-packages: "clang" 29 | 30 | steps: 31 | - uses: actions/checkout@v4 32 | with: 33 | submodules: 'recursive' 34 | 35 | - name: Install dependencies 36 | run: sudo apt-get update && sudo apt-get install libopencv-dev libglfw3-dev libgles2-mesa-dev ${{ matrix.config.extra-packages }} 37 | 38 | - name: Create Build Environment 39 | run: cmake -E make_directory ${{runner.workspace}}/build 40 | 41 | - name: Configure CMake 42 | working-directory: ${{runner.workspace}}/build 43 | run: ${{ matrix.config.env }} cmake $GITHUB_WORKSPACE 44 | 45 | - name: Build 46 | working-directory: ${{runner.workspace}}/build 47 | run: cmake --build . && cmake --install . 48 | 49 | - name: Test 50 | working-directory: ${{runner.workspace}}/build 51 | run: ctest --output-on-failure 52 | 53 | - name: Usage test 54 | working-directory: ${{runner.workspace}}/libcimbar/test/py 55 | run: python3 -m unittest 56 | 57 | cppcheck: 58 | runs-on: ubuntu-22.04 59 | 60 | steps: 61 | - uses: actions/checkout@v4 62 | 63 | - name: Install dependencies 64 | run: sudo apt-get install cppcheck 65 | 66 | - name: run cppcheck 67 | run: cppcheck src/ 68 | 69 | --------------------------------------------------------------------------------