Skip to content

Commit 2c63d95

Browse files
committed
Commit (1) Face Detection
1 parent dc73cb8 commit 2c63d95

File tree

12 files changed

+723
-20
lines changed

12 files changed

+723
-20
lines changed

.idea/misc.xml

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

+333-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

android/src/main/java/com/example/firebase_mlvision/FaceDetection/FaceDetectionActivity.kt

+331
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.example.firebase_mlvision
2+
import android.annotation.SuppressLint
3+
import android.content.Context
4+
import android.support.v7.widget.RecyclerView
5+
import android.view.LayoutInflater
6+
import android.view.View
7+
import android.view.ViewGroup
8+
import android.widget.TextView
9+
import com.example.firebase_mlvision.R
10+
11+
class FaceDetectionAdapter(private val context: Context, private val faceDetectionModels: List<FaceDetectionModel>) : RecyclerView.Adapter<FaceDetectionAdapter.FaceDetectionViewHolder>() {
12+
13+
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): FaceDetectionViewHolder {
14+
return FaceDetectionViewHolder(LayoutInflater.from(context).inflate(R.layout.item_face_detection, parent, false))
15+
}
16+
17+
@SuppressLint("SetTextI18n")
18+
override fun onBindViewHolder(holder: FaceDetectionViewHolder, position: Int) {
19+
holder.text1.text = "Face${faceDetectionModels[position].id}"
20+
holder.text2.text = faceDetectionModels[position].text
21+
}
22+
23+
override fun getItemCount() = faceDetectionModels.size
24+
25+
class FaceDetectionViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
26+
val view = itemView
27+
val text1 = itemView.findViewById<TextView>(R.id.item_face_detection_text_view1)!!
28+
val text2 = itemView.findViewById<TextView>(R.id.item_face_detection_text_view2)!!
29+
}
30+
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package com.example.firebase_mlvision.FaceDetection
2+
3+
data class FaceDetectionModel(val id: Int, val text: String?)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Asphalt
2+
Pothole
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"modelFile": "model.tflite",
3+
"labelsFile": "dict.txt",
4+
"modelType": "IMAGE_LABELING"
5+
}
5.58 MB
Binary file not shown.

example/android/app/build.gradle

+6
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ android {
3131
disable 'InvalidPackage'
3232
}
3333

34+
aaptOptions {
35+
noCompress "tflite"
36+
}
37+
3438
defaultConfig {
3539
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
3640
applicationId "com.example.firebase_mlvision_example"
@@ -58,4 +62,6 @@ dependencies {
5862
testImplementation 'junit:junit:4.12'
5963
androidTestImplementation 'com.android.support.test:runner:1.0.2'
6064
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
65+
implementation 'com.google.firebase:firebase-ml-vision:20.0.0'
66+
implementation 'com.google.firebase:firebase-ml-vision-automl:16.0.0'
6167
}

example/android/app/src/main/AndroidManifest.xml

+5-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
FlutterApplication and put your custom class here. -->
99
<application
1010
android:name="io.flutter.app.FlutterApplication"
11-
android:label="firebase_mlvision_example"
12-
android:icon="@mipmap/ic_launcher">
11+
android:label="firebase_mlvision_example">
12+
//android:icon="@mipmap/ic_launcher" >
1313
<activity
1414
android:name=".MainActivity"
1515
android:launchMode="singleTop"
@@ -23,7 +23,9 @@
2323
defined in @style/LaunchTheme). -->
2424
<meta-data
2525
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
26-
android:value="true" />
26+
android:value="true"
27+
android:name="com.google.firebase.ml.vision.DEPENDENCIES"
28+
android:value="face"/>
2729
<intent-filter>
2830
<action android:name="android.intent.action.MAIN"/>
2931
<category android:name="android.intent.category.LAUNCHER"/>

example/android/build.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ buildscript {
66

77
dependencies {
88
classpath 'com.android.tools.build:gradle:3.2.1'
9+
implementation 'com.google.firebase:firebase-ml-vision:20.0.0'
10+
implementation 'com.google.firebase:firebase-ml-vision-automl:16.0.0'
911
}
1012
}
1113

firebase_mlvision.iml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
<excludeFolder url="file://$MODULE_DIR$/example/.pub" />
1212
<excludeFolder url="file://$MODULE_DIR$/example/build" />
1313
</content>
14+
<orderEntry type="inheritedJdk" />
1415
<orderEntry type="sourceFolder" forTests="false" />
15-
<orderEntry type="library" name="Dart Packages" level="project" />
1616
<orderEntry type="library" name="Dart SDK" level="project" />
1717
<orderEntry type="library" name="Flutter Plugins" level="project" />
1818
</component>

0 commit comments

Comments
 (0)