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 ConsentsView @JvmOverloads constructor( | |
| context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 | |
| ) : LinearLayout(context, attrs, defStyleAttr) { | |
| var onConsentsCheckedChangeListener: (allConsentsChecked: Boolean) -> Unit = {} | |
| init { | |
| LayoutInflater.from(context).inflate(R.layout.consents_view, this, true) | |
| consent1.setOnCheckedChangeListener { _, _ -> validateConsents() } |
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"?> | |
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| android:orientation="vertical" | |
| android:gravity="center"> | |
| <TextView | |
| android:id="@+id/consentsTitle" | |
| android:layout_width="wrap_content" |
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"?> | |
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:tools="http://schemas.android.com/tools" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| android:gravity="center" | |
| android:orientation="vertical" | |
| tools:context=".MainActivity"> | |
| <include |
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 MainActivity : AppCompatActivity() { | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.activity_main) | |
| consent1.setOnCheckedChangeListener { _, _ -> validateConsents() } | |
| consent2.setOnCheckedChangeListener { _, _ -> validateConsents() } | |
| } |
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"?> | |
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:tools="http://schemas.android.com/tools" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| android:gravity="center" | |
| android:orientation="vertical" | |
| tools:context=".MainActivity"> | |
| <TextView |
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 MainActivity : AppCompatActivity { | |
| //... | |
| private fun classifyAndShowResult(croppedBitmap: Bitmap) { | |
| runInBackground( | |
| Runnable { | |
| val result = classifier.recognizeImage(croppedBitmap) | |
| showResult(result) | |
| }) |
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 const val ENABLE_LOG_STATS = false | |
| class ImageClassifier ( | |
| private val inputName: String, | |
| private val outputName: String, | |
| private val imageSize: Long, | |
| private val labels: List<String>, | |
| private val imageBitmapPixels: IntArray, | |
| private val imageNormalizedPixels: FloatArray, | |
| private val results: FloatArray, |
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
| object ImageClassifierFactory { | |
| fun create( | |
| assetManager: AssetManager, | |
| graphFilePath: String, | |
| labelsFilePath: String, | |
| imageSize: Int, | |
| inputName: String, | |
| outputName: String | |
| ): Classifier { |
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 MainActivity : AppCompatActivity { | |
| //... | |
| private val handler = Handler() | |
| private var photoFilePath = "" | |
| override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { | |
| val file = File(photoFilePath) | |
| if (requestCode == REQUEST_TAKE_PICTURE && file.exists()) { | |
| classifyPhoto(file) |
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
| const val GRAPH_FILE_PATH = "file:///android_asset/graph.pb" | |
| const val LABELS_FILE_PATH = "file:///android_asset/labels.txt" | |
| const val GRAPH_INPUT_NAME = "input" | |
| const val GRAPH_OUTPUT_NAME = "final_result" | |
| const val IMAGE_SIZE = 224 |