Skip to content
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

Add a FlatShape interface to allow manipulating the detected shapes in a unified way #480

Merged
merged 1 commit into from
Nov 11, 2022

Conversation

juliabeliaeva
Copy link
Contributor

Adding a common interface allows to simplify writing code like this:

private fun <T : FlatShape<T>> T.flip(): T {
    return map { x, y -> 1 - x to y }
}

private fun <T : FlatShape<T>> T.flipIfNeeded(isImageFlipped: Boolean): T {
    if (isImageFlipped) return flip()
    return this
}

Flipping detection results horizontally is used on Android when the front camera is used.

@juliabeliaeva
Copy link
Contributor Author

At the same time, this could be done with the when statement, and when is still used when drawing detection results in the Android demo app. So I'm not sure how necessary this is. @ermolenkodev what do you think?

@ermolenkodev
Copy link
Collaborator

I like it! I think the nice API is the main selling point of this library so this change fits perfectly

@juliabeliaeva juliabeliaeva merged commit 57ab688 into Kotlin:master Nov 11, 2022
@juliabeliaeva juliabeliaeva deleted the flat-shape branch November 11, 2022 23:16
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.

2 participants