-
Notifications
You must be signed in to change notification settings - Fork 80
added callbacks for face detection result in activity #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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.
@@ -46,6 +47,7 @@ class FaceBoundsOverlay @JvmOverloads constructor(ctx: Context, attrs: Attribute | |||
canvas.drawId(faceBounds.id.toString(), faceBounds.box.center()) | |||
canvas.drawBounds(faceBounds.box) | |||
} | |||
Log.e("faces", "draw ${facesBounds.size}") |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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}") |
There was a problem hiding this comment.
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()}") |
There was a problem hiding this comment.
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()}]
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
|
||
val lensFacing = | ||
savedInstanceState?.getSerializable(KEY_LENS_FACING) as Facing? ?: Facing.BACK | ||
val lensFacing = Facing.FRONT |
There was a problem hiding this comment.
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.
viewfinder.facing = lensFacing | ||
viewfinder.rotation = 180f |
There was a problem hiding this comment.
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?
viewfinder.addFrameProcessor { | ||
faceDetector.process( | ||
Frame( | ||
data = it.data, | ||
rotation = it.rotation, | ||
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 |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
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.