This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
implementation 'com.google.android.gms:play-services-mlkit-text-recognition:16.1.3' | |
implementation 'com.github.bumptech.glide:glide:4.11.0' | |
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="com.ibrahim.mlkit"> | |
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" | |
android:maxSdkVersion="18"/> | |
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | |
<uses-feature | |
android:name="android.hardware.camera" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<paths xmlns:android="http://schemas.android.com/apk/res/android"> | |
<external-path name="my_images" path="Android/data/com.ibrahim.mlkit/files/Pictures" /> | |
</paths> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context=".MainActivity"> | |
<ImageView | |
android:id="@+id/text_image" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun camera(){ | |
val takePictureIntent = Intent(MediaStore.ACTION_IMAGE_CAPTURE) | |
if (takePictureIntent.resolveActivity( | |
packageManager | |
) != null | |
) { | |
var photoFile: File? = null | |
try { | |
photoFile = createImageFile() | |
} catch (ex: IOException) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { | |
super.onActivityResult(requestCode, resultCode, data) | |
if (resultCode != RESULT_CANCELED) { | |
if (requestCode == PICK_IMAGE) { | |
data?.data?.let { | |
bitmap = null | |
bitmap = getBitmapFromUri(it) | |
Glide.with(this) | |
.load(bitmap) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun pickImage() { | |
val intent = Intent() | |
intent.type = "image/*" | |
intent.action = Intent.ACTION_GET_CONTENT | |
startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun detectImage() { | |
val recognizer = TextRecognition.getClient() | |
bitmap?.let { | |
val image = InputImage.fromBitmap(it, 0) | |
recognizer.process(image) | |
.addOnSuccessListener { visionText -> | |
Toast.makeText(this, visionText.text, Toast.LENGTH_SHORT).show() | |
} | |
.addOnFailureListener { e -> | |
Toast.makeText(this, "Error: " + e.message, Toast.LENGTH_SHORT).show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="com.ibrahim.volleyrequests"> | |
<uses-permission android:name="android.permission.INTERNET"/> | |
<application | |
android:usesCleartextTraffic="true" | |
... | |
</application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:orientation="vertical" | |
android:gravity="center" | |
tools:context=".MainActivity"> |