staring to integrate TextRecognizer

This commit is contained in:
frankknoll
2022-05-12 11:53:06 +02:00
parent 4c86f7b357
commit 04073c7a38

View File

@@ -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"
},