-
Notifications
You must be signed in to change notification settings - Fork 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
CameraX support #4
Comments
Same issue. Looking for ImageAnalyzer's ImageProxy.image to RGB conversion solution. Spent some days on this, still nothing.. |
just add two extra constructors data class Yuv(
val resource: AutoCloseable? = null,
val width: Int,
val height: Int,
val y: Plane,
val u: Plane,
val v: Plane) : YuvPlanes, AutoCloseable {
constructor(image: Image) : this(
resource = image,
width = image.width,
height = image.height,
y = Plane(image.planes[0]),
u = Plane(image.planes[1]),
v = Plane(image.planes[2])) {
require(image.format == ImageFormat.YUV_420_888)
require(image.width % 2 == 0)
require(image.height % 2 == 0)
}
// here
constructor(image: ImageProxy) : this(
resource = image,
width = image.width,
height = image.height,
y = Plane(image.planes[0]),
u = Plane(image.planes[1]),
v = Plane(image.planes[2])) {
require(image.format == ImageFormat.YUV_420_888)
require(image.width % 2 == 0)
require(image.height % 2 == 0)
}
data class Plane(
val buffer: ByteBuffer,
val pixelStride: Int,
val rowStride: Int) {
constructor(plane: Image.Plane) : this(
buffer = plane.buffer,
pixelStride = plane.pixelStride,
rowStride = plane.rowStride)
// and here
constructor(plane: ImageProxy.PlaneProxy) : this(
buffer = plane.buffer,
pixelStride = plane.pixelStride,
rowStride = plane.rowStride)
}
override fun close() {
resource?.close()
}
val rows = this.height
val cols = this.width
/**
* For java API call site
*/
companion object {
@JvmStatic
fun rgb(image: Image) = image.rgb()
@JvmStatic
fun rgb(image: ImageProxy) = image.rgb()
}
} |
but implementation in this repo is not correct, look at #5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
CameraX api has ImageProxy class which you obtain from ImageAnalyzer. It has the same api as usual Image. So adding support is just duplicating several constructors. And I would create pull request, but…
The difficult part, I think, this feature should be in separate package. If someone don't use CameraX in his/her project won't have to download it.
The text was updated successfully, but these errors were encountered: