Skip to content

Conversation

@MiRobotic
Copy link

while using face detection, developer may need to do something when face detected in camera. hence i added callbacks for face detection process in main activity. if you find this helpful then you can accept this pull request.

thanks.

Copy link
Owner

@husaynhakeem husaynhakeem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pull request! Appreciate the help.
A few changes and it'll be good to merge.

canvas.drawId(faceBounds.id.toString(), faceBounds.box.center())
canvas.drawBounds(faceBounds.box)
}
Log.e("faces", "draw ${facesBounds.size}")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a log message here makes sense, but instead of an error log message, it should be an info or debug message, so Log.d or Log.i. Also, could you add a static log tag to the class, something like:

companion object {
    private const val TAG = "FaceBoundsOverlay"
}

Then use it for the logging.

Log.d(TAG, "Drawing ${facesBounds.size}")

mainExecutor.execute { faceBoundsOverlay.updateFaces(faceBounds) }
mainExecutor.execute {
faceBoundsOverlay.updateFaces(faceBounds)
onFaceDetectionResultListener?.onSuccess(faceBounds)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this!


override fun onSuccess(faceBounds: List<FaceBounds>) {
super.onSuccess(faceBounds)
Log.e(TAG,"total faces ${faceBounds.size}")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't an error, it shouldn't use Log.e, instead an info or debug log should be used.

Also, please make sure to format the file after you're done (a space is missing before the log message).

super.onSuccess(faceBounds)
Log.e(TAG,"total faces ${faceBounds.size}")
for (face in faceBounds) {
Log.d(TAG, "face ${face.id} ${face.box.width()} ${face.box.height()}")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One little change here, could you format the log message to be

face ${face.id} [${face.box.width()}, ${face.box.height()}]


val lensFacing =
savedInstanceState?.getSerializable(KEY_LENS_FACING) as Facing? ?: Facing.BACK
val lensFacing = Facing.FRONT
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lensFacing is saved in onSaveInstanceState(). Please revert setting it here to use the saved instance state.

val faceDetector = FaceDetector(faceBoundsOverlay)
faceDetector.setonFaceDetectionFailureListener(onFaceDetectionResultListener)
viewfinder.facing = lensFacing
viewfinder.rotation = 180f
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you rotating the viewfinder?

size = Size(it.size.width, it.size.height),
format = it.format,
lensFacing = if (viewfinder.facing == Facing.BACK) LensFacing.BACK else LensFacing.FRONT
lensFacing = LensFacing.FRONT
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you set the value of the frame's lensFacing parameter to the variable lensFacing?

)
}

toggleCameraButton.setOnClickListener {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert removing these lines.


}

//111.375 338.5481
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this line and the one below it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants