-
Notifications
You must be signed in to change notification settings - Fork 408
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
Rotation degrees of Frame object is incorrect #253
Comments
When I try, it is not always 270. When Im in Portrait Mode it shows 270 when it should actually be 90. When I rotate clockwise to 180, it shows correctly 180. So in my case it shows 270 when its is actually 90. And it shows 90 when it is actually 270. So these two are somehow flipped. 0 degress and 180 works correct. |
@siralam it does seem to be a bug. Most likely the same as #262 @AlCabohne are you using the front or the rear camera? |
@dmitry-zaitsev Im using the rear camera (main camera) |
Any news on this? Can I assume that it's always off by 180 degrees on every device? Or is this device specifid? |
While further observing I have exactly the behavior @AlCabohne descriped. I don't understand the code base but this looked like a smell: Fotoapparat/fotoapparat/src/main/java/io/fotoapparat/routine/camera/StartRoutine.kt Line 49 in b55ebc6
setDisplayOrientation(
orientationState = OrientationState(
deviceOrientation = Orientation.Vertical.Portrait,
screenOrientation = getScreenOrientation()
)
) here upon start it's hardcoded. |
is there any update? Have you fixed the issue or not? |
I solved rotation problem @ frame process with following codes, it might be little outof scope of this ticket, however, it would help you a little. **Front ** override fun process(frame: Frame) {
Log.d(TAG, "frame: ${frame.image.size}, ${frame.size}")
YuvImage(
frame.image,
ImageFormat.NV21,
frame.size.width,
frame.size.height,
null
).let { yuvImage ->
ByteArrayOutputStream().use { output ->
yuvImage.compressToJpeg(
Rect(0, 0, frame.size.width, frame.size.height),
100,
output
)
output.toByteArray().apply {
BitmapFactory.decodeByteArray(this, 0, size)?.let { bitmap ->
process(bitmap.rotate(90f).flip(false, true))
bitmap.recycle()
}
}
}
}
}
private fun Bitmap.flip(horizontal: Boolean, vertical: Boolean): Bitmap {
val matrix = Matrix()
matrix.preScale((if (horizontal) -1 else 1).toFloat(), (if (vertical) -1 else 1).toFloat())
return Bitmap.createBitmap(this, 0, 0, width, height, matrix, true)
}
private fun Bitmap.rotate(degrees: Float): Bitmap {
val matrix = Matrix()
matrix.postRotate(degrees)
val scaledBitmap = Bitmap.createScaledBitmap(this, width, height, true);
return Bitmap.createBitmap(
scaledBitmap,
0,
0,
scaledBitmap.width,
scaledBitmap.height,
matrix,
true
)
}
|
@XinyueZ The issue is not how to rotate a yuv array, the issue is that the given rotation of the frame is not the actual rotation. |
Still no fix for this issue? Im getting always |
Also seeing the samples you do this "hack": That comes from your |
@siralam image orientation might differ from device orientation all because the camera hardware sensor can be mounted in whatever rotation a vendor decided. Hence, we can't guarantee what the rotation of the image will be. However, that is exactly why we are providing you rotation in degrees as part of the frame. @FireZenk you can read EXIF information from the file - it contains information about image orientation. Setting image rotation via |
Why is this closed?
The issue is that the orientation is always 270. |
Not sure if this is by design or a bug,
The rotation value of a Frame obtained in
FrameProcessor.process(Frame frame)
is always 270, even if the device is held in landscape (But OS is in portrait mode)Of course, if I made the activity / device setting rotatable, the activity is recreated with a new orientation, and now the rotation degree is correct.
However, this is not a good camera app UX since user would feel significant freeze when the activity is rotating.
I would definitely want the frame to have correct rotation degrees without changing activity orientation.
So... is it a bug or you expect us to implement by ourselves using orientation sensor?
(I suspect it is a bug more than by design because, same thing does not happen in taking a picture, so it means you did detect rotation using orientation sensor in your library. Probably just didn't implemented for Frame.)
The text was updated successfully, but these errors were encountered: