Skip to content

Instantly share code, notes, and snippets.

View kongkip's full-sized avatar
💭
Making cool things uncool

Evans Kiplagat kongkip

💭
Making cool things uncool
View GitHub Profile
// set no compress for tflite
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
android {
aaptOptions {
noCompress "tflite"
<?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">
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
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 = " "
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)
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
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
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)
class ImageClassifier() AppCompatActivity{
var bundle: Bundle? = null
}
import pandas as pd
import matplotlib.pyplot as plt