This file contains 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 FaceDetector(private val callback: DetectorCallback?) : IFrameProcessor { | |
interface DetectorCallback { | |
fun onSuccess(frameData: ByteBuffer, results: List<FirebaseVisionFace>, frameMetadata: FrameMetadata) | |
fun onFailure(exception: Exception) | |
} | |
companion object { | |
private const val TAG = "FaceDetector" | |
} |
This file contains 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 MLKitActivity : AbstractActivity() { | |
companion object { | |
private const val TAG = "MLKitActivity" | |
} | |
private var mCameraSource: MLCameraSource? = null | |
/** | |
* Creates and starts the camera. |
This file contains 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 GoogleVisionActivity : AbstractActivity() { | |
companion object { | |
private const val TAG = "GoogleVisionActivity" | |
} | |
private var mCameraSource: GVCameraSource? = null | |
private lateinit var mDetector: SaveFrameFaceDetector | |
/** |
This file contains 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 SaveFrameFaceDetector(private val delegateDetector: Detector<Face>) : Detector<Face>() { | |
var lastFrame: Frame? = null | |
override fun detect(frame: Frame): SparseArray<Face> { | |
lastFrame = frame | |
return delegateDetector.detect(frame) | |
} | |
override fun isOperational(): Boolean { |
This file contains 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"?> | |
<devnibbles.android.facialrecognition.common.CameraSourcePreview | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
android:id="@+id/preview" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"> | |
<devnibbles.android.facialrecognition.common.GraphicOverlay | |
android:id="@+id/faceOverlay" | |
android:layout_width="match_parent" |
This file contains 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
interface ICameraSource { | |
fun previewSize(): Size? | |
fun cameraFacing(): Int | |
fun release() | |
@Throws(IOException::class) | |
fun start(surfaceHolder: SurfaceHolder) |
This file contains 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 GVCameraSource(context: Context, detector: Detector<*>) : ICameraSource { | |
private val delegate = CameraSource.Builder(context, detector) | |
.setRequestedPreviewSize(640, 480) | |
.setFacing(GraphicOverlay.CAMERA_FACING_FRONT) | |
.setRequestedFps(15.0f) | |
.build() | |
override fun previewSize(): Size? { | |
return delegate.previewSize |
This file contains 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 CameraSourcePreview(private val mContext: Context, attrs: AttributeSet) : ViewGroup(mContext, attrs) { | |
companion object { | |
private const val TAG = "CameraSourcePreview" | |
} | |
private val mSurfaceView: SurfaceView | |
private var mStartRequested: Boolean = false | |
private var mSurfaceAvailable: Boolean = false | |
private var mCameraSource: ICameraSource? = null |
This file contains 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
'use strict'; | |
process.env.DEBUG = 'actions-on-google:*'; | |
const Assistant = require('actions-on-google').ApiAiAssistant; | |
exports.myAction = (req, res) => { | |
const assistant = new Assistant({request: req, response: res}); | |
console.log('Request headers: ' + JSON.stringify(req.headers)); | |
console.log('Request body: ' + JSON.stringify(req.body)); |
This file contains 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.swizel.android.widget; | |
import android.Manifest; | |
import android.content.Context; | |
import android.content.pm.PackageManager; | |
import android.graphics.ImageFormat; | |
import android.hardware.Camera; | |
import android.hardware.Camera.Parameters; | |
import android.support.v4.content.ContextCompat; | |
import android.util.AttributeSet; |