Skip to content

Instantly share code, notes, and snippets.

@makorowy
makorowy / Result.kt
Created February 25, 2018 19:07
TensorFlow - Hot or Not example. Result data class.
data class Result(val result: String, val confidence: Float)
@makorowy
makorowy / Classifier.kt
Created February 25, 2018 19:07
TensorFlow - Hot or Not example. Creating a classifier interface.
interface Classifier {
fun recognizeImage(bitmap: Bitmap): Result
}
@makorowy
makorowy / MainActivity.kt
Created February 25, 2018 19:04
TensorFlow - Hot or Not example. Creating a classifier.
class MainActivity : AppCompatActivity() {
private lateinit var classifier: Classifier
//other properties
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
checkPermissions()
@makorowy
makorowy / UriHelper.kt
Created February 25, 2018 18:46
TensorFlow - Hot or Not example. Creating an Uri from a file path.
object UriHelper {
fun getUriFromFilePath(context: Context, filePath: String): Uri {
val file = File(filePath)
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
FileProvider.getUriForFile(
context,
context.applicationContext.packageName + ".uri",
file)
} else {
@makorowy
makorowy / MainActivity.kt
Last active February 25, 2018 18:29
TensorFlow - Hot or Not example. Taking a photo.
private const val REQUEST_PERMISSIONS = 1
private const val REQUEST_TAKE_PICTURE = 2
class MainActivity : AppCompatActivity() {
private var photoFilePath = ""
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)