From 04073c7a3851f96fc4a0e06354e51a75b0ecbfd8 Mon Sep 17 00:00:00 2001 From: frankknoll Date: Thu, 12 May 2022 11:53:06 +0200 Subject: [PATCH] staring to integrate TextRecognizer --- src/HowBadIsMyBatch.ipynb | 85 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 84 insertions(+), 1 deletion(-) diff --git a/src/HowBadIsMyBatch.ipynb b/src/HowBadIsMyBatch.ipynb index 47b9af2513b..7e8403701c4 100644 --- a/src/HowBadIsMyBatch.ipynb +++ b/src/HowBadIsMyBatch.ipynb @@ -78,6 +78,89 @@ "print('needsUpdate:', needsUpdate)" ] }, + { + "cell_type": "markdown", + "id": "f3f94f5a", + "metadata": {}, + "source": [ + "## Solve CAPTCHA" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c2d1f298", + "metadata": {}, + "outputs": [], + "source": [ + "baseDir = \"~/AndroidStudioProjects/TextRecognizer\"\n", + "\n", + "def detectTextInImage(captchaImage):\n", + " ! cp $captchaImage $baseDir/app/src/main/assets/captchas/captcha_image.jpeg\n", + " ! cd $baseDir;./gradlew connectedAndroidTest\n", + " textInImage = ! adb shell \"run-as org.textrecognizer cat /data/data/org.textrecognizer/files/captcha_image.txt\"\n", + " return textInImage" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "3be7e021", + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "\n", + "def startEmulator():\n", + " os.system(\"/home/frankknoll/Android/Sdk/emulator/emulator -avd Pixel_2_API_30 -no-window &\")\n", + " \n", + "def stopEmulator():\n", + " ! adb emu kill" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fb3755a6", + "metadata": {}, + "outputs": [], + "source": [ + "startEmulator()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c113e49d", + "metadata": {}, + "outputs": [], + "source": [ + "textByImage = {}\n", + "for i in range(1, 2):\n", + " captchaImage = \"captchaImage\" + str(i) + \".jpeg\"\n", + " textByImage[captchaImage] = detectTextInImage(\"/home/frankknoll/Dokumente/Corona/CAPTCHA/images/VAERS/\" + captchaImage)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "cdf3fbe1", + "metadata": {}, + "outputs": [], + "source": [ + "stopEmulator()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6ba0ad8e", + "metadata": {}, + "outputs": [], + "source": [ + "textByImage" + ] + }, { "cell_type": "code", "execution_count": null, @@ -1020,7 +1103,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3.10.4 64-bit", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" },