diff --git a/.gitignore b/.gitignore index fd7972b..556a2f6 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,9 @@ converted.js *.pdn *.pyc *.json +!utsushis-charm* +*.exe +*.zip # Created by https://www.toptal.com/developers/gitignore/api/python,visualstudiocode diff --git a/LICENSES/Tesseract-OCR b/LICENSES/Tesseract-OCR new file mode 100644 index 0000000..7a4a3ea --- /dev/null +++ b/LICENSES/Tesseract-OCR @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/LICENSES/UB-Mannheim b/LICENSES/UB-Mannheim new file mode 100644 index 0000000..7a4a3ea --- /dev/null +++ b/LICENSES/UB-Mannheim @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/LICENSES/numpy b/LICENSES/numpy new file mode 100644 index 0000000..84e9bfe --- /dev/null +++ b/LICENSES/numpy @@ -0,0 +1,30 @@ +Copyright (c) 2005-2021, NumPy Developers. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of the NumPy Developers nor the names of any + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/LICENSES/opencv-python b/LICENSES/opencv-python new file mode 100644 index 0000000..dc3aa3d --- /dev/null +++ b/LICENSES/opencv-python @@ -0,0 +1,22 @@ + +MIT License + +Copyright (c) Olli-Pekka Heinisuo + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/LICENSES/pytesseract b/LICENSES/pytesseract new file mode 100644 index 0000000..f49a4e1 --- /dev/null +++ b/LICENSES/pytesseract @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/LICENSES/scikit-image b/LICENSES/scikit-image new file mode 100644 index 0000000..956f518 --- /dev/null +++ b/LICENSES/scikit-image @@ -0,0 +1,81 @@ +Copyright (C) 2019, the scikit-image team +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. Neither the name of skimage nor the names of its contributors may be + used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +skimage/_shared/version_requirements.py:_check_version + + Copyright (c) 2013 The IPython Development Team + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +skimage/_shared/version_requirements.py:is_installed: + + Original Copyright (C) 2009-2011 Pierre Raybaut + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/LICENSES/symspellpy b/LICENSES/symspellpy new file mode 100644 index 0000000..7fedb44 --- /dev/null +++ b/LICENSES/symspellpy @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) 2020 mmb L (Python port https://github.com/mammothb/symspellpy) +Copyright (c) 2020 Wolf Garbe (Original C# implementation https://github.com/wolfgarbe/SymSpell) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/LICENSES/tqdm b/LICENSES/tqdm new file mode 100644 index 0000000..e92d968 --- /dev/null +++ b/LICENSES/tqdm @@ -0,0 +1,49 @@ +`tqdm` is a product of collaborative work. +Unless otherwise stated, all authors (see commit logs) retain copyright +for their respective work, and release the work under the MIT licence +(text below). + +Exceptions or notable authors are listed below +in reverse chronological order: + +* files: * + MPLv2.0 2015-2021 (c) Casper da Costa-Luis + [casperdcl](https://github.com/casperdcl). +* files: tqdm/_tqdm.py + MIT 2016 (c) [PR #96] on behalf of Google Inc. +* files: tqdm/_tqdm.py setup.py README.rst MANIFEST.in .gitignore + MIT 2013 (c) Noam Yorav-Raphael, original author. + +[PR #96]: https://github.com/tqdm/tqdm/pull/96 + + +Mozilla Public Licence (MPL) v. 2.0 - Exhibit A +----------------------------------------------- + +This Source Code Form is subject to the terms of the +Mozilla Public License, v. 2.0. +If a copy of the MPL was not distributed with this file, +You can obtain one at https://mozilla.org/MPL/2.0/. + + +MIT License (MIT) +----------------- + +Copyright (c) 2013 noamraph + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index 6b39987..45f6b17 100644 --- a/README.md +++ b/README.md @@ -14,74 +14,88 @@ It's called Utsushi's charm because I thought it would be funny to make a comple ## Requirements - A computer (Windows) - - Linux and Mac might work too + - Linux and Mac might work too, you wont be able to run the EXE and will have to run from source in a terminal window. - A USB cable to connect your switch to transfer files -- **Google Tesseract** installed and in path - - Version 3 and Version 4 are confirmed working - - Version 4 works much better - - [Installer here](https://digi.bib.uni-mannheim.de/tesseract/tesseract-ocr-w64-setup-v4.1.0.20190314.exe) - - Just run the installer, no extra packages needed +- This latest version of this downloaded to your computer + - You can find it [here](https://github.com/chpoit/utsushis-charm/releases/latest) +- **Google Tesseract** installed and in path (Utsushis-Charm_**vx_x**.zip) + - A copy of the version 4 is bundled with the release. Just run it, no extra packages needed + - Built by UB-Mannheim [License (Apache 2.0)](https://github.com/tesseract-ocr/tesseract/blob/master/LICENSE) + - Alternatively, download the same version here: [Installer here](https://digi.bib.uni-mannheim.de/tesseract/tesseract-ocr-w64-setup-v4.1.0.20190314.exe) - Other Versions available on the [UB-Mannheim Github](https://github.com/UB-Mannheim/tesseract/wiki) page - - [License (Apache 2.0)](https://github.com/tesseract-ocr/tesseract/blob/master/LICENSE) - - Should add itself to path, you might have to reboot. - - Potential Locations: - - `C:\Users\\AppData\Local\Tesseract-OCR` (Version 3) - - `C:\Program Files\Tesseract-OCR` (Version 4) - - `C:\Program Files (x86)\Tesseract-OCR` (Version 4, less likely) -- **Python 3** (in path) - - I used 3.9, but most above 3 should work - - [Here](https://www.python.org/downloads/) - - Check the box to add to path -- This repository downloaded to your computer - - Installing everything in the requirements.txt with `pip install -r requirements.txt`. You might have to use `pip3` instead of `pip` - - The [Source code (zip)](https://github.com/chpoit/utsushis-charm/releases/latest) you can find here - Some knowledge of how to type things in the terminal + - AKA: Knowing how to type in a hacker box - Being able to read -#### Adding something to the path (Windows) - -1. Copy the path to the executable (Where the program was installed) - - Don't put the executable file in the path, only where it is located -2. type `env` in the Windows search bar - - Alternatively type `Edit environment variables for your account` -3. Press Enter -4. Click on `Environment Variables` -5. In `User Variables`, select `Path` -6. Click `Edit` -7. Click `New` -8. Paste the path you copied previously in the new spot. -9. Click `Ok/Apply` for every window you opened. -10. Restart every terminal/command line, or reboot to make sure you'll have access to the new commands - ## Steps 0. Unequip all jewels. You will create "fake" charms otherwise. - Don't ask, this is way out of scope for something that takes you 30 seconds to do. -1. Record clips similar to the following of you going through your charms. Try placing the UI in front of something that is very "flat" in color and doesn't have NPCs walking in front. +1. Download the release bundle and follow the Requirements section (Utsushis-Charm_**vx_x**.zip) + - Make sure you unzip everythin and you leave the files where they are. + - You can delete the `tesseract-installer.exe` once it's installed +2. Record clips similar to the following of you going through your charms. Try placing the UI in front of something that is very "flat" in color and doesn't have NPCs walking in front. - I can easily go through 2-3 pages of charms in 30 seconds. - Use a stopwatch on your phone if you have trouble timing the 30 seconds. I saved a clip every ~25 seconds. - Don't worry about passing over a charm multiple times. Duplicates will be removed at the end. ![Example Clip](./media/example_clip.gif) -2. Transfer the clips to your computer. -3. Put the files in the "inputs" directory in this repository. +3. Transfer the clips to your computer. +4. Put the files in the "inputs" directory. If it does not exist, create it at the same place you can find `utsushis-charm.exe` and `tesseract-installer.exe` - It does not matter how many you have - I haven't tried to see what would happen if there are clips that are not of the charm UI -3. Open a terminal/command line in the same directory as the "main.py" file. -4. type `python main.py` and press Enter. You might have to run `python3 main.py` -5. The first 2 steps of the program do no require any attention - - They can take a while -6. The third step might ask for your input, depending on how well the image recognition works. +5. Run the `utsushis-charm.exe` (Double-click) +6. A Terminal should pop up + - Wait a little bit, it need to some stuff (~5-15s) +7. The first step of the program should take roughly 1 minute per clip you have in the inputs folder +8. Once that step is done, the second phase starts, normally, it should be done without needing your attention - Follow the instructions on screen and correct any invalid skill names. - If a skill has to be corrected, a window with the skill should open, you might have to alt-tab to it, Windows likes to hide it. - - Sometimes tesseract is absolutely unable to read text, those charms will be logged in [`app.log`](app.log) and you can add them manually. -7. Congrats, you now have your charms under two different forms, - - `charms.json`: JSON (You probably don't care about that) - - `charms.encoded.txt`: This is the one you want -8. Open the `charms.encoded.txt` file and copy the contents in the import box of [MHR-Wiki](https://mhrise.wiki-db.com/sim/?hl=en) - +9. The program is done running. Press Enter and exit. + - Sometimes tesseract is absolutely unable to read text, those charms will be logged in `app.log` and you can add them manually. +10. If no charm errored, or you don't care about those charms, you should be able to open the `charms.encoded.txt` file and copy the contents into the import box of [MHR-Wiki](https://mhrise.wiki-db.com/sim/?hl=en) + + + + +# Troubleshooting + +If the program starts and closes without anything happening, open the `app.log` file and use this section to try and fix your issues + +## Simple issues: +- O charms found + - Make sure your clips are in the inputs folder +- I had to enter skill by hand but it wont accept it + - You need to enter them one word at a time, it might only not know what one of the words is. + - Make sure you are writing it exactly how it is shown on the picture that pops up +- I get through the First phase, but it stops when checking the first frame of + - This is an issue with Tesseract not being installed. Check the next bullet point. +- Google Tesseract is not installed/not found + - Make sure you installed it. You might have to reboot + - Try adding it manually to the path + - Potential Locations: + - `C:\Program Files\Tesseract-OCR` (Most likely, if you chose "Install for anyone") + - `C:\Users\\AppData\Local\Tesseract-OCR` (If you chose "Install only for me") + - `C:\Program Files (x86)\Tesseract-OCR` (Version 4, less likely) + - It seems really random wether it'll add it to path. If there is a request for it, I might add a "bruteforce" method to find the exe so people don't have to worry about this. + + +## Adding something to the path (Windows) + +1. Copy the path to the executable (Where the program was installed) + - Don't put the executable file in the path, only where it is located +2. type `env` in the Windows search bar + - Alternatively type `Edit environment variables for your account` +3. Press Enter +4. Click on `Environment Variables` +5. In `User Variables`, select `Path` +6. Click `Edit` +7. Click `New` +8. Paste the path you copied previously in the new spot. +9. Click `Ok/Apply` for every window you opened. +10. Restart every terminal/command line, or reboot to make sure you'll have access to the new commands # How does this work @@ -117,3 +131,16 @@ In all seriousness, the work is done in a few broad steps: - [ ] Docker image for deployment? - [ ] UI - [ ] Multithreading for some of that SPEEEEED + +# Building the executable +Run the `scripts\build_release.bat` file. You will need to have 7zip in path. + +# Extra command line options +If you run from source, or call the executable from the terminal you can make use of the following flags/arguments to achieve different functionality + +- `-h` or ` --help`: Shows arguments +- `--thirdparty `: Shows 3rd party licenses +- `--skip-frames`: Skips the first frame extraction step. Useful if the second step crashed. +-` --skip-charms`:`Skips the Tesseract-OCR step. Not sure why you would want that. +- `-i ` or `--input `: Changes the Input directory for videos +- `-f ` or `--frames `: Changes the Directory used to store temporary frames \ No newline at end of file diff --git a/skill_dict.freq b/data/skill_dict.freq similarity index 100% rename from skill_dict.freq rename to data/skill_dict.freq diff --git a/skill_list.txt b/data/skill_list.txt similarity index 100% rename from skill_list.txt rename to data/skill_list.txt diff --git a/main.py b/main.py index 7e4a06e..f4ef2fe 100644 --- a/main.py +++ b/main.py @@ -1,28 +1,10 @@ +from src.__main__ import main import os -import json -from frame_extraction import extract_unique_frames -from charm_extraction import extract_charms, save_charms -from charm_encoding import encode_charms +import sys +from src.arg_builder import build_args if __name__ == "__main__": + args = build_args() + main(args) - input_dir = "inputs" - frame_dir = "frames" - charm_json = "charms.json" - - for d in [input_dir, frame_dir]: - os.makedirs(d, exist_ok=True) - - extract_unique_frames(input_dir, frame_dir) - - charms = extract_charms(frame_dir) - - save_charms(charms,charm_json) - print(f"Saved {len(charms)} charms") - - print("Encoding charms") - encode_charms(charm_json) - print("Charms encoded under \"charms.encoded.txt\". Use the contents of that file on the MHR Wiki armor set builder") - - - + input("Press Enter to Exit...") diff --git a/requirements.txt b/requirements.txt index 0cf17bf..26eaed0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,5 @@ numpy scikit-image pytesseract symspellpy -tqdm \ No newline at end of file +tqdm +pyinstaller diff --git a/scripts/build_release.bat b/scripts/build_release.bat new file mode 100644 index 0000000..4c4f522 --- /dev/null +++ b/scripts/build_release.bat @@ -0,0 +1,25 @@ +@echo off +set tesseract_name="tesseract-installer.exe" +set skill_corrections="skill_corrections.csv" +set version=%1 +set version=%version:.=_% + +echo "Building version %version%" + +del Utsushis-Charm.v%version%.zip +rd /s /q "dist" +md dist +md "dist\inputs" + +python -m PyInstaller .\utsushis-charm.spec --onefile + +copy %skill_corrections% "dist\%skill_corrections%" + +if not exist %tesseract_name% ( + echo "Tesseract installer missing, downloading..." + curl https://digi.bib.uni-mannheim.de/tesseract/tesseract-ocr-w64-setup-v4.1.0.20190314.exe -o %tesseract_name% +) + +copy %tesseract_name% "dist\%tesseract_name%" + +7z a -tzip Utsushis-Charm_v%version%.zip ".\dist\*" diff --git a/scripts/check_missing_skills.py b/scripts/check_missing_skills.py index 26245da..cd2f70c 100644 --- a/scripts/check_missing_skills.py +++ b/scripts/check_missing_skills.py @@ -1,13 +1,13 @@ import os all_skills = set() -with open('skill_list.txt') as slf: +with open(os.path.join("data", "skill_list.txt")) as slf: for line in slf.readlines(): skill_name = line.strip() all_skills.add(skill_name) existing = set() -for s_f in os.scandir(os.path.join("images","skills")): +for s_f in os.scandir(os.path.join("images", "skills")): skill = s_f.name.split(".")[0] existing.add(skill) @@ -16,4 +16,4 @@ for skill in sorted(missing): print(f"- {skill}") -print(missing) \ No newline at end of file +print(missing) diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..12ad5ab --- /dev/null +++ b/setup.py @@ -0,0 +1,27 @@ +import os +from setuptools import setup + +with open("README.md") as fid: + README = fid.read() + +with open("requirements.txt") as reqf: + reqs = map(lambda x: x.strip(), reqf.readlines()) + reqs = filter(lambda x: x != "pyinstaller", reqs) + reqs = filter(lambda x: x, reqs) + reqs = list(reqs) + +setup( + name="utsushis-charm", + version="1.0.0", + description="Read the latest Real Python tutorials", + long_description=README, + long_description_content_type="text/markdown", + url="https://github.com/chpoit/utsushis-charm", + author="chpoit", + author_email="chpoit@chpoit.com", + license="MIT", + packages=["src"], + include_package_data=True, + install_requires=reqs, +) + diff --git a/skill_corrections.csv b/skill_corrections.csv index c27c6a0..182b40d 100644 --- a/skill_corrections.csv +++ b/skill_corrections.csv @@ -301,7 +301,6 @@ Flinch,Flinch Fofi“Y,Focus FoI’|W,Focus Focus,Focus -Fofi"Y,Focus Fom"Y,Focus FoI’W,Focus Fortify,Fortify diff --git a/Charm.py b/src/Charm.py similarity index 100% rename from Charm.py rename to src/Charm.py diff --git a/src/__main__.py b/src/__main__.py new file mode 100644 index 0000000..8ff4e2f --- /dev/null +++ b/src/__main__.py @@ -0,0 +1,50 @@ +import os +import sys +from .frame_extraction import extract_unique_frames +from .charm_extraction import extract_charms, save_charms +from .charm_encoding import encode_charms +from .arg_builder import build_args +from .utils import print_licenses +import logging + +logging.basicConfig(filename='app.log', filemode='w', + format='%(name)s - %(levelname)s - %(message)s') + +logger = logging.getLogger(__name__) + + +def main(args): + if args.license: + print_licenses() + sys.exit(0) + + + input_dir = args.input_dir + frame_dir = args.frame_dir + charm_json = "charms.json" + + if input_dir=="inputs": + os.makedirs(input_dir, exist_ok=True) + if frame_dir=="frames": + os.makedirs(frame_dir, exist_ok=True) + + if not args.skip_frames: + extract_unique_frames(input_dir, frame_dir) + + if not args.skip_charms: + charms = extract_charms(frame_dir) + + save_charms(charms, charm_json) + print(f"Saved {len(charms)} charms") + + print("Encoding charms") + encode_charms(charm_json) + print("Charms encoded under \"charms.encoded.txt\". Use the contents of that file on the MHR Wiki armor set builder") + + +if __name__ == "__main__": + try: + args = build_args() + main(args) + except Exception as e: + logger.error(f"Crashed with {e}") diff --git a/src/arg_builder.py b/src/arg_builder.py new file mode 100644 index 0000000..6d3e33f --- /dev/null +++ b/src/arg_builder.py @@ -0,0 +1,18 @@ +import argparse + +def build_args(): + parser = argparse.ArgumentParser() + parser.add_argument('--thirdparty', dest='license', action='store_true', + help='Shows 3rd party licenses') + + parser.add_argument('--skip-frames', dest='skip_frames', action='store_true', + help='Skips the first frame extraction step. Useful if the second step crashed.') + parser.add_argument('--skip-charms', dest='skip_charms', action='store_true', + help='Skips the Tesseract-OCR step. Not sure why you would want that.') + + parser.add_argument("-i", "--input", dest="input_dir", required=False, + help="Changes the Input directory for videos", default='inputs') + parser.add_argument("-f", "--frames", dest="frame_dir", required=False, + help="Changes the Directory used to store temporary frames", default='frames') + + return parser.parse_args() \ No newline at end of file diff --git a/charm_encoding.py b/src/charm_encoding.py similarity index 93% rename from charm_encoding.py rename to src/charm_encoding.py index ad20178..360bf87 100644 --- a/charm_encoding.py +++ b/src/charm_encoding.py @@ -1,5 +1,5 @@ import json -from Charm import Charm +from .Charm import Charm def encode_charms(charm_file): diff --git a/charm_extraction.py b/src/charm_extraction.py similarity index 82% rename from charm_extraction.py rename to src/charm_extraction.py index 4be3aa6..87c3804 100644 --- a/charm_extraction.py +++ b/src/charm_extraction.py @@ -11,8 +11,8 @@ # Level 2: 618, 167 # Level 3: 618, 217 -> Jewels were not removed -from Charm import Charm -from utils import * +from .Charm import Charm +from .utils import * from tqdm import tqdm from symspellpy.symspellpy import SymSpell import numpy as np @@ -23,18 +23,18 @@ DEBUG = False -logging.basicConfig(filename='app.log', filemode='w', - format='%(name)s - %(levelname)s - %(message)s') + logger = logging.getLogger(__name__) if DEBUG: logger.setLevel(logging.DEBUG) spell = SymSpell(max_dictionary_edit_distance=4) -spell.load_dictionary("skill_dict.freq", 0, 1) +spell.load_dictionary(get_resource_path("skill_dict"), 0, 1) + known_corrections = {} -with open('skill_corrections.csv', encoding='utf-8') as scf: +with open(get_resource_path('skill_corrections'), encoding='utf-8') as scf: for line in scf.readlines(): line = line.strip() w, r = line.split(',') @@ -42,7 +42,7 @@ all_skills = {} -with open('skill_list.txt') as slf: +with open(get_resource_path('skill_list')) as slf: for line in slf.readlines(): skill_name = line.strip() all_skills[skill_name.lower()] = skill_name @@ -127,7 +127,7 @@ def extract_charm(frame_loc, slots, skills, skill_text): reconstructed_skill = reconstructed_skill.strip() if "" in reconstructed_skill: - with open("skill_corrections.csv", "a") as scf: + with open(get_resource_path("skill_corrections"), "a") as scf: scf.write(f"{w.strip()},{reconstructed_skill}\n") known_corrections[skill] = reconstructed_skill elif not is_skill(all_skills, reconstructed_skill): @@ -144,7 +144,7 @@ def extract_charm(frame_loc, slots, skills, skill_text): f"Corrected skill: {reconstructed_skill} from {skill}") for w, r in zip(skill.split(), reconstructed_skill.split()): if w not in known_corrections: - with open("skill_corrections.csv", "a", encoding="utf-8") as scf: + with open(get_resource_path("skill_corrections"), "a", encoding="utf-8") as scf: scf.write(f"{w.strip()},{r.strip()}\n") known_corrections[w] = r break @@ -162,27 +162,30 @@ def extract_charm(frame_loc, slots, skills, skill_text): return charm + def extract_charms(frame_dir): charms = [] try: - for frame_loc in tqdm(list(os.scandir(frame_dir)), desc="Parsing skills"): - frame_loc = frame_loc.path - print(f" Parsing {frame_loc}") - frame = cv2.imread(frame_loc) + with tqdm(list(os.scandir(frame_dir)), desc="Parsing skills")as tqdm_iter: + for frame_loc in tqdm_iter: + frame_loc = frame_loc.path + tqdm_iter.set_description(f"Parsing {frame_loc}") + frame = cv2.imread(frame_loc) - skill_only_im = remove_non_skill_info(frame) - slots = get_slots(skill_only_im) + skill_only_im = remove_non_skill_info(frame) + slots = get_slots(skill_only_im) - inverted = cv2.bitwise_not(skill_only_im) + inverted = cv2.bitwise_not(skill_only_im) - trunc_tr = apply_trunc_threshold(inverted) # appears to work best + trunc_tr = apply_trunc_threshold(inverted) # appears to work best - skills = get_skills(trunc_tr, True) + skills = get_skills(trunc_tr, True) - skill_text = read_text_from_skill_tuple(skills) + skill_text = read_text_from_skill_tuple(skills) - charm = extract_charm(frame_loc, slots, skills, skill_text) - charms.append(charm) + charm = extract_charm(frame_loc, slots, skills, skill_text) + charms.append(charm) + except Exception as e: logger.error(f"Crashed with {e}") diff --git a/frame_extraction.py b/src/frame_extraction.py similarity index 93% rename from frame_extraction.py rename to src/frame_extraction.py index f9baf49..0168f8e 100644 --- a/frame_extraction.py +++ b/src/frame_extraction.py @@ -1,13 +1,13 @@ import os import cv2 -from utils import pre_crop_mask, get_charm_borders, only_keep_shiny_border +from .utils import pre_crop_mask, get_charm_borders, only_keep_shiny_border, get_resource_path from tqdm import tqdm from math import floor from skimage.metrics import structural_similarity def extract_unique_frames(input_dir, frame_dir): - overlay_file_name = os.path.join('images', 'mask.png') + overlay_file_name = get_resource_path("mask") charm_count = 0 currentFrame = 0 diff --git a/utils.py b/src/utils.py similarity index 68% rename from utils.py rename to src/utils.py index fadfba5..92da2bf 100644 --- a/utils.py +++ b/src/utils.py @@ -28,7 +28,7 @@ def pre_crop_mask(img, mask_location): def get_charm_borders(img): hsv = [0, 179, 0, 255, 1, 255] - charm_only_filter_path = os.path.join("images", "charm_only.png") + charm_only_filter_path = get_resource_path("charm_only") charm_only_filter = cv2.imread(charm_only_filter_path) lower = np.array([hsv[0], hsv[2], hsv[4]]) @@ -55,7 +55,7 @@ def only_keep_shiny_border(img): def remove_non_skill_info(img): hsv = [0, 179, 0, 255, 142, 255] - skill_only_path = os.path.join("images", "skill_mask.png") + skill_only_path = get_resource_path("skill_mask") skill_filter = cv2.imread(skill_only_path) lower = np.array([hsv[0], hsv[2], hsv[4]]) @@ -115,10 +115,10 @@ def get_slots(img): x2 = x1 + w+1 x3 = x1 + w*2+1 - slot0 = cv2.imread(os.path.join("images", "slots", "slot0.png")) - slot1 = cv2.imread(os.path.join("images", "slots", "slot1.png")) - slot2 = cv2.imread(os.path.join("images", "slots", "slot2.png")) - slot3 = cv2.imread(os.path.join("images", "slots", "slot3.png")) + slot0 = cv2.imread(get_resource_path('slot0')) + slot1 = cv2.imread(get_resource_path('slot1')) + slot2 = cv2.imread(get_resource_path('slot2')) + slot3 = cv2.imread(get_resource_path('slot3')) spot1 = img[y:y + h, x1:x1 + w] spot2 = img[y:y + h, x2:x2 + w] @@ -178,9 +178,9 @@ def _get_levels(img, inverted=False): y1 = 117 y2 = 167 - lv1 = cv2.imread(os.path.join("images", "levels", "lv1.png"), 0) - lv2 = cv2.imread(os.path.join("images", "levels", "lv2.png"), 0) - lv3 = cv2.imread(os.path.join("images", "levels", "lv3.png"), 0) + lv1 = cv2.imread(get_resource_path('lv1'), 0) + lv2 = cv2.imread(get_resource_path('lv2'), 0) + lv3 = cv2.imread(get_resource_path('lv3'), 0) level1 = img[y1:y1 + h, x:x + w] level2 = img[y2:y2 + h, x:x + w] @@ -208,3 +208,48 @@ def _get_levels(img, inverted=False): levels.append(i+1) return levels + + +def get_resource_path(resource): + + return _resources[resource] if resource in _resources else resource + + +def _alter_resource_path(relative_path): + import sys + """ Get absolute path to resource, works for dev and for PyInstaller """ + try: + # PyInstaller creates a temp folder and stores path in _MEIPASS + base_path = sys._MEIPASS + except Exception: + base_path = os.path.abspath(".") + + return os.path.join(base_path, relative_path) + + +def print_licenses(): + print("Third party licenses") + for f in os.scandir(get_resource_path("licences")): + print(f"License for {f.name}") + with open(f.path, "r") as l_f: + print(l_f.read()) + + print("\n\n") + + +_resources = { + 'skill_dict': _alter_resource_path(os.path.join("data", "skill_dict.freq")), + 'skill_list': _alter_resource_path(os.path.join("data", "skill_list.txt")), + 'skill_corrections': "skill_corrections.csv", + 'lv1': _alter_resource_path(os.path.join("images", "levels", "lv1.png")), + 'lv2': _alter_resource_path(os.path.join("images", "levels", "lv2.png")), + 'lv3': _alter_resource_path(os.path.join("images", "levels", "lv3.png")), + 'slot0': _alter_resource_path(os.path.join("images", "slots", "slot0.png")), + 'slot1': _alter_resource_path(os.path.join("images", "slots", "slot1.png")), + 'slot2': _alter_resource_path(os.path.join("images", "slots", "slot2.png")), + 'slot3': _alter_resource_path(os.path.join("images", "slots", "slot3.png")), + 'mask': _alter_resource_path(os.path.join("images", "mask.png")), + 'charm_only': _alter_resource_path(os.path.join("images", "charm_only.png")), + 'skill_mask': _alter_resource_path(os.path.join("images", "skill_mask.png")), + 'licences': _alter_resource_path("LICENSES"), +} diff --git a/utsushis-charm.spec b/utsushis-charm.spec new file mode 100644 index 0000000..83aa411 --- /dev/null +++ b/utsushis-charm.spec @@ -0,0 +1,40 @@ +# -*- mode: python ; coding: utf-8 -*- + + +block_cipher = None + + +a = Analysis(['main.py'], + pathex=['C:\\Users\\chpoit\\Documents\\utsushis-charm'], + binaries=[], + datas=[ + ("images/*", 'images' ), + ("images/levels/*", 'images/levels' ), + ("images/slots/*", 'images/slots' ), + ("data/*", 'data' ), + ("LICENSES/*", 'LICENSES' ), + ], + hiddenimports=[], + hookspath=[], + runtime_hooks=[], + excludes=[], + win_no_prefer_redirects=False, + win_private_assemblies=False, + cipher=block_cipher, + noarchive=False) +pyz = PYZ(a.pure, a.zipped_data, + cipher=block_cipher) +exe = EXE(pyz, + a.scripts, + a.binaries, + a.zipfiles, + a.datas, + [], + name='utsushis-charm', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=True )