FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Portrait Mode (WIP) by IzaakBH · Pull Request #18 · ThePhoneProject/advanced-android-camera · GitHub

Portrait Mode (WIP) - #18

Draft
IzaakBH wants to merge 30 commits into
mainfrom
portrait-mediapipe
Draft

Portrait Mode (WIP)#18
IzaakBH wants to merge 30 commits into
mainfrom
portrait-mediapipe

Conversation

IzaakBH commented Jan 12, 2025
edited
Loading

Copy link
Copy Markdown
Collaborator

Portrait mode with MediaPipe.

}
}

fun Bitmap.saveImage(context: Context): Uri? {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Long term will just overwrite the saved image, but for now i wanna compare


class ImageSegmenterHelper(
var currentDelegate: Int = DELEGATE_CPU,
var runningMode: RunningMode = RunningMode.IMAGE,

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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?

ISNIT0 mentioned this pull request Jan 13, 2025
ISNIT0 marked this pull request as draft January 13, 2025 08:43
- Old approach blurred the whole image & then applied the mask which is significantly more computationally expensive
- Also fixing some lint errors

IzaakBH commented Jan 13, 2025

Copy link
Copy Markdown
Collaborator Author

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

IzaakBH commented Jan 13, 2025

Copy link
Copy Markdown
Collaborator Author

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

stoneCameraViewModel: StoneCameraViewModel,
outputFileResults: ImageCapture.OutputFileResults
) {
val portraitModeSetting = stoneCameraViewModel.getSetting<String>("portraitMode") ?: "OFF"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Should this be more global for all modes? Perhaps I'm mis-understanding

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

"Borrowed from" 😉

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Also, isn't there a way we can shift this onto a shader?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Not aware of shaders. will take a look

import com.google.mediapipe.tasks.vision.imagesegmenter.ImageSegmenterResult

class ImageSegmenterHelper(
var currentDelegate: Int = DELEGATE_CPU,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Can we make sure we use GPU where possible?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I was having trouble w/ gpu but yes, I agree. Will work on making that happen

}
}

when(currentModel) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Are all the models included in the build at this stage? How do we strip out the ones we're not using?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

They are not, have made changes to remove references to other models

This file contains hidden or 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
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


Back | FazBrowse Home | New Git URL