pax_global_header00006660000000000000000000000064150714470050014515gustar00rootroot0000000000000052 comment=18f23fa50b91931246dbfba9a29a2d9fb5a9e86d camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/000077500000000000000000000000001507144700500223715ustar00rootroot00000000000000camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/.clang-format000066400000000000000000000044251507144700500247510ustar00rootroot00000000000000--- # Webkit style was loosely based on the Qt style BasedOnStyle: WebKit Standard: Cpp11 IndentWidth: 4 # Leave the line breaks up to the user. # Note that this may be changed at some point in the future. ColumnLimit: 0 # How much weight do extra characters after the line length limit have. # PenaltyExcessCharacter: 4 # Disable reflow of qdoc comments: indentation rules are different. # Translation comments are also excluded. CommentPragmas: "^!|^:" # We want a space between the type and the star for pointer types. PointerBindsToType: false # We use template< without space. SpaceAfterTemplateKeyword: false # We want to break before the operators, but not before a '='. BreakBeforeBinaryOperators: NonAssignment # Braces are usually attached, but not after functions or class declarations. BreakBeforeBraces: Custom BraceWrapping: AfterClass: true AfterControlStatement: false AfterEnum: false AfterFunction: true AfterNamespace: false AfterObjCDeclaration: false AfterStruct: true AfterUnion: false BeforeCatch: false BeforeElse: false IndentBraces: false # When constructor initializers do not fit on one line, put them each on a new line. ConstructorInitializerAllOnOneLineOrOnePerLine: false # Indent initializers by 4 spaces ConstructorInitializerIndentWidth: 4 # Indent width for line continuations. ContinuationIndentWidth: 8 # No indentation for namespaces. NamespaceIndentation: None # Horizontally align arguments after an open bracket. # The coding style does not specify the following, but this is what gives # results closest to the existing code. AlignAfterOpenBracket: true AlwaysBreakTemplateDeclarations: true # Ideally we should also allow less short function in a single line, but # clang-format does not handle that. AllowShortFunctionsOnASingleLine: Inline # The coding style specifies some include order categories, but also tells to # separate categories with an empty line. It does not specify the order within # the categories. Since the SortInclude feature of clang-format does not # re-order includes separated by empty lines, the feature is not used. SortIncludes: false # macros for which the opening brace stays attached. ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, forever, Q_FOREVER, QBENCHMARK, QBENCHMARK_ONCE ] camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/.gitignore000066400000000000000000000006431507144700500243640ustar00rootroot00000000000000# build dir /build/ # clickable dir /.clickable/ # Prerequisites *.d # Compiled Object files *.slo *.lo *.o *.obj # Precompiled Headers *.gch *.pch # Compiled Dynamic libraries *.so *.dylib *.dll # Fortran module files *.mod *.smod # Compiled Static libraries *.lai *.la *.a *.lib # Executables *.exe *.out *.app # Test directory /plugins/ImageProcessing/Test/* # clangd stuff /.clangd/ compile_commands.json camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/.gitlab-ci.yml000066400000000000000000000033231507144700500250260ustar00rootroot00000000000000stages: - deps - build - publish variables: GIT_SUBMODULE_STRATEGY: "recursive" DOCKER_DRIVER: "overlay2" CLICKABLE_VERSION: "8.5.0" UT_VERSION: "ut24.04-1.x" default: image: "clickable/ci-$UT_VERSION-$ARCH:$CLICKABLE_VERSION" cache: &opencv_cache key: '$CI_JOB_NAME-$CI_COMMIT_REF_SLUG-4.1.2' untracked: true .armhf: &armhf variables: ARCH: "armhf" ARCH_TRIPLET: "arm-linux-gnueabihf" .arm64: &arm64 variables: ARCH: "arm64" ARCH_TRIPLET: "aarch64-linux-gnu" .amd64: &amd64 variables: ARCH: "amd64" ARCH_TRIPLET: "x86_64-linux-gnu" .opencv: stage: deps script: 'clickable build --libs opencv --arch $ARCH' cache: <<: *opencv_cache paths: - "build/$ARCH_TRIPLET/opencv" artifacts: paths: - "build/$ARCH_TRIPLET/opencv/install" expire_in: 1 week .app: stage: build script: 'clickable build --arch $ARCH' artifacts: paths: - "build/$ARCH_TRIPLET/app" expire_in: 1 week opencv-armhf: <<: *armhf extends: .opencv opencv-arm64: <<: *arm64 extends: .opencv opencv-amd64: <<: *amd64 extends: .opencv app-armhf: <<: *armhf dependencies: - opencv-armhf extends: .app app-arm64: <<: *arm64 dependencies: - opencv-arm64 extends: .app app-amd64: <<: *amd64 dependencies: - opencv-amd64 extends: .app publish: <<: *amd64 stage: publish only: - tags script: - 'clickable publish --arch armhf' - 'clickable publish --arch arm64' - 'clickable publish --arch amd64' dependencies: - app-armhf - app-arm64 - app-amd64 artifacts: paths: - build/arm-linux-gnueabihf/app/*.click - build/aarch64-linux-gnu/app/*.click - build/x86_64-linux-gnu/app/*.click expire_in: 30 days camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/.gitmodules000066400000000000000000000001401507144700500245410ustar00rootroot00000000000000[submodule "libs/opencv"] path = libs/opencv url = https://github.com/opencv/opencv.git camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/CMakeLists.txt000066400000000000000000000045241507144700500251360ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.0.0) project(camerascanner C CXX) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") find_package(Qt5Core) find_package(Qt5Qml) find_package(Qt5Quick) find_package(Qt5Sql) # Automatically create moc files set(CMAKE_AUTOMOC ON) set(QT_IMPORTS_DIR "lib/$ENV{ARCH_TRIPLET}") set(CLICK_ARCH "$ENV{ARCH}") set(PROJECT_NAME "camerascanner") set(FULL_PROJECT_NAME "camerascanner.jonnius") set(CMAKE_INSTALL_PREFIX /) set(DATA_DIR /) set(DESKTOP_FILE_NAME ${PROJECT_NAME}.desktop) configure_file(manifest.json.in ${CMAKE_CURRENT_BINARY_DIR}/manifest.json) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/manifest.json DESTINATION ${CMAKE_INSTALL_PREFIX}) install(FILES ${PROJECT_NAME}.apparmor DESTINATION ${DATA_DIR}) install(DIRECTORY qml DESTINATION ${DATA_DIR}) install(DIRECTORY assets DESTINATION ${DATA_DIR}) add_executable(${PROJECT_NAME} main.cpp) qt5_use_modules(${PROJECT_NAME} Gui Qml Quick QuickControls2) install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}) # Translations file(GLOB_RECURSE I18N_SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/po qml/*.qml qml/*.js plugins/ImageProcessing/*.h plugins/ImageProcessing/*.cpp) list(APPEND I18N_SRC_FILES ${DESKTOP_FILE_NAME}.in.h) find_program(INTLTOOL_MERGE intltool-merge) if(NOT INTLTOOL_MERGE) message(FATAL_ERROR "Could not find intltool-merge, please install the intltool package") endif() find_program(INTLTOOL_EXTRACT intltool-extract) if(NOT INTLTOOL_EXTRACT) message(FATAL_ERROR "Could not find intltool-extract, please install the intltool package") endif() add_custom_target(${DESKTOP_FILE_NAME} ALL COMMENT "Merging translations into ${DESKTOP_FILE_NAME}..." COMMAND LC_ALL=C ${INTLTOOL_MERGE} -d -u ${CMAKE_SOURCE_DIR}/po ${CMAKE_SOURCE_DIR}/${DESKTOP_FILE_NAME}.in ${DESKTOP_FILE_NAME} COMMAND sed -i 's/${PROJECT_NAME}-//g' ${CMAKE_CURRENT_BINARY_DIR}/${DESKTOP_FILE_NAME} ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${DESKTOP_FILE_NAME} DESTINATION ${DATA_DIR}) add_subdirectory(po) add_subdirectory(plugins) # Make source files visible in qtcreator file(GLOB_RECURSE PROJECT_SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} qml/*.qml qml/*.js *.json *.json.in *.apparmor *.desktop.in ) add_custom_target(${PROJECT_NAME}_FILES ALL SOURCES ${PROJECT_SRC_FILES}) camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/LICENSE000066400000000000000000001074471507144700500234130ustar00rootroot00000000000000GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2020 Jonatan Hatakeyama Zeidler This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. {one line to give the program's name and a brief idea of what it does.} Copyright (C) {year} {name of author} This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: {project} Copyright (C) {year} {fullname} This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/README.md000066400000000000000000000042271507144700500236550ustar00rootroot00000000000000[![pipeline status](https://gitlab.com/jonnius/camera-scanner/badges/master/pipeline.svg)](https://gitlab.com/jonnius/camera-scanner/commits/master) # Camera Scanner - An Ubuntu Touch Document Scanner App This is an Ubuntu Touch App to scan documents using your camera. ## How to get it [![OpenStore](https://open-store.io/badges/en_US.png)](https://open-store.io/app/camerascanner.jonnius) Or build it yourself following instructions below. ## Building the app ### Dependencies Install [clickable](https://clickable-ut.dev/en/latest/), which is used to build this app and dependencies. This app depends on OpenCV. You can easily build OpenCV by running git submodule update --init --recursive clickable build --libs --arch arm64 # or armhf, depending on your device clickable build --libs --arch amd64 # If you want to do desktop builds, too This may take quite some time, but only needs to be done once. ### Installation To build and launch the app, simply run clickable chain build install launch logs --arch arm64 # or armhf clickable desktop # to try a desktop build See [clickable documentation](https://clickable-ut.dev/en/latest/) for details. ## Code Style/Formatting ### C++ Clang-format is used to keep the code style consistent and should be run before committing any changes to C++ code. Install clang-format sudo apt install clang-format Then you can either run clang-format as a git pre commit hook (preffered) or run the apply-format script to format any staged changes. ./apply-format -i plugins/ImageProcessing/*.{h,cpp} ### QML Qmlfmt is used to keep the QML code style clean and should be run before committing any changes to QML code. Install [Qmlfmt](https://github.com/jesperhh/qmlfmt#build-instructions). You can either run qmlfmt as a git pre commit hook (preffered) or run `qmlfmt -w ` on any qml file. ## Contributors * Jonatan Hatakeyama Zeidler (jonnius) * Joan CiberSheep (cibersheep) * Stefan Weng (stefwe) * Christian Pauly (krille) * Anne017 The image processing algorithm is based on the one used in [OpenNoteScanner](https://github.com/ctodobom/OpenNoteScanner). camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/README_Development.md000066400000000000000000000010041507144700500262050ustar00rootroot00000000000000# Camera Scanner - An Ubuntu Touch Document Scanner App ## Test Image Processing only Compile OpenCV for desktop as described in the [README](README.md). Additionally install the following packages: sudo apt install libjpeg-dev libpng-dev libtiff-dev Uncomment line 6 in **plugins/ImageProcessing/Debugger.h**: #define NOQT Now you can code into **plugins/ImageProcessing/Test/Test.cpp** whatever you want. Compile and run it: cd plugins/ImageProcessing/Test cmake . make ./scannertest camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/apply-format000077500000000000000000000226351507144700500247420ustar00rootroot00000000000000#! /bin/bash # # Copyright 2018 Undo Ltd. # # https://github.com/barisione/clang-format-hooks # Force variable declaration before access. set -u # Make any failure in piped commands be reflected in the exit code. set -o pipefail readonly bash_source="${BASH_SOURCE[0]:-$0}" ################## # Misc functions # ################## function error_exit() { for str in "$@"; do echo -n "$str" >&2 done echo >&2 exit 1 } ######################## # Command line parsing # ######################## function show_help() { if [ -t 1 ] && hash tput 2> /dev/null; then local -r b=$(tput bold) local -r i=$(tput sitm) local -r n=$(tput sgr0) else local -r b= local -r i= local -r n= fi cat << EOF ${b}SYNOPSIS${n} To reformat git diffs: ${i}$bash_source [OPTIONS] [FILES-OR-GIT-DIFF-OPTIONS]${n} To reformat whole files, including unchanged parts: ${i}$bash_source [-f | --whole-file] FILES${n} ${b}DESCRIPTION${n} Reformat C or C++ code to match a specified formatting style. This command can either work on diffs, to reformat only changed parts of the code, or on whole files (if -f or --whole-file is used). ${b}FILES-OR-GIT-DIFF-OPTIONS${n} List of files to consider when applying clang-format to a diff. This is passed to "git diff" as is, so it can also include extra git options or revisions. For example, to apply clang-format on the changes made in the last few revisions you could use: ${i}\$ $bash_source HEAD~3${n} ${b}FILES${n} List of files to completely reformat. ${b}-f, --whole-file${n} Reformat the specified files completely (including parts you didn't change). The patch is printed on stdout by default. Use -i if you want to modify the files on disk. ${b}--staged, --cached${n} Reformat only code which is staged for commit. The patch is printed on stdout by default. Use -i if you want to modify the files on disk. ${b}-i${n} Reformat the code and apply the changes to the files on disk (instead of just printing the patch on stdout). ${b}--apply-to-staged${n} This is like specifying both --staged and -i, but the formatting changes are also staged for commit (so you can just use "git commit" to commit what you planned to, but formatted correctly). ${b}--style STYLE${n} The style to use for reformatting code. If no style is specified, then it's assumed there's a .clang-format file in the current directory or one of its parents. ${b}--help, -h, -?${n} Show this help. EOF } # getopts doesn't support long options. # getopt mangles stuff. # So we parse manually... declare positionals=() declare has_positionals=false declare whole_file=false declare apply_to_staged=false declare staged=false declare in_place=false declare style=file while [ $# -gt 0 ]; do declare arg="$1" shift # Past option. case "$arg" in -h | -\? | --help ) show_help exit 0 ;; -f | --whole-file ) whole_file=true ;; --apply-to-staged ) apply_to_staged=true ;; --cached | --staged ) staged=true ;; -i ) in_place=true ;; --style=* ) style="${arg//--style=/}" ;; --style ) [ $# -gt 0 ] || \ error_exit "No argument for --style option." style="$1" shift ;; -- ) # Stop processing further arguments. if [ $# -gt 0 ]; then positionals+=("$@") has_positionals=true fi break ;; -* ) error_exit "Unknown argument: $arg" ;; *) positionals+=("$arg") ;; esac done # Restore positional arguments, access them from "$@". if [ ${#positionals[@]} -gt 0 ]; then set -- "${positionals[@]}" has_positionals=true fi [ -n "$style" ] || \ error_exit "If you use --style you need to specify a valid style." ####################################### # Detection of clang-format & friends # ####################################### # clang-format. declare format="${CLANG_FORMAT:-}" if [ -z "$format" ]; then format=$(type -p clang-format) fi if [ -z "$format" ]; then error_exit \ $'You need to install clang-format.\n' \ $'\n' \ $'On Ubuntu/Debian this is available in the clang-format package or, in\n' \ $'older distro versions, clang-format-VERSION.\n' \ $'On Fedora it\'s available in the clang package.\n' \ $'You can also specify your own path for clang-format by setting the\n' \ $'$CLANG_FORMAT environment variable.' fi # clang-format-diff. if [ "$whole_file" = false ]; then invalid="/dev/null/invalid/path" if [ "${OSTYPE:-}" = "linux-gnu" ]; then readonly sort_version=-V else # On macOS, sort doesn't have -V. readonly sort_version=-n fi declare paths_to_try=() # .deb packages directly from upstream. # We try these first as they are probably newer than the system ones. while read -r f; do paths_to_try+=("$f") done < <(compgen -G "/usr/share/clang/clang-format-*/clang-format-diff.py" | sort "$sort_version" -r) # LLVM official releases (just untarred in /usr/local). while read -r f; do paths_to_try+=("$f") done < <(compgen -G "/usr/local/clang+llvm*/share/clang/clang-format-diff.py" | sort "$sort_version" -r) # Maybe it's in the $PATH already? This is true for Ubuntu and Debian. paths_to_try+=( \ "$(type -p clang-format-diff 2> /dev/null || echo "$invalid")" \ "$(type -p clang-format-diff.py 2> /dev/null || echo "$invalid")" \ ) # Fedora. paths_to_try+=( \ /usr/share/clang/clang-format-diff.py \ ) # Gentoo. while read -r f; do paths_to_try+=("$f") done < <(compgen -G "/usr/lib/llvm/*/share/clang/clang-format-diff.py" | sort -n -r) # Homebrew. while read -r f; do paths_to_try+=("$f") done < <(compgen -G "/usr/local/Cellar/clang-format/*/share/clang/clang-format-diff.py" | sort -n -r) declare format_diff= # Did the user specify a path? if [ -n "${CLANG_FORMAT_DIFF:-}" ]; then format_diff="$CLANG_FORMAT_DIFF" else for path in "${paths_to_try[@]}"; do if [ -e "$path" ]; then # Found! format_diff="$path" if [ ! -x "$format_diff" ]; then format_diff="python $format_diff" fi break fi done fi if [ -z "$format_diff" ]; then error_exit \ $'Cannot find clang-format-diff which should be shipped as part of the same\n' \ $'package where clang-format is.\n' \ $'\n' \ $'Please find out where clang-format-diff is in your distro and report an issue\n' \ $'at https://github.com/barisione/clang-format-hooks/issues with details about\n' \ $'your operating system and setup.\n' \ $'\n' \ $'You can also specify your own path for clang-format-diff by setting the\n' \ $'$CLANG_FORMAT_DIFF environment variable, for instance:\n' \ $'\n' \ $' CLANG_FORMAT_DIFF="python /.../clang-format-diff.py" \\\n' \ $' ' "$bash_source" fi readonly format_diff fi ############################ # Actually run the command # ############################ if [ "$whole_file" = true ]; then [ "$has_positionals" = true ] || \ error_exit "No files to reformat specified." [ "$staged" = false ] || \ error_exit "--staged/--cached only make sense when applying to a diff." read -r -a format_args <<< "$format" format_args+=("-style=file") [ "$in_place" = true ] && format_args+=("-i") "${format_args[@]}" "$@" else # Diff-only. if [ "$apply_to_staged" = true ]; then [ "$staged" = false ] || \ error_exit "You don't need --staged/--cached with --apply-to-staged." [ "$in_place" = false ] || \ error_exit "You don't need -i with --apply-to-staged." staged=true readonly patch_dest=$(mktemp) trap '{ rm -f "$patch_dest"; }' EXIT else readonly patch_dest=/dev/stdout fi declare git_args=(git diff -U0 --no-color) [ "$staged" = true ] && git_args+=("--staged") # $format_diff may contain a command ("python") and the script to excute, so we # need to split it. read -r -a format_diff_args <<< "$format_diff" [ "$in_place" = true ] && format_diff_args+=("-i") "${git_args[@]}" "$@" \ | "${format_diff_args[@]}" \ -p1 \ -style="$style" \ -iregex='^.*\.(c|cpp|cxx|cc|h|m|mm|js|java)$' \ > "$patch_dest" \ || exit 1 if [ "$apply_to_staged" = true ]; then if [ ! -s "$patch_dest" ]; then echo "No formatting changes to apply." exit 0 fi patch -p0 < "$patch_dest" || \ error_exit "Cannot apply patch to local files." git apply -p0 --cached < "$patch_dest" || \ error_exit "Cannot apply patch to git staged changes." fi fi camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/assets/000077500000000000000000000000001507144700500236735ustar00rootroot00000000000000camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/assets/logo.png000066400000000000000000000245141507144700500253470ustar00rootroot00000000000000PNG  IHDRxbKGD pHYs88q+8tIME0[ IDATxy|U-,db@v(. lc,XmˌLֶc2VT\PEeO/* aK;ZT~MC|WcU-%:Ij+@R#IY<$J!iuVKZ,iim&+$ t|>wD\Is$='8jrI$ n%MBɒnԝ ЬtiFK9 ? T]BI]Ԧْ~,iC]ɒ,)Z_@IS{TI7$:44S` @x]8``M@gD? I#Ty &3 i4:!:7x 2={&?P-p@ >Ԇ&KYSt} %e%uQ&k4D^6] 8r1TBRL t?ҠiH^ˏ&QR?C$.撊\A=H WHJ=H C쒔OMHy%xz6%$>Փԉ:V:yRJ IDzk4G;[/,J˭WH1j}< tT`%P r3+Zoo ߓuѩb ݔkmL<ifؒ@3X}9->G^µ" Zri@-k?@zjPzyJZ5H4j-{Э ˤ Emg =pN5>ΗϠ(yyy1(^]ku+Z^4ifL%e8@O^ bj@ތX_CNce@2+>cjHK Rҏ7ⰯB0#J߽hxm#]33}DkkGZj*:dut1B:[YMT¶@X3+mH G|XBUUۤ~-56j%;No<" Bo[4n>U=vO}#Hy* I[4n8[gr{Nj&1C<]xjx=_j zr =th_ /pz .l&?Hcyc|l5Xgu A@B@<I B@Ca, s[@ז@2/?ħ"qlԾ18Sn0b`ay HP?GaIg<ν|.Džr!AV1v]OEbްx3Y{HO,-ja4𔯾]hԥ[/T <tѩ,$=$<Ӡ,i`@{5Pn׭9t"AҴ1Nm@¬vX.-~ j$3+lFUY65YHʛ&559) zN KJӯfmM++#kꖗI ,Sf>ݫG.5g yഅ,$ul._ŨY^|?ۻ-ݞ*)syn^5}]p_8 䁅V3uԄnRAeIUGn??ocz7V?:U=wi6Be*NnQ=bt0u2Z_wPz84g|&0&}=jMHHi/~SS4Fݮ:Os?QJO@@r+lڻ3S]VzO/)@@*M6Ȓ.R]{7ɀ1Ѥ<Rˬ|+NSv͌h %.|Xa}c )VMFaxWO 'O''u=7sį?Lin_X =^̐DW~镵{FݣnoPF|Oe'$+U8{vQFu7icԹ9&4z:_[1$)35zcz$-?6]L@<:77z;I.Hz˷Z͔%Ǜߘ2}/d|73'f %oҹ܏ ^MG <6eh TĤgW5v'~U[?mC$Ti#O k_S{ܜ0q>*}var=ЇTb'VO K6F}c`՚V뿰eTZnDJ$LCpFuws[_1Î>8S8& Kw5RWQsk%E0mt=9ax/q ]6\`-I}ncǚ+bS+ b2׵};&^Ǘ0)O>n}w?al+!)u߷NOeiP+\I@žU\a ̊@oqW*shв2Kq+2jvҜP=cYJʬJʢShjy@#'"j}O÷>:ڪ VJmq8>cY[\+=A@zF,n3p@"赵V;Rxm.Z'd^4^^Xh<쯨 @@$Zͭ6/~`KL5$Wt|I~}RCIVgmBz1= 7`unLL_(5o;5rΓ |jvpA'ԬOVBxggoHaV7Gj#}j\e =(5Ȓ.cۃ:5sK,+P殷ڱv]/Itq~Hca==f$[ ..^Yl 89=@vFm_繕**PG]['?M`cC()^[G/ȬN{zml3"a@@]ظjѧ[vk^IF6w__ks/!@u9ڨ鹭we =^"kWƄ7+>jj qjMVJmgxh[>ܪEuTڵ* cT[\u##@@ sT~J^N-?-NW/Slӌ7KH0!Ԛҋ=gxe]{8Y(T'xw-wQZ^5?悩1mA@xCn8c8GYX m#y@. T&j1+Wv疕1!V?C#(҇t۾Ga)]ܙQIQ^u^rk*iWLrKr30440,{>eJn  ܮG0@?X&Ւ mhCYtv!GThԢuٛanڲ}5?#yn ߫+kkC"&Z(::Օy?!D g،ϣ6 ^_g>kĨI48GszKʮqKRзQcDPgϏadh нʐ&hiL@@ĔUJדUV9 $J~tB虽"PE5z6@#s\am \zyM[^Omaxڂh ?&UOh[pȦe">oo4g~)&H/I s_q::.)2zfq66RA)^X_~nje[v[@~ԥѰ"3iA@5͓em%ͺn]p=!^@@@@@@@5q{H[w[@\u##ӔA@* rZU,&a !}o$"}2E[,bw4k1hy2e;J>D*sI4-$wgioA?{"j7|}@@\L? ^Z"hf^(|/5\lC @@ep]Д̀&D@h#בzʡ ˰" Nj(f@MHI4 nir?n5fKjӘZ};{ϥoo4gGbqj̈́ޞFՁmT*;H]K EF)i\/ju!6[+~~m|@ Q'*;H-&RFF VzzË-*PFŧ}o$"}2E[,\juɐ@@+]@LKh TZ.zӴ8]Hj^ y\C ǯ^ Q4s)3xmep3 D/{|@@}. |jfMY (lJ @@]Љ6yxL#1\d?꾞n@.)2jӘ@P̀ϑn$a7 4P] GjӈZ};{ϥoo4g~?bfBoO#N@6X}Z*hXљ4 fJzy׋Z@]b    Ml\ nz   H>nQpk%E P#<q C       8 cvy1NIDAT@@@@@@RZ=+2(AZ;n@@@@@@@@Xk-e@@@@@@@ ntq C        ,+b@t|v!N2~~j8>;gRC4lRD5ّE p<85nώC pѡ}#@?;:48~RkRGwRzm[Ԍti%s@2Jݮѩ9'yߣgHu{i0F:='9wY;^'6u~ݮqjs %螤@0!-jo, *P\tRxym/Դc4ifL!Lٝ@@(4k4@~IM=b]ԱQB3w8_5;.R 6@ZEVjŶp z=5 ZQc@HGc_ 4 皍I}ivUn4xgELκRph&J3xwL|5Ё_Slj,\:JsI;]hԭQ|R&GzUznl.Z^_k"I4ϡ$ĬeV7>]}vܖVG=MMs2H1{vThk4  e+}$LWx[jhH {WGN#\{PwniPnXԁ݌nuOy܉\>ԥzxjť]#dU,>nA-HH᱾'ϒ܏5|іo)wyx m_w4z7C==G#5iiLO ;g- TZN]_iJ?OS{j̎D;-O4sպb·UetM_O)At@O7|fJ>Zӊ"cTT`tn݌zD7?)wkޭ;J 6[}j}RiTZ^uf_uXOl9RRfFT*y~@a@@@@@~(i%$R@Z)$-œ:VyVSjOb@ZYlKR> Hjrx'0WVsia$h&i'5 5T|Xlj@J}iө )m!ÖKN}H9+$8?wQRW @@~CH)hۏ IHIْn(RR.u K&i?A5 4MTj@$M=Ԗձx]҅IzC,  VH@=*4Bj @R[s.>U$ ;*@r1& T5 @&:0P\\n4EU ڷP[|CjCmx/9T1AD[qͽR5?P%$ .7D.4I(ْKz! '*LJ:OR>%T"i9S g'S^H* $5%9 $2IvH"iՒKZZ[1&ªIENDB`camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/assets/logo.svg000066400000000000000000000075721507144700500253670ustar00rootroot00000000000000 image/svg+xml A camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/camerascanner.apparmor000066400000000000000000000002121507144700500267310ustar00rootroot00000000000000{ "policy_groups": [ "content_exchange", "content_exchange_source" ], "policy_version": "@APPARMOR_POLICY@" } camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/camerascanner.desktop.in000066400000000000000000000002421507144700500271710ustar00rootroot00000000000000[Desktop Entry] _Name=Camera Scanner Exec=camerascanner %U Icon=assets/logo.svg Terminal=false Type=Application X-Lomiri-Touch=true X-Lomiri-Splash-Color=#FFFFFF camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/clickable.yaml000066400000000000000000000014231507144700500251660ustar00rootroot00000000000000clickable_minimum_required: 8.5.0 framework: ubuntu-touch-24.04-1.x builder: cmake dependencies_target: - libjpeg-dev - libpng-dev - libtiff-dev kill: camerascanner libraries: opencv: builder: cmake build_args: - -DCMAKE_BUILD_TYPE=Release - -DCMAKE_CXX_STANDARD=17 - -DCMAKE_CXX_FLAGS='-include cstdint' - -DBUILD_LIST=core,imgproc,highgui,imgcodecs - -DBUILD_EXAMPLES=OFF - -DBUILD_DOCS=OFF - -DBUILD_PERF_TESTS=OFF - -DBUILD_TESTS=OFF - -DBUILD_OPENCV_APPS=OFF - -DWITH_TBB=OFF - -DWITH_OPENMP=OFF - -DWITH_IPP=OFF - -DWITH_NVCUVID=OFF - -DWITH_CUDA=OFF - -DWITH_CSTRIPES=OFF - -DWITH_OPENCL=OFF - -DBUILD_SHARED_LIBS=OFF dependencies_target: - libjpeg-dev - libpng-dev - libtiff-dev camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/libs/000077500000000000000000000000001507144700500233225ustar00rootroot00000000000000camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/libs/opencv/000077500000000000000000000000001507144700500246145ustar00rootroot00000000000000camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/main.cpp000066400000000000000000000022261507144700500240230ustar00rootroot00000000000000/* * Copyright (C) 2020 Jonatan Hatakeyama Zeidler * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * ubuntu-calculator-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include #include #include int main(int argc, char *argv[]) { QGuiApplication *app = new QGuiApplication(argc, (char**)argv); app->setApplicationName("camerascanner.jonnius"); qDebug() << "Starting app from main.cpp"; QQuickView *view = new QQuickView(); view->setSource(QUrl(QStringLiteral("qml/Main.qml"))); view->setResizeMode(QQuickView::SizeRootObjectToView); view->show(); return app->exec(); } camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/manifest.json.in000066400000000000000000000007101507144700500254750ustar00rootroot00000000000000{ "name": "camerascanner.jonnius", "description": "Use your camera to scan documents", "architecture": "@CLICK_ARCH@", "title": "Camera Scanner", "hooks": { "camerascanner": { "apparmor": "camerascanner.apparmor", "desktop": "camerascanner.desktop" } }, "version": "0.5.1", "maintainer": "Jonatan Hatakeyama Zeidler ", "framework" : "@CLICK_FRAMEWORK@" } camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/plugins/000077500000000000000000000000001507144700500240525ustar00rootroot00000000000000camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/plugins/CMakeLists.txt000066400000000000000000000000421507144700500266060ustar00rootroot00000000000000add_subdirectory(ImageProcessing) camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/plugins/ImageProcessing/000077500000000000000000000000001507144700500271315ustar00rootroot00000000000000CMakeLists.txt000066400000000000000000000013371507144700500316160ustar00rootroot00000000000000camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/plugins/ImageProcessingset(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") set(PLUGIN "ImageProcessing") set(SRC plugin.cpp ImageProcessing.cpp Document.cpp DocumentStore.cpp ONSExtractor.cpp ExtractorConfig.cpp ) set(CMAKE_AUTOMOC ON) add_library(${PLUGIN} MODULE ${SRC}) set_target_properties(${PLUGIN} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PLUGIN}) qt5_use_modules(${PLUGIN} Qml Quick DBus Sql) find_package(OpenCV REQUIRED core imgproc highgui imgcodecs) include_directories(${OpenCV_INCLUDE_DIRS}) target_link_libraries(${PLUGIN} ${OpenCV_LIBS}) set(QT_IMPORTS_DIR "/lib/$ENV{ARCH_TRIPLET}") install(TARGETS ${PLUGIN} DESTINATION ${QT_IMPORTS_DIR}/${PLUGIN}/) install(FILES qmldir DESTINATION ${QT_IMPORTS_DIR}/${PLUGIN}/) camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/plugins/ImageProcessing/Debugger.h000066400000000000000000000010641507144700500310270ustar00rootroot00000000000000#ifndef DEBUGGER_H #define DEBUGGER_H struct DebugPipe { } debug; //~ #define NOQT #ifdef NOQT #include inline void print(std::string msg) { std::cout << msg << std::endl; } template DebugPipe &operator<<(DebugPipe &pipe, const T &obj) { std::cout << obj << std::endl; return pipe; } #else #include inline void print(std::string msg) { qDebug() << QString::fromStdString(msg); } template DebugPipe &operator<<(DebugPipe &pipe, const T &obj) { qDebug() << obj; return pipe; } #endif #endif camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/plugins/ImageProcessing/Document.cpp000066400000000000000000000016551507144700500314220ustar00rootroot00000000000000#include "Document.h" using namespace DocumentScanner; using namespace cv; Document::Document(const Mat &rawImg, const ONSExtractor &extractor) { rawImg.copyTo(m_rawImg); m_docImg = Mat(); m_docExtracted = extractor.extractDocument(m_rawImg, m_docImg); } Document::Document(const Mat &rawImg, const Mat &docImg, bool docExtracted /*= true*/) : m_docExtracted(docExtracted) { rawImg.copyTo(m_rawImg); if (docExtracted) docImg.copyTo(m_docImg); else m_docImg = Mat(); } void Document::reprocessImage(const ONSExtractor &extractor, const ONSExtractorConfig &conf) { m_docExtracted = extractor.extractDocument(m_rawImg, m_docImg, conf); } Mat Document::getRawImage() const { return m_rawImg; } Mat Document::getDocImage() const { return m_docExtracted ? m_docImg : m_rawImg; } bool Document::docExtracted() const { return m_docExtracted; } camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/plugins/ImageProcessing/Document.h000066400000000000000000000024331507144700500310620ustar00rootroot00000000000000#ifndef DOCUMENT_H #define DOCUMENT_H #include #include "ONSExtractor.h" namespace DocumentScanner { /** * The Document class holds the raw image of a document page, the * information whether a document has been sucessfully extracted and if * so, the processed document image. */ class Document { public: /** * Set the raw image and let the specified extractor produce the * document image. */ Document(const cv::Mat &rawImg, const ONSExtractor &extractor); /** * Set the raw image and the processed document image. If * docExtracted is false, docImg is ignored. */ Document(const cv::Mat &rawImg, const cv::Mat &docImg, bool docExtracted = true); /** * Reprocesses the image with the given configuration. */ void reprocessImage(const ONSExtractor &extractor, const ONSExtractorConfig &conf); /** * Returns the raw image. */ cv::Mat getRawImage() const; /** * Returns the processed document image. If the document * extraction has failed, the raw image is returned instead. */ cv::Mat getDocImage() const; bool docExtracted() const; private: cv::Mat m_rawImg; cv::Mat m_docImg; bool m_docExtracted; }; } // namespace DocumentScanner #endif DocumentStore.cpp000066400000000000000000000224551507144700500323610ustar00rootroot00000000000000camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/plugins/ImageProcessing#include "DocumentStore.h" #include #include #include #include #include #include #include #include #include "ONSExtractor.h" using namespace DocumentScanner; using namespace cv; inline static QImage convertMat2QImage(const Mat &img) { if (!img.data) { qDebug() << "Error: Tried to convert an empty Mat to QImage!"; return QImage(); // TODO throw exception } Mat rgb(img.size(), CV_8UC3); switch (img.type()) { case CV_8UC1: { cvtColor(img, rgb, COLOR_GRAY2RGB); break; } case CV_8UC3: { cvtColor(img, rgb, COLOR_BGR2RGB); break; } default: { qDebug() << "Error: Tried to convert an Mat other than CV_8UC3 to QImage!"; return QImage(); // TODO throw exception } } return QImage((uchar *)rgb.data, rgb.cols, rgb.rows, rgb.step, QImage::Format_RGB888) .copy(); } inline static QString getTimeStampNow() { return QString::number( std::chrono::duration_cast( std::chrono::system_clock::now().time_since_epoch()) .count()); } inline static QString joinPath(QString d1, QString d2) { return QFileInfo(QDir(d1), d2).absoluteFilePath(); } inline static QString getDocumentBaseDir() { QString path = joinPath( QStandardPaths::writableLocation(QStandardPaths::CacheLocation), "docs"); QDir doc(path); if (!doc.exists() && !doc.mkpath(".")) { qDebug() << "Failed to create document base directory " << path; } return path; } inline static QString getDocumentDir(const QString &id) { QString path = joinPath(getDocumentBaseDir(), id); QDir doc(path); if (!doc.exists() && !doc.mkpath(".")) { qDebug() << "Failed to create document directory " << path; } return path; } inline static QStringList getIDsFromCache() { QDir base(getDocumentBaseDir()); base.setFilter(QDir::Dirs | QDir::NoDotAndDotDot); return base.entryList(); } inline static QString getRawImagePath(const QString &id) { return joinPath(getDocumentDir(id), "raw.jpg"); } inline static QString getDocImagePath(const QString &id) { return joinPath(getDocumentDir(id), "doc.jpg"); } inline static QString URL2Path(const QString &URL) { if (URL.startsWith("file://")) { return QUrl(URL).toLocalFile(); } return URL; } inline static QString path2URL(const QString &path) { return QUrl::fromLocalFile(path).toString(); } inline static bool fileExists(QString path) { QFileInfo check_file(URL2Path(path)); return check_file.exists() && check_file.isFile(); } inline static bool loadImage(const QString &imageURL, Mat &img) { QString imagePath = URL2Path(imageURL); img = imread(imagePath.toStdString()); return img.data; } inline static Document loadDocument(const QString &imageURL, const QString &docURL) { Mat img, doc; bool imgFound = loadImage(imageURL, img); bool docFound = loadImage(docURL, doc); if (!imgFound) { qDebug() << "raw image does not exist or is invalid: " << imageURL; // TODO throw exception } if (!docFound) { //~ qDebug() << "No cached extracted document " << docURL; } return Document(img, doc, docFound); } inline static Document createDocument(const QString &imageURL, const ONSExtractor &extractor) { Mat img; bool imgFound = loadImage(imageURL, img); if (!imgFound) { qDebug() << "raw image does not exist or is invalid: " << imageURL; // TODO throw exception } return Document(img, extractor); } QString DocumentStore::addDocument(const QString &url, QString id) { if (!fileExists(url)) { qDebug() << "Document to add does not exist! " << url; return QString(); } bool newDoc = id.isEmpty(); if (newDoc) id = getTimeStampNow(); if (!m_documents.count(id)) { m_documents.insert(std::pair( id, newDoc ? createDocument(url, extractor) : loadDocument(url, getDocImagePath(id)))); return id; } else { qDebug() << "Incredible! A document with the exact same timestamp already " "existed! We met a document from the future with id " << id; return QString(); } } void DocumentStore::reprocessDocument(const QString &id, const ONSExtractorConfig &conf) { if (m_documents.count(id)) { m_documents.at(id).reprocessImage(extractor, conf); cacheDocument(id); } else { qDebug() << "Tried to access document with invalid id " << id; } } void DocumentStore::cacheDocument(const QString &id) const { if (m_documents.count(id)) { const Document &d = m_documents.at(id); QString rawPath = getRawImagePath(id); QString docPath = getDocImagePath(id); QFile(docPath).remove(); try { if (!QFile(rawPath).exists()) imwrite(rawPath.toStdString(), d.getRawImage()); if (d.docExtracted()) imwrite(docPath.toStdString(), d.getDocImage()); } catch (cv::Exception &e) { qDebug() << "Exception caching image with id " << id << "\n" << e.what(); } } else { qDebug() << "Tried to access document with invalid id " << id; } } void DocumentStore::removeDocument(const QString &id) { if (m_documents.count(id)) { if (!QDir(getDocumentDir(id)).removeRecursively()) { qDebug() << "Zombie alert! Failed to remove document dir from cache: " << id; } m_documents.erase(id); } else { qDebug() << "Tried to access document with invalid id " << id; } } QStringList DocumentStore::getIDs() const { QStringList ids; ids.reserve(m_documents.size()); for (auto const &idmap : m_documents) ids.push_back(idmap.first); return ids; } QStringList DocumentStore::restoreCache() { qDebug() << "Restoring cache"; QStringList ids = getIDsFromCache(); for (QString id : ids) addDocument(getRawImagePath(id), id); return ids; } QImage DocumentStore::requestImage(const QString &id, QSize *size, const QSize &requestedSize) { QImage img; //~ qDebug() << "image requested with id " << id; if (m_documents.count(id)) { img = convertMat2QImage(m_documents.at(id).getDocImage()); QSize sizeOrig = img.size(); if (size) *size = sizeOrig; QSize newSize(requestedSize.width() > 0 ? requestedSize.width() : sizeOrig.width(), requestedSize.height() > 0 ? requestedSize.height() : sizeOrig.height()); img = img.scaled(newSize, Qt::KeepAspectRatio); } else { qDebug() << "Tried to access document with invalid id " << id; if (size) *size = QSize(0, 0); } return img; } QString DocumentStore::getImageURL(const QString &id) const { if (m_documents.count(id)) { const Document &d = m_documents.at(id); QString imagePath = d.docExtracted() ? getDocImagePath(id) : getRawImagePath(id); return path2URL(imagePath); } else { qDebug() << "Tried to access document with invalid id " << id; return ""; } } bool DocumentStore::containsDocuments(const QStringList &ids) const { for (QString id : ids) if (m_documents.at(id).docExtracted()) return true; return false; } QString DocumentStore::exportPdf(const QStringList &ids) const { //if (!containsDocuments(ids)) { // qDebug() << "Tried to export empty PDF. Aborting..."; // return QString(); //} QDateTime current = QDateTime::currentDateTime(); qDebug() << "Time: " << current; QString path = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/" + QDateTime::currentDateTime().toString(Qt::ISODate) + "_scan.pdf"; qDebug() << "Writing pdf to " << path; // TODO make divider configurable // reduces the default resolution of 1200 DPI by the divider. double resDivider = 4.0; QPdfWriter pdfwriter(path); QPainter painter(&pdfwriter); pdfwriter.setPageSize(QPagedPaintDevice::A4); painter.scale(resDivider, resDivider); bool firstPage = true; for (QString id : ids) { const Document &d = m_documents.at(id); //if (!d.docExtracted()) // continue; if (firstPage) firstPage = false; else pdfwriter.newPage(); QSize sizeA4 = pdfwriter.pageLayout().pageSize().sizePixels( pdfwriter.resolution() / resDivider); QImage imageA4 = convertMat2QImage(d.getDocImage()); imageA4 = imageA4.scaled(sizeA4); painter.drawImage(0, 0, imageA4); } if (firstPage) qDebug() << "Saved an empty PDF"; painter.end(); return path; } bool DocumentStore::isExtractedDoc(const QString &id) const { if (m_documents.count(id)) { return m_documents.at(id).docExtracted(); } else { qDebug() << "Tried to access document with invalid id " << id; } } DocumentStore.h000066400000000000000000000027761507144700500320320ustar00rootroot00000000000000camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/plugins/ImageProcessing#ifndef DOCUMENTSTORE_H #define DOCUMENTSTORE_H #include #include "Document.h" #include "ONSExtractor.h" namespace DocumentScanner { class DocumentStore : public QQuickImageProvider { private: DocumentStore() : QQuickImageProvider(QQuickImageProvider::Image) { /* empty */ } DocumentStore(const DocumentStore &) = delete; DocumentStore &operator=(const DocumentStore &) = delete; DocumentStore(DocumentStore &&) = delete; DocumentStore &operator=(DocumentStore &&) = delete; public: static DocumentStore *instance() { static DocumentStore *_instance = nullptr; if (_instance == nullptr) { _instance = new DocumentStore(); } return _instance; } QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize) override; QString addDocument(const QString &url, QString id = ""); void reprocessDocument(const QString &id, const ONSExtractorConfig &conf); void cacheDocument(const QString &id) const; void removeDocument(const QString &id); QStringList getIDs() const; QStringList restoreCache(); QString exportPdf(const QStringList &ids) const; bool isExtractedDoc(const QString &id) const; QString getImageURL(const QString &id) const; private: bool containsDocuments(const QStringList &ids) const; private: std::map m_documents; ONSExtractor extractor; }; } // namespace DocumentScanner #endif ExtractorConfig.cpp000066400000000000000000000101551507144700500326610ustar00rootroot00000000000000camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/plugins/ImageProcessing#include "ExtractorConfig.h" using namespace DocumentScanner; ExtractorConfig::ExtractorConfig(QObject *parent) : QObject(parent) { m_db = new QSqlDatabase(); createDataDir(); } ExtractorConfig::~ExtractorConfig() { closeDB(); } void ExtractorConfig::createDataDir() { QString pathDatabase = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + QDir::separator() + "database"; QDir dir; if( !dir.mkpath(pathDatabase)) { qDebug() << "Error creating the database directory"; } else { createDB(pathDatabase); } } void ExtractorConfig::createDB(QString path) { QString url = path + "/ImageProcessingSettings.sqlite"; *m_db = QSqlDatabase::addDatabase("QSQLITE"); m_db->setDatabaseName(url); if (!m_db->open()) qDebug() << "Error opening DB: " << m_db->lastError().text(); createTableSettings(); } void ExtractorConfig::createTableSettings() { QSqlQuery query(*m_db); if( !query.exec("create table if not exists settings " "(id varchar(20), " "filterMode integer, " "colorMode integer, " "colorThr integer, " "colorGain real, " "colorBias real)") ) { qDebug() << "exec :" << query.lastError(); } } void ExtractorConfig::addImageConfig(const QString& id) { //Store default settings for new image ONSExtractorConfig conf; qDebug() << "add new image " << id << " with following values:" << conf.colorMode << conf.filterMode << conf.colorThr << conf.colorGain << conf.colorBias; QSqlQuery query(*m_db); //Store settings query.prepare("INSERT INTO settings (id, filterMode, colorMode, colorThr, colorGain, colorBias) " "VALUES (:id, :filterMode, :colorMode, :colorThr, :colorGain, :colorBias)"); query.bindValue(":id", id); query.bindValue(":filterMode", QVariant(conf.filterMode).toInt()); query.bindValue(":colorMode", QVariant(conf.colorMode).toInt()); query.bindValue(":colorThr", conf.colorThr); query.bindValue(":colorGain", conf.colorGain); query.bindValue(":colorBias", conf.colorBias); if( !query.exec()) qDebug() << "exec :" << query.lastError(); } void ExtractorConfig::editImageConfig(const QString& id, const ONSExtractorConfig& conf) { qDebug() << "edit image " << id << " with following values:" << conf.colorMode << conf.filterMode << conf.colorThr << conf.colorGain << conf.colorBias; QSqlQuery query(*m_db); query.prepare("UPDATE settings SET filterMode = :filterMode, colorMode = :colorMode, colorThr = :colorThr, colorGain = :colorGain, colorBias = :colorBias WHERE id = :id"); query.bindValue(":id", id); query.bindValue(":filterMode", conf.filterMode); query.bindValue(":colorMode", conf.colorMode); query.bindValue(":colorThr", conf.colorThr); query.bindValue(":colorGain", conf.colorGain); query.bindValue(":colorBias", conf.colorBias); if (!query.exec()) qDebug() << "exec :" << query.lastError(); } ONSExtractorConfig ExtractorConfig::loadImageConfig(const QString& id) { ONSExtractorConfig conf; QSqlQuery query(*m_db); query.prepare("SELECT * FROM settings WHERE id = (:id)"); query.bindValue(":id", id); if (!query.exec()) { qDebug() << "exec :" << query.lastError(); return conf; } else { query.first(); conf.filterMode = QVariant(query.value(1).toInt()).toBool(); conf.colorMode = QVariant(query.value(2).toString()).toBool(); conf.colorThr = query.value(3).toInt(); conf.colorGain = query.value(4).toReal(); conf.colorBias = query.value(5).toReal(); qDebug() << "load image settings" << id << " with following values:" << conf.colorMode << conf.filterMode << conf.colorThr << conf.colorGain << conf.colorBias; return conf; } } void ExtractorConfig::removeImageConfig(const QString& id) { QSqlQuery query(*m_db); query.prepare("DELETE FROM settings WHERE id = :id"); query.bindValue(":id", id); if (!query.exec()) qDebug() << "exec :" << query.lastError(); } void ExtractorConfig::closeDB() { qDebug() << "Close database"; m_db->close(); } ExtractorConfig.h000066400000000000000000000015221507144700500323240ustar00rootroot00000000000000camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/plugins/ImageProcessing#ifndef EXTRACTORCONFIG_H #define EXTRACTORCONFIG_H #include #include #include #include #include #include #include #include #include "ONSExtractor.h" class QSqlDatabase; class QSqlQuery; namespace DocumentScanner { class ExtractorConfig : public QObject { Q_OBJECT public: ExtractorConfig(QObject *parent = 0); ~ExtractorConfig(); void addImageConfig(const QString &id); void removeImageConfig(const QString &id); void editImageConfig(const QString &id, const ONSExtractorConfig &conf); ONSExtractorConfig loadImageConfig(const QString &id); signals: private: void createDataDir(void); void createDB(QString path); void createTableSettings(void); void closeDB(void); QSqlDatabase *m_db; }; } // namespace DocumentScanner #endif ImageProcessing.cpp000066400000000000000000000103501507144700500326340ustar00rootroot00000000000000camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/plugins/ImageProcessing#include #include #include #include #include #include #include #include #include #define _(value) gettext(value) #include "ImageProcessing.h" using namespace DocumentScanner; const QString GETTEXT_DOMAIN = "camerascanner.jonnius"; ImageProcessing::ImageProcessing() : m_store(*DocumentStore::instance()) { textdomain(GETTEXT_DOMAIN.toStdString().c_str()); /* empty */ // TODO define default params // TODO load params from config } void ImageProcessing::restoreCache() { bool any = false; for (QString id : m_store.restoreCache()) { emit imageAdded(id); any = true; } if (any) emit userInfo(_("Session restored")); validateIsAnyFlags(); } void ImageProcessing::addImage(const QString &imageURL) { QString id = m_store.addDocument(imageURL); m_store.cacheDocument(id); emit imageAdded(id); validateIsAnyFlags(); m_extractorConfig.addImageConfig(id); } void ImageProcessing::reprocessImage(const QString &id, bool colorMode, bool filterMode, int colorThr, float colorGain, float colorBias) { qDebug() << "reprocess image " << id << " with following values:" << colorMode << filterMode << colorThr << colorGain << colorBias; ONSExtractorConfig conf; conf.colorMode = colorMode; conf.filterMode = filterMode; conf.colorThr = colorThr * 100.0 + 150.0; conf.colorGain = colorGain; conf.colorBias = colorBias * 100.0; m_extractorConfig.editImageConfig(id, conf); m_store.reprocessDocument(id, conf); validateIsAnyFlags(); emit imageUpdated(id); } void ImageProcessing::removeImage(const QString &id) { m_store.removeDocument(id); emit imageRemoved(id); m_extractorConfig.removeImageConfig(id); validateIsAnyFlags(); } void ImageProcessing::removeAll() { for (QString id : m_store.getIDs()) removeImage(id); validateIsAnyFlags(); } QString ImageProcessing::exportAsPdf(const QString &id) const { QStringList ids = { id }; return m_store.exportPdf(ids); } QString ImageProcessing::exportAllAsPdf() const { return m_store.exportPdf(m_store.getIDs()); } QString ImageProcessing::exportAsImage(const QString &id) const { return m_store.getImageURL(id); } QStringList ImageProcessing::exportAllAsImages() const { QStringList ids = m_store.getIDs(); QStringList urls; for (QString id : ids) { urls << m_store.getImageURL(id); } return urls; } bool ImageProcessing::isDocument(const QString &id) const { return m_store.isExtractedDoc(id); } bool ImageProcessing::isAnyImage() const { return m_isAnyImage; } bool ImageProcessing::isAnyDocument() const { return m_isAnyDocument; } void ImageProcessing::validateIsAnyFlags() { bool isAnyImage = false; bool isAnyDocument = false; QStringList ids = m_store.getIDs(); for (QString id : ids) { isAnyImage = true; if (isDocument(id)) { isAnyDocument = true; } } if (isAnyImage != m_isAnyImage) { m_isAnyImage = isAnyImage; emit isAnyImageChanged(); } if (isAnyDocument != m_isAnyDocument) { m_isAnyDocument = isAnyDocument; emit isAnyDocChanged(); } } void ImageProcessing::loadSingleImageSettings(const QString &id) { ONSExtractorConfig conf; conf = m_extractorConfig.loadImageConfig(id); qDebug() << "load image ImageProcessing" << id << " with following values:" << conf.colorMode << conf.filterMode << conf.colorThr << conf.colorGain << conf.colorBias; m_colorMode = conf.colorMode; emit colorModeChanged(); m_filterMode = conf.filterMode; emit filterModeChanged(); m_colorThr = (conf.colorThr - 150.0) / 100.0; emit colorThrChanged(); m_colorGain = conf.colorGain; emit colorGainChanged(); m_colorBias = conf.colorBias / 100.0; emit colorBiasChanged(); } bool ImageProcessing::colorMode() const { return m_colorMode; } bool ImageProcessing::filterMode() const { return m_filterMode; } float ImageProcessing::colorThr() const { return m_colorThr; } float ImageProcessing::colorGain() const { return m_colorGain; } float ImageProcessing::colorBias() const { return m_colorBias; } ImageProcessing.h000066400000000000000000000066461507144700500323160ustar00rootroot00000000000000camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/plugins/ImageProcessing#ifndef IMAGEPROCESSING_H #define IMAGEPROCESSING_H #include #include #include "DocumentStore.h" #include "ExtractorConfig.h" /** * Qt Object that acts as an interface to the Image Processing. */ class ImageProcessing : public QObject { Q_OBJECT Q_PROPERTY(bool isAnyImage READ isAnyImage NOTIFY isAnyImageChanged) Q_PROPERTY(bool isAnyDocument READ isAnyDocument NOTIFY isAnyDocChanged) Q_PROPERTY(bool colorMode READ colorMode NOTIFY colorModeChanged) Q_PROPERTY(bool filterMode READ filterMode NOTIFY filterModeChanged) Q_PROPERTY(float colorThr READ colorThr NOTIFY colorThrChanged) Q_PROPERTY(float colorGain READ colorGain NOTIFY colorGainChanged) Q_PROPERTY(float colorBias READ colorBias NOTIFY colorBiasChanged) public: ImageProcessing(); ~ImageProcessing() = default; /** Load cached images from disk and add them */ Q_INVOKABLE void restoreCache(); /** Add an image and cache it on disk */ Q_INVOKABLE void addImage(const QString &imageURL); /** Reprocess a existing image on disk */ Q_INVOKABLE void reprocessImage(const QString &id, bool colorMode, bool filterMode, int colorThr, float colorGain, float colorBias); /** Remove the specified image and delete it from cache */ Q_INVOKABLE void removeImage(const QString &id); /** Remove all images and clear the cache */ Q_INVOKABLE void removeAll(); /** Export one image as PDF and return URL to PDF file */ Q_INVOKABLE QString exportAsPdf(const QString &id) const; /** Export all images as PDF and return URL to PDF file */ Q_INVOKABLE QString exportAllAsPdf() const; /** Export one image and return URL to image file */ Q_INVOKABLE QString exportAsImage(const QString &id) const; /** Export all images and return list of URLs to image files */ Q_INVOKABLE QStringList exportAllAsImages() const; /** Load image settings for selected image */ Q_INVOKABLE void loadSingleImageSettings(const QString &id); /** Return true if a document has been found in the specified image */ Q_INVOKABLE bool isDocument(const QString &id) const; /** Return true if there is at least one image in the current session */ bool isAnyImage() const; /** Return true if a processed document has been found in the current session */ bool isAnyDocument() const; /** Return true if filter mode is set for the current image */ bool isFilterModeOn() const; /** Return true if color mode is set for the current image */ bool isColorModeOn() const; /** Image settings */ bool colorMode() const; bool filterMode() const; float colorThr() const; float colorGain() const; float colorBias() const; private: void validateIsAnyFlags(); signals: void isAnyImageChanged(); void isAnyDocChanged(); void imageAdded(const QString &id); void imageUpdated(const QString &id); void imageRemoved(const QString &id); void userInfo(const QString msg); void colorModeChanged(); void filterModeChanged(); void colorThrChanged(); void colorGainChanged(); void colorBiasChanged(); private: DocumentScanner::DocumentStore &m_store; DocumentScanner::ExtractorConfig m_extractorConfig; std::map m_params; bool m_isAnyDocument = false; bool m_isAnyImage = false; bool m_colorMode; bool m_filterMode; float m_colorThr; float m_colorGain; float m_colorBias; }; #endif ONSExtractor.cpp000066400000000000000000000206161507144700500321160ustar00rootroot00000000000000camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/plugins/ImageProcessing#include "ONSExtractor.h" #include #include #include #include #include #include #include "Debugger.h" using namespace cv; using namespace std; using namespace DocumentScanner; typedef vector Border; /** A Quad is meant to be a border consisting of exactly 4 points */ typedef Border Quad; const int PROCESSINGHEIGHT = 500; struct BorderSort { bool operator()(const Border &a, const Border &b) const { return contourArea(a) < contourArea(b); } }; struct sumComparator { bool operator()(const Point &a, const Point &b) { return (a.y + a.x) < (b.y + b.x); } }; struct diffComparator { bool operator()(const Point &a, const Point &b) { return (a.y - a.x) < (b.y - b.x); } }; inline vector findCandidates(const Mat &src) { // Scale to processing height float ratio = 1.0 * src.size().height / PROCESSINGHEIGHT; int height = PROCESSINGHEIGHT; int width = static_cast(src.size().width / ratio); Size size(width, height); Mat grayImage(size, CV_8UC4); Mat cannedImage(size, CV_8UC4); Mat resizedImage(size, CV_8UC1); resize(src, resizedImage, size); cvtColor(resizedImage, grayImage, COLOR_RGBA2GRAY, 4); GaussianBlur(grayImage, grayImage, Size(5, 5), 0.0, 0.0); Canny(grayImage, cannedImage, 75, 200); vector candidates; Mat hierarchy; findContours(cannedImage, candidates, hierarchy, RETR_LIST, CHAIN_APPROX_SIMPLE); hierarchy.release(); // TODO Test, if sorting is inverted! sort(candidates.begin(), candidates.end(), BorderSort()); resizedImage.release(); grayImage.release(); cannedImage.release(); //~ debug << candidates.size() << " contours found."; return candidates; } inline Quad find4Corners(const Quad &src) { Quad result(4); // top-left corner = minimal sum result[0] = *min_element(src.begin(), src.end(), sumComparator()); // bottom-right corner = maximal sum result[2] = *max_element(src.begin(), src.end(), sumComparator()); // top-right corner = minimal diference result[1] = *min_element(src.begin(), src.end(), diffComparator()); // bottom-left corner = maximal diference result[3] = *max_element(src.begin(), src.end(), diffComparator()); return result; } inline bool findQuad(const vector &candidates, const Size &srcSize, Quad &quad) { // Scale to processing height float ratio = 1.0 * srcSize.height / PROCESSINGHEIGHT; int height = PROCESSINGHEIGHT; int width = static_cast(srcSize.width / ratio); Size size(width, height); for (size_t ic = 0; ic < candidates.size(); ic++) { // Convert contour to float vector c2f; Mat(candidates[ic]).copyTo(c2f); // Get contour length float peri = arcLength(c2f, true); vector approx; // Approx. polygone approxPolyDP(c2f, approx, 0.02 * peri, true); // Convert to int vector points; Mat(approx).copyTo(points); // Minimum 4 points required if (points.size() < 4) continue; // Reduce to 4 corner points Quad cornerPoints = find4Corners(points); // Area of final contour const double cornersArea = contourArea(cornerPoints); // Check size of contour if (cornersArea / width / height < 0.25) continue; // Bounding boxes of whole contour and corner points only Rect boxPolygone = boundingRect(points); Rect boxCorners = boundingRect(cornerPoints); const auto polygoneBoxArea = boxPolygone.width * boxPolygone.height; const auto cornersBoxArea = boxCorners.width * boxCorners.height; // Check if contour is tending to be a axes parallel rectangular if (cornersArea / cornersBoxArea < 0.5) continue; // Check if contour are has changed by reducing to corner points if (cornersBoxArea / polygoneBoxArea < 0.8) continue; // All checks passed quad = cornerPoints; return true; } return false; } inline void rectify(const Quad &pts, const Mat &src, Mat &dst) { assert(pts.size() == 4); // Scale to the processing height float ratio = 1.0 * src.size().height / PROCESSINGHEIGHT; //~ debug << "Ratio: " << ratio; Point tl = pts[0]; Point tr = pts[1]; Point br = pts[2]; Point bl = pts[3]; float widthA = sqrt(pow(br.x - bl.x, 2) + pow(br.y - bl.y, 2)); float widthB = sqrt(pow(tr.x - tl.x, 2) + pow(tr.y - tl.y, 2)); float dw = max(widthA, widthB) * ratio; int maxWidth = static_cast(dw); float heightA = sqrt(pow(tr.x - br.x, 2) + pow(tr.y - br.y, 2)); float heightB = sqrt(pow(tl.x - bl.x, 2) + pow(tl.y - bl.y, 2)); float dh = max(heightA, heightB) * ratio; int maxHeight = static_cast(dh); dst = Mat(maxHeight, maxWidth, CV_8UC4); float src_data[] = { tl.x * ratio, tl.y * ratio, tr.x * ratio, tr.y * ratio, br.x * ratio, br.y * ratio, bl.x * ratio, bl.y * ratio }; float dst_data[] = { 0.0, 0.0, dw, 0.0, dw, dh, 0.0, dh }; Mat src_mat(4, 1, CV_32FC2, &src_data); Mat dst_mat(4, 1, CV_32FC2, &dst_data); Mat m = getPerspectiveTransform(src_mat, dst_mat); warpPerspective(src, dst, m, dst.size()); } /** * When a pixel have any of its three elements above the threshold * value and the average of the three values are less than 80% of the * higher one, brings all three values to the max possible keeping * the relation between them, any absolute white keeps the value, all * others go to absolute black. * * src must be a 3 channel image with 8 bits per channel * * @param src * @param threshold */ inline void colorThresh(const int &threshold, Mat &img) { assert(img.type() == CV_8UC3); for (int i = 0; i < img.rows; i++) { for (int j = 0; j < img.cols; j++) { float maxC = max(max(img.at(i, j)[0], img.at(i, j)[1]), img.at(i, j)[2]); float meanC = static_cast(img.at(i, j)[0] + img.at(i, j)[1] + img.at(i, j)[2]) / 3.0; if (img.at(i, j) != Vec3b(255, 255, 255)) { if (maxC > threshold && meanC < maxC * 0.8) { // Scale pixel so that the maximal color value becomes 255 img.at(i, j) *= 255.0 / maxC; } else { // Set pixel to black img.at(i, j) = Vec3b(0, 0, 0); } } } } } inline void enhanceDocument(Mat &img, const ONSExtractorConfig &conf) { if (conf.colorMode && conf.filterMode) { img.convertTo(img, -1, conf.colorGain, conf.colorBias); Mat mask(img.size(), CV_8UC1); cvtColor(img, mask, COLOR_RGBA2GRAY); Mat copy(img.size(), CV_8UC3); img.copyTo(copy); adaptiveThreshold(mask, mask, 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY_INV, 15, 5); img.setTo(Scalar(255, 255, 255)); copy.copyTo(img, mask); copy.release(); mask.release(); // special color threshold algorithm colorThresh(conf.colorThr, img); } else if (!conf.colorMode) { cvtColor(img, img, COLOR_RGBA2GRAY); if (conf.filterMode) { adaptiveThreshold(img, img, 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY, 15, 5); } } } bool ONSExtractor::extractDocument(const Mat &rawImg, Mat &docImg, const ONSExtractorConfig conf) const { vector candidates; Quad quad; debug << "Starting document extraction..."; // Find candidates candidates = findCandidates(rawImg); //~ debug << " " << candidates.size() << " candidates found."; // Find quad if (!findQuad(candidates, rawImg.size(), quad)) { debug << " Didn't find a proper quad between the " << candidates.size() << " candidates."; return false; } debug << " Document detected. Processing image..."; // Process image rectify(quad, rawImg, docImg); enhanceDocument(docImg, conf); debug << " Document extraction finished."; return true; } ONSExtractor.h000066400000000000000000000013351507144700500315600ustar00rootroot00000000000000camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/plugins/ImageProcessing#ifndef ONSEXTRACTOR_H #define ONSEXTRACTOR_H #include namespace DocumentScanner { class ONSExtractorConfig { public: bool colorMode = false; bool filterMode = true; int colorThr = 205; float colorGain = 1.5; // contrast float colorBias = 0; // brightness }; /** * The OpenNoteScanner extractor is a reimplementation of the document * extraction algorithm used in the app OpenNoteScanner by * Claudemir Todo Bom (https://github.com/ctodobom/OpenNoteScanner). */ class ONSExtractor { public: bool extractDocument(const cv::Mat &rawImg, cv::Mat &docImg, const ONSExtractorConfig conf = ONSExtractorConfig()) const; }; } // namespace DocumentScanner #endif camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/plugins/ImageProcessing/Test/000077500000000000000000000000001507144700500300505ustar00rootroot00000000000000CMakeLists.txt000066400000000000000000000005211507144700500325270ustar00rootroot00000000000000camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/plugins/ImageProcessing/Testcmake_minimum_required(VERSION 3.1.0) project(CameraScannerTest) add_executable(scannertest Test.cpp ../ONSExtractor.cpp) set(OpenCV_DIR "../../../build/opencv/x86_64-linux-gnu") find_package(OpenCV REQUIRED core imgproc highgui imgcodecs) include_directories(${OpenCV_INCLUDE_DIRS}) target_link_libraries(scannertest ${OpenCV_LIBS}) camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/plugins/ImageProcessing/Test/Test.cpp000066400000000000000000000011361507144700500314740ustar00rootroot00000000000000#define NOQT #include "../ONSExtractor.h" #include using namespace cv; using namespace std; using namespace DocumentScanner; int main() { Mat image = imread("test.jpg"); if(! image.data ) // Check for invalid input { cout << "Could not open or find the image" << std::endl ; return -1; } Mat doc; ONSExtractor extractor; if (!extractor.extractDocument(image, doc)) { cout << "Could not detect document" << std::endl ; return -1; } imwrite( "testouput.jpg", doc ); return 0; } camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/plugins/ImageProcessing/plugin.cpp000066400000000000000000000012271507144700500311350ustar00rootroot00000000000000#include #include #include "ImageProcessing.h" #include "plugin.h" using namespace DocumentScanner; void ImageProcessingPlugin::registerTypes(const char *uri) { //@uri ImageProcessing qmlRegisterSingletonType( uri, 1, 0, "ImageProcessing", [](QQmlEngine *, QJSEngine *) -> QObject * { return new ImageProcessing(); }); } void ImageProcessingPlugin::initializeEngine(QQmlEngine *engine, const char *uri) { engine->addImageProvider(QLatin1String("documents"), DocumentStore::instance()); } camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/plugins/ImageProcessing/plugin.h000066400000000000000000000007151507144700500306030ustar00rootroot00000000000000#ifndef IMAGEPROCESSINGPLUGIN_H #define IMAGEPROCESSINGPLUGIN_H #include "DocumentStore.h" #include /** * QML Plugin. Auto-generated by clickable. */ class ImageProcessingPlugin : public QQmlExtensionPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") public: void registerTypes(const char *uri) override; void initializeEngine(QQmlEngine *engine, const char *uri) override; }; #endif camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/plugins/ImageProcessing/qmldir000066400000000000000000000000561507144700500303450ustar00rootroot00000000000000module ImageProcessing plugin ImageProcessing camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/po/000077500000000000000000000000001507144700500230075ustar00rootroot00000000000000camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/po/CMakeLists.txt000066400000000000000000000025121507144700500255470ustar00rootroot00000000000000include(FindGettext) find_program(GETTEXT_XGETTEXT_EXECUTABLE xgettext) set(DOMAIN ${FULL_PROJECT_NAME}) set(POT_FILE ${DOMAIN}.pot) file(GLOB PO_FILES *.po) # Creates the .pot file containing the translations template add_custom_target(${POT_FILE} ALL COMMENT "Generating translation template" COMMAND ${INTLTOOL_EXTRACT} --update --type=gettext/ini --srcdir=${CMAKE_SOURCE_DIR} ${DESKTOP_FILE_NAME}.in COMMAND ${GETTEXT_XGETTEXT_EXECUTABLE} -o ${POT_FILE} -D ${CMAKE_CURRENT_SOURCE_DIR} -D ${CMAKE_CURRENT_BINARY_DIR} --from-code=UTF-8 --c++ --qt --language=javascript --add-comments=TRANSLATORS --keyword=tr --keyword=tr:1,2 --keyword=N_ --keyword=_ --package-name='${DOMAIN}' --sort-by-file ${I18N_SRC_FILES} COMMAND ${CMAKE_COMMAND} -E copy ${POT_FILE} ${CMAKE_CURRENT_SOURCE_DIR}) # Builds the binary translations catalog for each language # it finds source translations (*.po) for foreach(PO_FILE ${PO_FILES}) get_filename_component(LANG ${PO_FILE} NAME_WE) gettext_process_po_files(${LANG} ALL PO_FILES ${PO_FILE}) set(INSTALL_DIR ${CMAKE_INSTALL_LOCALEDIR}/share/locale/${LANG}/LC_MESSAGES) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${LANG}.gmo DESTINATION ${INSTALL_DIR} RENAME ${DOMAIN}.mo) endforeach(PO_FILE) camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/po/camerascanner.jonnius.pot000066400000000000000000000046671507144700500300360ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the camerascanner.jonnius package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: camerascanner.jonnius\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2022-12-29 16:06+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" #: ../plugins/ImageProcessing/ImageProcessing.cpp:39 msgid "Session restored" msgstr "" #: ../qml/components/CommonHeader.qml:8 #: ../qml/components/SingleImageHeader.qml:6 camerascanner.desktop.in.h:1 msgid "Camera Scanner" msgstr "" #: ../qml/components/CommonHeader.qml:23 msgid "Information" msgstr "" #: ../qml/components/CommonHeader.qml:33 msgid "Add" msgstr "" #: ../qml/components/CommonHeader.qml:48 ../qml/components/CommonHeader.qml:53 msgid "Clear session" msgstr "" #: ../qml/components/CommonHeader.qml:55 msgid "Do you really want to remove all images?" msgstr "" #: ../qml/components/CommonHeader.qml:56 msgid "Cancel" msgstr "" #: ../qml/components/CommonHeader.qml:57 #: ../qml/components/SingleImageHeader.qml:24 msgid "Delete" msgstr "" #: ../qml/components/CommonHeader.qml:67 #: ../qml/components/SingleImageHeader.qml:32 msgid "Save" msgstr "" #: ../qml/components/EmptySession.qml:33 msgid "Empty Session" msgstr "" #: ../qml/components/EmptySession.qml:35 msgid "Please, tap on the + icon to add images to the session" msgstr "" #: ../qml/pages/ImportPage.qml:37 msgid "Import Image" msgstr "" #: ../qml/pages/InfoPage.qml:12 msgid "Info about Camera Scanner" msgstr "" #: ../qml/pages/InfoPage.qml:37 msgid "Report a bug" msgstr "" #: ../qml/pages/InfoPage.qml:44 msgid "Contributors" msgstr "" #: ../qml/pages/InfoPage.qml:51 msgid "Source code" msgstr "" #: ../qml/pages/InfoPage.qml:58 msgid "License" msgstr "" #: ../qml/pages/SingleImagePage.qml:143 msgid "Filter Mode" msgstr "" #: ../qml/pages/SingleImagePage.qml:157 msgid "Color Mode" msgstr "" #: ../qml/pages/SingleImagePage.qml:181 msgid "Color Thr" msgstr "" #: ../qml/pages/SingleImagePage.qml:218 msgid "Contrast" msgstr "" #: ../qml/pages/SingleImagePage.qml:255 msgid "Brightness" msgstr "" #: ../qml/pages/SingleImagePage.qml:281 msgid "Restore to default" msgstr "" camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/po/de.po000066400000000000000000000056401507144700500237440ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the camerascanner.jonnius package. # FIRST AUTHOR , YEAR. # msgid "" msgstr "" "Project-Id-Version: camerascanner.jonnius\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-03-20 19:13+0000\n" "PO-Revision-Date: 2020-03-20 20:18+0100\n" "Last-Translator: \n" "Language-Team: Jonatan Hatakeyama Zeidler\n" "Language: de\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Generator: Poedit 2.2.4\n" "X-Poedit-SourceCharset: UTF-8\n" #: ../qml/pages/ImportPage.qml:37 msgid "Import Image" msgstr "Bild importieren" #: ../qml/pages/InfoPage.qml:12 msgid "Info about Camera Scanner" msgstr "Infos zu Camera Scanner" #: ../qml/pages/InfoPage.qml:37 msgid "Report a bug" msgstr "Fehler melden" #: ../qml/pages/InfoPage.qml:44 msgid "Contributors" msgstr "Mitwirkende" #: ../qml/pages/InfoPage.qml:51 msgid "Source code" msgstr "Quelltext" #: ../qml/pages/InfoPage.qml:58 msgid "License" msgstr "Lizenz" #: ../qml/pages/SingleImagePage.qml:142 msgid "Filter Mode" msgstr "Filtermodus" #: ../qml/pages/SingleImagePage.qml:156 msgid "Color Mode" msgstr "Farbmodus" #: ../qml/pages/SingleImagePage.qml:180 msgid "Color Thr" msgstr "Farbschwelle" #: ../qml/pages/SingleImagePage.qml:217 msgid "Contrast" msgstr "Kontrast" #: ../qml/pages/SingleImagePage.qml:254 msgid "Brightness" msgstr "Helligkeit" #: ../qml/pages/SingleImagePage.qml:280 msgid "Restore to default" msgstr "Zurücksetzen" #: ../qml/components/CommonHeader.qml:8 #: ../qml/components/SingleImageHeader.qml:6 camerascanner.desktop.in.h:1 msgid "Camera Scanner" msgstr "Camera Scanner" #: ../qml/components/CommonHeader.qml:23 msgid "Information" msgstr "Informationen" #: ../qml/components/CommonHeader.qml:33 msgid "Add" msgstr "Hinzufügen" #: ../qml/components/CommonHeader.qml:48 ../qml/components/CommonHeader.qml:53 msgid "Clear session" msgstr "Neue Sitzung" #: ../qml/components/CommonHeader.qml:55 msgid "Do you really want to remove all images?" msgstr "Sollen wirklich alle Bilder entfernt werden?" #: ../qml/components/CommonHeader.qml:56 msgid "Cancel" msgstr "Abbrechen" #: ../qml/components/CommonHeader.qml:57 #: ../qml/components/SingleImageHeader.qml:24 msgid "Delete" msgstr "Entfernen" #: ../qml/components/CommonHeader.qml:67 #: ../qml/components/SingleImageHeader.qml:32 msgid "Save" msgstr "Speichern" #: ../qml/components/EmptySession.qml:33 msgid "Empty Session" msgstr "Leere Sitzung" #: ../qml/components/EmptySession.qml:35 msgid "Please, tap on the + icon to add images to the session" msgstr "Auf das +-Symbol tippen, um Bilder zur Sitzung hinzuzufügen" #: ../plugins/ImageProcessing/ImageProcessing.cpp:39 msgid "Session restored" msgstr "Sitzung wiederhergestellt" #~ msgid "Edit" #~ msgstr "Bearbeiten" #~ msgid "Empty Project" #~ msgstr "Leeres Projekt" camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/po/es.po000066400000000000000000000055421507144700500237640ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the camerascanner.jonnius package. # FIRST AUTHOR , YEAR. # msgid "" msgstr "" "Project-Id-Version: camerascanner.jonnius\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-01-26 17:33+0000\n" "PO-Revision-Date: 2020-03-02 00:33+0100\n" "Language-Team: UBports Spanish Team\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Generator: Poedit 2.2.4\n" "Last-Translator: Josu\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" "Language: es\n" #: ../qml/pages/ImportPage.qml:37 msgid "Import Image" msgstr "Importar imagen" #: ../qml/pages/InfoPage.qml:12 msgid "Info about Camera Scanner" msgstr "Información sobre Camera Scanner" #: ../qml/pages/InfoPage.qml:37 msgid "Report a bug" msgstr "Reportar un fallo" #: ../qml/pages/InfoPage.qml:44 msgid "Contributors" msgstr "Contribuyentes" #: ../qml/pages/InfoPage.qml:51 msgid "Source code" msgstr "Código fuente" #: ../qml/pages/InfoPage.qml:58 msgid "License" msgstr "Licencia" #: ../qml/pages/SingleImagePage.qml:142 msgid "Filter Mode" msgstr "Modo filtro" #: ../qml/pages/SingleImagePage.qml:156 msgid "Color Mode" msgstr "Modo color" #: ../qml/pages/SingleImagePage.qml:180 msgid "Color Thr" msgstr "Color Thr" #: ../qml/pages/SingleImagePage.qml:217 msgid "Contrast" msgstr "Contraste" #: ../qml/pages/SingleImagePage.qml:254 msgid "Brightness" msgstr "Brillo" #: ../qml/pages/SingleImagePage.qml:280 msgid "Restore to default" msgstr "Restaurar por defecto" #: ../qml/components/CommonHeader.qml:8 #: ../qml/components/SingleImageHeader.qml:6 camerascanner.desktop.in.h:1 msgid "Camera Scanner" msgstr "Camera Scanner" #: ../qml/components/CommonHeader.qml:23 msgid "Information" msgstr "Información" #: ../qml/components/CommonHeader.qml:33 msgid "Add" msgstr "Añadir" #: ../qml/components/CommonHeader.qml:48 ../qml/components/CommonHeader.qml:53 msgid "Clear session" msgstr "Limpiar sesión" #: ../qml/components/CommonHeader.qml:55 msgid "Do you really want to remove all images?" msgstr "¿Realmente desea borrar todas las imágenes?" #: ../qml/components/CommonHeader.qml:56 msgid "Cancel" msgstr "Cancelar" #: ../qml/components/CommonHeader.qml:57 #: ../qml/components/SingleImageHeader.qml:24 msgid "Delete" msgstr "Eliminar" #: ../qml/components/CommonHeader.qml:67 #: ../qml/components/SingleImageHeader.qml:32 msgid "Save" msgstr "Guardar" #: ../qml/components/EmptySession.qml:33 msgid "Empty Session" msgstr "Vaciar sesión" #: ../qml/components/EmptySession.qml:35 msgid "Please, tap on the + icon to add images to the session" msgstr "Por favor, pulse en el icono + para añadir imágenes a la sesión" #: ../plugins/ImageProcessing/ImageProcessing.cpp:39 msgid "Session restored" msgstr "Sesión restaurada"camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/po/fr.po000066400000000000000000000056501507144700500237640ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the camerascanner.jonius package. # FIRST AUTHOR , YEAR. # msgid "" msgstr "" "Project-Id-Version: camerascanner.jonius\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-03-20 19:13+0000\n" "PO-Revision-Date: 2020-03-22 18:12+0100\n" "Last-Translator: Anne017 \n" "Language-Team: \n" "Language: fr\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../qml/pages/ImportPage.qml:37 msgid "Import Image" msgstr "Importer une image" #: ../qml/pages/InfoPage.qml:12 msgid "Info about Camera Scanner" msgstr "Informations à propos de Numériseur" #: ../qml/pages/InfoPage.qml:37 msgid "Report a bug" msgstr "Signaler un problème" #: ../qml/pages/InfoPage.qml:44 msgid "Contributors" msgstr "Contributeurs/trices" #: ../qml/pages/InfoPage.qml:51 msgid "Source code" msgstr "Code source" #: ../qml/pages/InfoPage.qml:58 msgid "License" msgstr "Licence" #: ../qml/pages/SingleImagePage.qml:142 msgid "Filter Mode" msgstr "Mode filtre" #: ../qml/pages/SingleImagePage.qml:156 msgid "Color Mode" msgstr "Mode couleur" #: ../qml/pages/SingleImagePage.qml:180 msgid "Color Thr" msgstr "Seuil de couleur" #: ../qml/pages/SingleImagePage.qml:217 msgid "Contrast" msgstr "Contraste" #: ../qml/pages/SingleImagePage.qml:254 msgid "Brightness" msgstr "Luminosité" #: ../qml/pages/SingleImagePage.qml:280 msgid "Restore to default" msgstr "Restaurer les valeurs par défaut" #: ../qml/components/CommonHeader.qml:8 #: ../qml/components/SingleImageHeader.qml:6 camerascanner.desktop.in.h:1 msgid "Camera Scanner" msgstr "Numériseur" #: ../qml/components/CommonHeader.qml:23 msgid "Information" msgstr "Informations" #: ../qml/components/CommonHeader.qml:33 msgid "Add" msgstr "Ajouter" #: ../qml/components/CommonHeader.qml:48 ../qml/components/CommonHeader.qml:53 msgid "Clear session" msgstr "Nettoyer la session" #: ../qml/components/CommonHeader.qml:55 msgid "Do you really want to remove all images?" msgstr "Voulez-vous vraiment supprimer toutes les images ?" #: ../qml/components/CommonHeader.qml:56 msgid "Cancel" msgstr "Annuler" #: ../qml/components/CommonHeader.qml:57 #: ../qml/components/SingleImageHeader.qml:24 msgid "Delete" msgstr "Supprimer" #: ../qml/components/CommonHeader.qml:67 #: ../qml/components/SingleImageHeader.qml:32 msgid "Save" msgstr "Enregistrer" #: ../qml/components/EmptySession.qml:33 msgid "Empty Session" msgstr "Session vide" #: ../qml/components/EmptySession.qml:35 msgid "Please, tap on the + icon to add images to the session" msgstr "Appuyez sur l'icône « + » pour ajouter des images à la session" #: ../plugins/ImageProcessing/ImageProcessing.cpp:39 msgid "Session restored" msgstr "Session restaurée" #~ msgid "Edit" #~ msgstr "Modifier" #~ msgid "Empty Project" #~ msgstr "Projet vide"camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/po/nl.po000066400000000000000000000055511507144700500237660ustar00rootroot00000000000000# SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the camerascanner.jonnius package. # FIRST AUTHOR , YEAR. # msgid "" msgstr "" "Project-Id-Version: camerascanner.jonnius\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-04-03 21:41+0000\n" "PO-Revision-Date: 2020-07-10 20:03+0200\n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Generator: Poedit 2.3.1\n" "Last-Translator: Heimen Stoffels \n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" "Language: nl\n" #: ../plugins/ImageProcessing/ImageProcessing.cpp:39 msgid "Session restored" msgstr "De sessie is hersteld" #: ../qml/components/CommonHeader.qml:8 #: ../qml/components/SingleImageHeader.qml:6 camerascanner.desktop.in.h:1 msgid "Camera Scanner" msgstr "Camerascanner" #: ../qml/components/CommonHeader.qml:23 msgid "Information" msgstr "Informatie" #: ../qml/components/CommonHeader.qml:33 msgid "Add" msgstr "Toevoegen" #: ../qml/components/CommonHeader.qml:48 ../qml/components/CommonHeader.qml:53 msgid "Clear session" msgstr "Sessie wissen" #: ../qml/components/CommonHeader.qml:55 msgid "Do you really want to remove all images?" msgstr "Weet je zeker dat je alle afbeeldingen wilt verwijderen?" #: ../qml/components/CommonHeader.qml:56 msgid "Cancel" msgstr "Annuleren" #: ../qml/components/CommonHeader.qml:57 #: ../qml/components/SingleImageHeader.qml:24 msgid "Delete" msgstr "Verwijderen" #: ../qml/components/CommonHeader.qml:67 #: ../qml/components/SingleImageHeader.qml:32 msgid "Save" msgstr "Opslaan" #: ../qml/components/EmptySession.qml:33 msgid "Empty Session" msgstr "Lege sessie" #: ../qml/components/EmptySession.qml:35 msgid "Please, tap on the + icon to add images to the session" msgstr "Druk op de '+'-knop om afbeeldingen toe te voegen" #: ../qml/pages/ImportPage.qml:37 msgid "Import Image" msgstr "Afbeelding importeren" #: ../qml/pages/InfoPage.qml:12 msgid "Info about Camera Scanner" msgstr "Informatie over Camerascanner" #: ../qml/pages/InfoPage.qml:37 msgid "Report a bug" msgstr "Bug melden" #: ../qml/pages/InfoPage.qml:44 msgid "Contributors" msgstr "Bijdragers" #: ../qml/pages/InfoPage.qml:51 msgid "Source code" msgstr "Broncode" #: ../qml/pages/InfoPage.qml:58 msgid "License" msgstr "Licentie" #: ../qml/pages/SingleImagePage.qml:142 msgid "Filter Mode" msgstr "Filtermodus" #: ../qml/pages/SingleImagePage.qml:156 msgid "Color Mode" msgstr "Kleurmodus" #: ../qml/pages/SingleImagePage.qml:180 msgid "Color Thr" msgstr "Kleurwaarde" #: ../qml/pages/SingleImagePage.qml:217 msgid "Contrast" msgstr "Contrast" #: ../qml/pages/SingleImagePage.qml:254 msgid "Brightness" msgstr "Helderheid" #: ../qml/pages/SingleImagePage.qml:280 msgid "Restore to default" msgstr "Standaardwaarden herstellen" camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/qml/000077500000000000000000000000001507144700500231625ustar00rootroot00000000000000camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/qml/Main.qml000066400000000000000000000020411507144700500245560ustar00rootroot00000000000000import QtQuick 2.6 import QtQuick.Layouts 1.3 import Lomiri.Components 1.3 import ImageProcessing 1.0 import "components" import "pages" MainView { id: mainView objectName: 'mainView' applicationName: 'camerascanner.jonnius' automaticOrientation: true width: units.gu(45) height: units.gu(75) readonly property color bgColor: "#0e8cba" readonly property color fgColor: "#f7f7f7" readonly property color txtColor: "#3d3d3d" property var activeTransfer: null property double gridmargin: units.gu(1) property double mingridwidth: units.gu(15) function notification(text) { var noti = Qt.createComponent(Qt.resolvedUrl("components/InfoBar.qml")) noti.createObject(mainView, { "text": text }) } PageStack { id: pageStack Component.onCompleted: pageStack.push(mainPage) } MainPage { id: mainPage anchors.fill: parent } Component.onCompleted: ImageProcessing.restoreCache() } camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/qml/components/000077500000000000000000000000001507144700500253475ustar00rootroot00000000000000camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/qml/components/CommonHeader.qml000066400000000000000000000063441507144700500304320ustar00rootroot00000000000000import QtQuick 2.6 import Lomiri.Components 1.3 import Lomiri.Content 1.3 import ImageProcessing 1.0 import Lomiri.Components.Popups 1.3 PageHeader { title: i18n.tr('Camera Scanner') StyleHints { foregroundColor: fgColor backgroundColor: bgColor dividerColor.visible: false } trailingActionBar { numberOfSlots: 4 actions: [ Action { iconName: "info" shortcut: "Ctrl+i" text: i18n.tr("Information") onTriggered: { pageStack.push(Qt.resolvedUrl("../pages/InfoPage.qml")) } }, Action { iconName: "add" shortcut: "Ctrl+a" text: i18n.tr("Add") onTriggered: { Qt.inputMethod.hide() pageStack.push(Qt.resolvedUrl("../pages/ImportPage.qml"), { "contentType": ContentType.Pictures, "handler": ContentHandler.Source }) } }, Action { iconName: "delete" shortcut: "Ctrl+Del" visible: imageModel.count != 0 text: i18n.tr("Clear session") onTriggered: { PopupUtils.open(clearSessionDialog, mainPage, { "confirmationDialogText": i18n.tr( "Clear session"), "descriptionLabelText": i18n.tr( "Do you really want to remove all images?"), "cancelButtonText": i18n.tr("Cancel"), "confirmButtonText": i18n.tr("Delete"), "confirmIsDestructive": true }) } }, Action { iconName: "save" shortcut: "Ctrl+s" visible: ImageProcessing.isAnyImage text: i18n.tr("Save") onTriggered: { var url = ImageProcessing.exportAllAsPdf() if (url) { console.log("Share: " + url) var sharePopup = PopupUtils.open(shareDialog, mainPage, { "contentType": ContentType.Documents }) sharePopup.items.push(contentItemComponent.createObject( mainPage, { "url": url, "text": "export" })) } else { console.log("Sharing docs failed") // TODO display proper message } } } ] } } camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/qml/components/ConfirmationDialog.qml000066400000000000000000000024111507144700500316300ustar00rootroot00000000000000import QtQuick 2.6 import Lomiri.Components 1.3 import Lomiri.Components.Popups 1.3 Dialog { id: confirmationDialog property alias confirmationDialogText: confirmationDialog.title property alias descriptionLabelText: descriptionLabel.text property alias confirmButtonText: confirmButton.text property alias cancelButtonText: cancelButton.text property bool confirmIsDestructive signal confirmClicked signal cancelClicked Label { id: descriptionLabel horizontalAlignment: Text.AlignHCenter wrapMode: Text.WordWrap } Row { anchors { left: parent.left right: parent.right } spacing: units.gu(1) Button { id: cancelButton width: parent.width / 2 - units.gu(0.5) onClicked: { cancelClicked() PopupUtils.close(confirmationDialog) } } Button { id: confirmButton color: confirmIsDestructive ? theme.palette.normal.negative : theme.palette.normal.focus width: parent.width / 2 - units.gu(0.5) onClicked: { confirmClicked() PopupUtils.close(confirmationDialog) } } } } camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/qml/components/ContentShareDialog.qml000066400000000000000000000027461507144700500316100ustar00rootroot00000000000000 /* * Copyright 2014 Canonical Ltd. * * This file is part of webbrowser-app. * * webbrowser-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * webbrowser-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import QtQuick 2.4 import Lomiri.Components 1.3 import Lomiri.Components.Popups 1.3 import Lomiri.Content 1.3 PopupBase { id: shareDialog anchors.fill: parent property var activeTransfer property var items: [] property alias contentType: peerPicker.contentType Rectangle { anchors.fill: parent ContentPeerPicker { id: peerPicker handler: ContentHandler.Destination visible: parent.visible onPeerSelected: { activeTransfer = peer.request() activeTransfer.items = shareDialog.items activeTransfer.state = ContentTransfer.Charged PopupUtils.close(shareDialog) } onCancelPressed: { PopupUtils.close(shareDialog) } } } } camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/qml/components/EmptySession.qml000066400000000000000000000021531507144700500305250ustar00rootroot00000000000000 /* Copyright (C) 2015, 2016 Stefano Verzegnassi This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License 3 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ import QtQuick 2.6 import Lomiri.Components 1.3 Item { anchors.fill: parent EmptyState { id: state anchors { topMargin: units.gu(8) left: parent.left right: parent.right margins: units.gu(2) verticalCenter: parent.verticalCenter } title: i18n.tr("Empty Session") subTitle: i18n.tr( "Please, tap on the + icon to add images to the session") iconName: "insert-image" } } camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/qml/components/EmptyState.qml000066400000000000000000000036641507144700500301720ustar00rootroot00000000000000 /* * Copyright (C) 2014-2016 Canonical Ltd * * This file is part of Ubuntu Clock App * * Ubuntu Clock App is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * Ubuntu Clock App is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import QtQuick 2.6 import Lomiri.Components 1.3 /* Component which displays an empty state (approved by design). It offers an icon, title and subtitle to describe the empty state. */ Item { id: emptyState // Public APIs property alias iconName: emptyIcon.name property alias title: emptyLabel.text property alias subTitle: emptySublabel.text height: childrenRect.height Label { id: emptyLabel textSize: Label.Large font.weight: Font.Normal width: parent.width wrapMode: Text.WordWrap horizontalAlignment: Text.AlignHCenter color: bgColor } Icon { id: emptyIcon anchors { horizontalCenter: parent.horizontalCenter top: emptyLabel.bottom topMargin: units.gu(4) } height: units.gu(17) width: height color: bgColor asynchronous: true } Label { id: emptySublabel width: parent.width - gridmargin * 6 wrapMode: Text.WordWrap anchors { horizontalCenter: parent.horizontalCenter top: emptyIcon.bottom topMargin: units.gu(6) } horizontalAlignment: Text.AlignHCenter color: LomiriColors.ash } } camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/qml/components/InfoBar.qml000066400000000000000000000033001507144700500273760ustar00rootroot00000000000000import QtQuick 2.4 import Lomiri.Components 1.3 Rectangle { id: infoBar property alias text: infoBarText.text width: parent.width height: infoBarText.height + units.gu(3) anchors { bottom: parent.bottom bottomMargin: -height } color: "#000" opacity: 0 Component.onCompleted: { anchors.bottomMargin = 0 opacity = 0.6 infoBarTimer.start() } Text { id: infoBarText anchors { left: parent.left leftMargin: units.gu(2) right: parent.right rightMargin: units.gu(2) verticalCenter: parent.verticalCenter } text: "" wrapMode: Text.WrapAnywhere color: "white" } Timer { id: infoBarTimer interval: 3000 running: false repeat: false triggeredOnStart: false onTriggered: { animaDestroy.start() } } SequentialAnimation { id: animaDestroy LomiriNumberAnimation { target: infoBar.anchors property: "bottomMargin" to: -infoBar.height duration: 500 easing.type: Easing.InOutCirc } LomiriNumberAnimation { target: infoBar property: "opacity" to: 0 duration: 500 easing.type: Easing.InOutCirc } } Behavior on opacity { LomiriNumberAnimation { duration: 500 easing.type: Easing.InOutCirc } } Behavior on anchors.bottomMargin { LomiriNumberAnimation { duration: 500 easing.type: Easing.InOutCirc } } } camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/qml/components/SettingsListItem.qml000066400000000000000000000013401507144700500313330ustar00rootroot00000000000000import QtQuick 2.9 import QtQuick.Layouts 1.1 import Lomiri.Components 1.3 ListItem { property var name: "" property var value: "" property var icon: "settings" property var rightIcon: "" height: layout.height ListItemLayout { id: layout title.text: name subtitle.text: value Icon { name: icon width: units.gu(3) height: units.gu(3) visible: icon !== "" SlotsLayout.position: SlotsLayout.Leading } Icon { SlotsLayout.position: SlotsLayout.Trailing name: rightIcon visible: rightIcon !== "" width: units.gu(2) height: width } } } camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/qml/components/SingleImageHeader.qml000066400000000000000000000013641507144700500313630ustar00rootroot00000000000000import QtQuick 2.6 import Lomiri.Components 1.3 import Lomiri.Content 1.3 PageHeader { title: i18n.tr('Camera Scanner') signal deleteImage signal saveImage StyleHints { foregroundColor: fgColor backgroundColor: bgColor dividerColor.visible: false } trailingActionBar { numberOfSlots: 2 actions: [ Action { iconName: "delete" shortcut: "supr" text: i18n.tr("Delete") onTriggered: deleteImage() }, Action { iconName: "save" shortcut: "Ctrl+s" text: i18n.tr("Save") onTriggered: saveImage() } ] } } camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/qml/pages/000077500000000000000000000000001507144700500242615ustar00rootroot00000000000000camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/qml/pages/ImportPage.qml000066400000000000000000000044671507144700500270560ustar00rootroot00000000000000 /* * Copyright (C) 2016 Stefano Verzegnassi * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License 3 as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. */ import QtQuick 2.6 import Lomiri.Components 1.3 import Lomiri.Content 1.3 import ImageProcessing 1.0 Page { id: picker property var activeTransfer property var url property var handler property var contentType signal cancel signal imported(string fileUrl) header: PageHeader { id: importHeader title: i18n.tr("Import Image") } ContentPeerPicker { anchors { fill: parent topMargin: importHeader.height } visible: parent.visible showTitle: false contentType: picker.contentType handler: picker.handler onPeerSelected: { peer.selectionType = ContentTransfer.Multiple picker.activeTransfer = peer.request() picker.activeTransfer.stateChanged.connect(function () { if (picker.activeTransfer.state === ContentTransfer.Charged) { console.log("Charged") console.log(picker.activeTransfer.items[0].url) for (var i = 0; i < picker.activeTransfer.items.length; i++) { var item = picker.activeTransfer.items[i] //Add current image to being processed ImageProcessing.addImage(item.url) } picker.activeTransfer = null pageStack.pop() } }) } onCancelPressed: { pageStack.pop() } } ContentTransferHint { id: transferHint anchors.fill: parent activeTransfer: picker.activeTransfer } Component { id: resultComponent ContentItem {} } } camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/qml/pages/InfoPage.qml000066400000000000000000000036641507144700500264750ustar00rootroot00000000000000import QtQuick 2.9 import QtQuick.Layouts 1.1 import Lomiri.Components 1.3 import "../components" Page { id: infoPage anchors.fill: parent header: PageHeader { id: header title: i18n.tr('Info about Camera Scanner') StyleHints { foregroundColor: fgColor backgroundColor: bgColor dividerColor.visible: false } } ScrollView { id: scrollView width: parent.width height: parent.height - header.height anchors.top: header.bottom contentItem: Column { width: infoPage.width Icon { anchors.horizontalCenter: parent.horizontalCenter anchors.topMargin: parent.width / 4 width: parent.width / 2 height: width source: "../../assets/logo.svg" } SettingsListItem { name: i18n.tr("Report a bug") icon: "stock_message" onClicked: Qt.openUrlExternally( "https://gitlab.com/jonnius/camera-scanner/issues") } SettingsListItem { name: i18n.tr("Contributors") icon: "contact-group" onClicked: Qt.openUrlExternally( "https://gitlab.com/jonnius/camera-scanner/-/graphs/master") } SettingsListItem { name: i18n.tr("Source code") icon: "text-xml-symbolic" onClicked: Qt.openUrlExternally( "https://gitlab.com/jonnius/camera-scanner") } SettingsListItem { name: i18n.tr("License") icon: "x-office-document-symbolic" onClicked: Qt.openUrlExternally( "https://gitlab.com/jonnius/camera-scanner/blob/master/LICENSE") } } } } camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/qml/pages/MainPage.qml000066400000000000000000000207531507144700500264640ustar00rootroot00000000000000import QtQuick 2.6 import Lomiri.Components 1.3 import QtQml.Models 2.1 import QtGraphicalEffects 1.0 import ImageProcessing 1.0 import Lomiri.Content 1.3 import Lomiri.Components.Popups 1.3 import "../components" Page { id: mainPage property alias imageModel: imageModel signal exportCompleted header: CommonHeader { id: mainHeader } function getImageUrl(id) { return "image://documents/" + id } function addImage(id) { imageModel.append({ "imageID": id, "imgout": getImageUrl(id) }) } function getIndexById(id) { for (var i = 0; i < imageModel.count; i++) { console.log("Looking at " + imageModel.get(i).imageID) if (imageModel.get(i).imageID == id) return i } console.log("Requested image with ID " + id + " is not in list model") return null } function updateImage(id) { var index = getIndexById(id) if (index !== null) { imageModel.get(index).imgout = "" imageModel.get(index).imgout = getImageUrl(id) } } function removeImage(id) { var index = getIndexById(id) if (index !== null) imageModel.remove(index) } Connections { target: ImageProcessing onImageAdded: addImage(id) onImageRemoved: removeImage(id) onUserInfo: notification(msg) onImageUpdated: updateImage(id) } ListModel { id: imageModel } Component { id: shareDialog ContentShareDialog { Component.onDestruction: exportCompleted() } } Component { id: clearSessionDialog ConfirmationDialog { onConfirmClicked: ImageProcessing.removeAll() } } Component { id: contentItemComponent ContentItem {} } DelegateModel { id: visualModel model: imageModel delegate: MouseArea { id: delegateRoot property int visualIndex: DelegateModel.itemsIndex property var imageID: model.imageID width: gridview.cellWidth height: gridview.cellHeight drag.smoothed: true Item { id: icon width: gridview.cellWidth height: gridview.cellHeight anchors { horizontalCenter: parent.horizontalCenter verticalCenter: parent.verticalCenter } Drag.active: delegateRoot.drag.active Drag.source: delegateRoot Drag.hotSpot.x: 36 Drag.hotSpot.y: 36 states: [ State { when: icon.Drag.active ParentChange { target: icon parent: mainView } AnchorChanges { target: icon anchors.horizontalCenter: undefined anchors.verticalCenter: undefined } } ] Image { id: mainImg anchors { fill: parent leftMargin: mainView.gridmargin rightMargin: mainView.gridmargin topMargin: 1.5 * mainView.gridmargin bottomMargin: 1.5 * mainView.gridmargin } asynchronous: true fillMode: Image.PreserveAspectFit source: Qt.resolvedUrl(model.imgout) // Prevent blurry SVGs sourceSize.width: 2 * mainView.mingridwidth sourceSize.height: 3 * mainView.mingridwidth /* Overlay for when image is pressed */ Rectangle { id: overlay anchors.fill: parent color: "#000" border.color: LomiriColors.orange border.width: 0 opacity: delegateRoot.pressed ? 0.3 : 0 Behavior on opacity { NumberAnimation { duration: LomiriAnimation.SlowDuration } } } } DropShadow { anchors.fill: mainImg horizontalOffset: 5 verticalOffset: 5 radius: 18 samples: 25 transparentBorder: true color: "#80000000" source: mainImg } } DropArea { anchors { fill: parent margins: 15 } onEntered: { visualModel.items.move(drag.source.visualIndex, delegateRoot.visualIndex) imageModel.move(drag.source.visualIndex, delegateRoot.visualIndex, 1) } } onPressAndHold: { overlay.border.width = 10 mouse.accepted = false delegateRoot.drag.target = icon deleteIcon.visible = true } onReleased: { /* if (deleteIcon.visible == true) { ImageProcessing.removeImage ( model.imageID ) imageModel.remove( index ) overlay.border.width = 0 delegateRoot.drag.target = undefined deleteIcon.visible = false } else { var url = ImageProcessing.exportAsPdf( model.imageID ) console.log("Share:",url) var sharePopup = PopupUtils.open(shareDialog, mainPage, {"contentType" : ContentType.Documents}) sharePopup.items.push(contentItemComponent.createObject(mainPage, {"url" : url, "text": model.imageID})) } */ ImageProcessing.loadSingleImageSettings(model.imageID) pageStack.push(Qt.resolvedUrl("SingleImagePage.qml"), { "currentImage": Qt.resolvedUrl(model.imgout), "currentID": model.imageID, "currentIndex": index }) } } } Item { id: topPanel anchors { left: parent.left right: parent.right top: mainHeader.bottom topMargin: units.gu(2) } height: units.gu(5) DropArea { id: deleteDragTarget anchors.fill: parent Icon { id: deleteIcon name: "delete" visible: false color: LomiriColors.red anchors.horizontalCenter: parent.horizontalCenter height: parent.height } states: [ State { when: deleteDragTarget.containsDrag PropertyChanges { target: deleteIcon color: LomiriColors.coolGrey } } ] } } GridView { id: gridview anchors { top: topPanel.bottom left: parent.left right: parent.right bottom: parent.bottom topMargin: units.gu(2) leftMargin: mainView.gridmargin rightMargin: mainView.gridmargin } height: mainView.height / 2 clip: true cellWidth: width / Math.floor(width / mainView.mingridwidth) cellHeight: cellWidth * 1.4 displaced: Transition { NumberAnimation { properties: "x,y" easing.type: Easing.OutQuad } } model: visualModel } Loader { id: emptyStateLoader anchors.fill: parent active: imageModel.count === 0 source: Qt.resolvedUrl("../components/EmptySession.qml") } } camera-scanner-v0.5.1-18f23fa50b91931246dbfba9a29a2d9fb5a9e86d/qml/pages/SingleImagePage.qml000066400000000000000000000245021507144700500277600ustar00rootroot00000000000000import QtQuick 2.9 import Lomiri.Components 1.3 import ImageProcessing 1.0 import Lomiri.Content 1.3 import Lomiri.Components.Popups 1.3 import "../components" Page { id: singleImagePage width: parent.width property string currentImage property int currentIndex property string currentID property bool pageLoaded: false header: SingleImageHeader { id: singleImageHeader } Flickable { id: flickable anchors { left: parent.left top: parent.top right: parent.right bottom: detailsItem.top topMargin: singleImagePage.header.height } contentHeight: height contentWidth: width Item { height: flickable.height width: flickable.width LomiriShape { id: image aspect: LomiriShape.Flat anchors { fill: parent leftMargin: gridmargin rightMargin: gridmargin } source: Image { sourceSize.width: image.width sourceSize.height: image.height source: currentImage cache: false } sourceFillMode: LomiriShape.PreserveAspectFit } } } MouseArea { anchors { left: parent.left right: parent.right bottom: parent.bottom } height: detailsItem.height property bool ignoring: false onPressed: { ignoring = false if (detailsItem.showProgress == 0 && mouseY < height - units.gu(2)) { print("rejecting mouse") mouse.accepted = false ignoring = true } } onMouseYChanged: { if (ignoring) { return } detailsItem.showProgress = (height - mouseY) / height } onReleased: { if (detailsItem.showProgress > .5) { detailsItem.showProgress = 1 } else { detailsItem.showProgress = 0 } } } Item { id: detailsItem anchors { left: parent.left right: parent.right bottom: parent.bottom } height: singleImagePage.height / 2 anchors.bottomMargin: Math.min(Math.max( -height + units.gu(2), -height + showProgress * height), 0) property real showProgress: 0 Behavior on anchors.bottomMargin { LomiriNumberAnimation {} } Rectangle { id: dragHandle anchors { left: parent.left right: parent.right top: parent.top } height: units.gu(2) color: bgColor Row { anchors.centerIn: parent spacing: units.gu(1) Repeater { model: 3 Rectangle { height: units.gu(1) width: height radius: height / 2 color: Qt.lighter(Qt.lighter(bgColor)) } } } } Column { width: parent.width spacing: units.gu(2) anchors.top: dragHandle.bottom anchors.horizontalCenter: parent.horizontalCenter ListItemLayout { id: filterModeSwitch title.text: i18n.tr("Filter Mode") title.color: theme.palette.normal.baseText Switch { id: filterSwitch checked: ImageProcessing.filterMode onCheckedChanged: if (pageLoaded) reprocessImage() } } ListItemLayout { id: colorModeSwitch visible: filterSwitch.checked title.text: i18n.tr("Color Mode") title.color: theme.palette.normal.baseText Switch { id: colorSwitch checked: ImageProcessing.colorMode onCheckedChanged: if (pageLoaded) reprocessImage() } } Row { id: thrRow anchors.horizontalCenter: parent.horizontalCenter visible: filterSwitch.checked && colorSwitch.checked spacing: units.gu(2) property var sliderWidth: parent.width - thrLabel.width - units.gu( 6) Label { id: thrLabel width: text.width wrapMode: Text.Wrap text: i18n.tr("Color Thr") } Slider { id: colorThrSlider live: false function formatValue(v) { return v.toFixed(2) } minimumValue: 0.25 maximumValue: 1.0 value: ImageProcessing.colorThr width: thrRow.sliderWidth height: units.gu(2) onPressedChanged: { if (!pressed) { reprocessImage() } } } } Row { id: gainRow anchors.horizontalCenter: parent.horizontalCenter visible: filterSwitch.checked && colorSwitch.checked spacing: units.gu(2) property var sliderWidth: parent.width - gainLabel.width - units.gu( 6) Label { id: gainLabel width: text.width wrapMode: Text.Wrap text: i18n.tr("Contrast") } Slider { id: colorGainSlider live: false function formatValue(v) { return v.toFixed(2) } minimumValue: 1.00 maximumValue: 2.00 value: ImageProcessing.colorGain width: gainRow.sliderWidth height: units.gu(2) onPressedChanged: { if (!pressed) { reprocessImage() } } } } Row { id: biasRow anchors.horizontalCenter: parent.horizontalCenter visible: filterSwitch.checked && colorSwitch.checked spacing: units.gu(2) property var sliderWidth: parent.width - biasLabel.width - units.gu( 6) Label { id: biasLabel width: text.width wrapMode: Text.Wrap text: i18n.tr("Brightness") } Slider { id: colorBiasSlider live: false function formatValue(v) { return v.toFixed(2) } minimumValue: 0.00 maximumValue: 1.00 value: ImageProcessing.colorBias width: biasRow.sliderWidth height: units.gu(2) onPressedChanged: { if (!pressed) { reprocessImage() } } } } Button { anchors.horizontalCenter: parent.horizontalCenter text: i18n.tr("Restore to default") color: LomiriColors.green onClicked: { colorSwitch.checked = false filterSwitch.checked = true colorThrSlider.value = 0.55 colorGainSlider.value = 1.5 colorBiasSlider.value = 0.0 reprocessImage() } } } } Connections { target: singleImageHeader onDeleteImage: { ImageProcessing.removeImage(currentID) pageStack.pop() } onSaveImage: { //TODO: move this code to a general function //TODO: save as pdf or as an image? var url = ImageProcessing.exportAsPdf(currentID) console.log("Share:", url) var sharePopup = PopupUtils.open(shareDialog, singleImagePage, { "contentType": ContentType.Documents }) sharePopup.items.push(contentItemComponent.createObject( singleImagePage, { "url": url, "text": currentID })) } } Component { id: shareDialog ContentShareDialog { Component.onDestruction: exportCompleted() } } Component { id: contentItemComponent ContentItem {} } Component.onDestruction: { currentImage = "" //TODO: Find a more elegant way of reseting this int currentIndex = -1 currentID = "" } Component.onCompleted: { pageLoaded = true } Connections { target: ImageProcessing onImageUpdated: currentImage = "image://documents/" + id } function reprocessImage() { currentImage = "" ImageProcessing.reprocessImage(currentID, colorSwitch.checked, filterSwitch.checked, colorThrSlider.value, colorGainSlider.value, colorBiasSlider.value) } }