This file contains hidden or 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
// set no compress for tflite | |
compileOptions { | |
sourceCompatibility JavaVersion.VERSION_1_8 | |
targetCompatibility JavaVersion.VERSION_1_8 | |
} | |
android { | |
aaptOptions { | |
noCompress "tflite" |
This file contains hidden or 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:id="@+id/frameLayout" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context=".ClassificationActivity"> |
This file contains hidden or 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
package com.example.funitureclassifier | |
import android.app.Activity | |
import android.graphics.Bitmap | |
import android.graphics.RectF | |
import com.example.funitureclassifier.Keys.IMAGE_MEAN | |
import com.example.funitureclassifier.Keys.IMAGE_STD | |
import com.example.funitureclassifier.Keys.LABEL_FILENAME | |
import com.example.funitureclassifier.Keys.MAX_RESULTS |
This file contains hidden or 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
inner class Classify: ImageAnalysis.Analyzer { | |
@SuppressLint("SetTextI18n") | |
override fun analyze(imageProxy: ImageProxy?, rotationDegrees: Int) { | |
// get bitmap from the camera finder view | |
val imgBitmap = rotateImage(viewFinder.bitmap, | |
rotationDegrees.toFloat()) | |
val recognitions = imageClassifier!!.classifyImage( | |
imgBitmap, rotationDegrees) | |
runOnUiThread { | |
val empty = " " |
This file contains hidden or 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 startCamera() { | |
CameraX.unbindAll() | |
val previewConfig = PreviewConfig.Builder().apply { | |
setTargetResolution(Size(1920, 1080)) | |
setTargetRotation(viewFinder.display.rotation) | |
}.build() | |
// Build the viewFinder use case | |
val preview = Preview(previewConfig) |
This file contains hidden or 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
package com.example.funitureclassifier | |
import android.graphics.Bitmap | |
import android.graphics.BitmapFactory | |
import android.graphics.Matrix | |
import android.media.Image | |
import androidx.camera.core.ImageAnalysis | |
import androidx.camera.core.ImageProxy | |
This file contains hidden or 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
class ClassicficationActivity : AppCompatActivity() { | |
private val REQUEST_CAMERA_CODE = 13 | |
private val PERMISSIONS = arrayOf(Manifest.permission.CAMERA) | |
private val executor = Executors.newSingleThreadExecutor() | |
private var textResult1: TextView? = null | |
private var textResult2: TextView? = null | |
private var textResult3: TextView? = null |
This file contains hidden or 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 startCamera() { | |
CameraX.unbindAll() | |
val previewConfig = PreviewConfig.Builder().apply{ | |
setTargetResolution(Size(680, 400 )) | |
setTargetRotation(viewFinder.display.rotation) | |
}.build() | |
// Build the viewFinder use case | |
val preview = Preview(previewConfig) |
This file contains hidden or 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
class ImageClassifier() AppCompatActivity{ | |
var bundle: Bundle? = null | |
} |
This file contains hidden or 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
import pandas as pd | |
import matplotlib.pyplot as plt |