-
Notifications
You must be signed in to change notification settings - Fork 0
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
Portrait Mode (WIP) #18
base: main
Are you sure you want to change the base?
Conversation
app/src/main/java/co/stonephone/stonecamera/plugins/Portrait.kt
Outdated
Show resolved
Hide resolved
} | ||
} | ||
|
||
fun Bitmap.saveImage(context: Context): Uri? { |
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.
Long term will just overwrite the saved image, but for now i wanna compare
app/src/main/java/co/stonephone/stonecamera/utils/ImageSegmenterHelper.kt
Outdated
Show resolved
Hide resolved
|
||
class ImageSegmenterHelper( | ||
var currentDelegate: Int = DELEGATE_CPU, | ||
var runningMode: RunningMode = RunningMode.IMAGE, |
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.
Can set it to process on a live stream instead of images. I wonder if this will be preferable, performance wise, for the live view & how that would tie into the current plugin model?
- Old approach blurred the whole image & then applied the mask which is significantly more computationally expensive - Also fixing some lint errors
Newly optimised blurring algo takes roughly 700ms on pixel 6a with a large radius of 25 (not including segmentation). Defo further optimisations to be had. Will focus next on shoving it on a background thread & improving the smoothness of the blur |
Also not 100% happy with the visuals of the blur, but can polish this later after getting the images to save in the correct orientation :D |
- Remove some redundant code - General refactoring for readability
stoneCameraViewModel: StoneCameraViewModel, | ||
outputFileResults: ImageCapture.OutputFileResults | ||
) { | ||
val portraitModeSetting = stoneCameraViewModel.getSetting<String>("portraitMode") ?: "OFF" |
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.
Do you think we should do this on a "mode" basis?
E.g. extend the Photo Mode plugin? Then there will be a mode option like most other camera apps?
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.
Yeah I think this would be a good idea. Will make that change
private fun getOriginalImageRotation(contentResolver: ContentResolver, imageUri: Uri): Int { | ||
val exifInputStream = contentResolver.openInputStream(imageUri) | ||
val exif = ExifInterface(exifInputStream!!) | ||
val rotation = when (exif.getAttributeInt( |
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.
Should this be more global for all modes? Perhaps I'm mis-understanding
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.
The image was being spat out sideways after blurring for some reason. No objection to making it more global
) | ||
} | ||
|
||
// Stolen from https://stackoverflow.com/questions/21418892/understanding-super-fast-blur-algorithm?fbclid=IwZXh0bgNhZW0CMTEAAR1w91ucNtw4nU-Z8Z9RyMYFVUHWxfgt7ivsE7foTkwR2wmdx2losQqQ0sk_aem_Zrf_8344PRxW6SFzutkE7g |
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.
"Borrowed from" 😉
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.
Also, isn't there a way we can shift this onto a shader?
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.
Not aware of shaders. will take a look
import com.google.mediapipe.tasks.vision.imagesegmenter.ImageSegmenterResult | ||
|
||
class ImageSegmenterHelper( | ||
var currentDelegate: Int = DELEGATE_CPU, |
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.
Can we make sure we use GPU where possible?
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.
I was having trouble w/ gpu but yes, I agree. Will work on making that happen
} | ||
} | ||
|
||
when(currentModel) { |
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.
Are all the models included in the build at this stage? How do we strip out the ones we're not using?
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.
They are not, have made changes to remove references to other models
Portrait mode with MediaPipe.