1.6 到 2.1 CameraInfo 的替代品?
android.Camera.Preferences.setRotation 文档
public void onOrientationChanged(int orientation) {
if (orientation == ORIENTATION_UNKNOWN) return;
android.hardware.Camera.CameraInfo info =
new android.hardware.Camera.CameraInfo();
android.hardware.Camera.getCameraInfo(cameraId, info);
orientation = (orientation + 45) / 90 * 90;
int rotation = 0;
if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
rotation = (info.orientation - orientation + 360) % 360;
} else { // back-facing camera
rotation = (info.orientation + orientation) % 360;
}
mParameters.setRotation(rotation);
}
在 API 级别 5(或更好,甚至是 4)中是否有 Camera.CameraInfo 的替代方案?我正在尝试设置捕获图像的旋转,但不知道如何获取设备相机的方向。 API 9 级之前所有相机的方向都是固定的还是什么?
android.Camera.Preferences.setRotation documentation
public void onOrientationChanged(int orientation) {
if (orientation == ORIENTATION_UNKNOWN) return;
android.hardware.Camera.CameraInfo info =
new android.hardware.Camera.CameraInfo();
android.hardware.Camera.getCameraInfo(cameraId, info);
orientation = (orientation + 45) / 90 * 90;
int rotation = 0;
if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
rotation = (info.orientation - orientation + 360) % 360;
} else { // back-facing camera
rotation = (info.orientation + orientation) % 360;
}
mParameters.setRotation(rotation);
}
is there an alternative to Camera.CameraInfo in API level 5 (or better yet even 4)? I am trying to set the rotation of the captured image and I cannot figure out how to get the orientation of the device's camera. pre API level 9 was all camera's orientation fixed or something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,目前 Android 平台上的相机方向确实很混乱。
即使您在我的应用程序中通过相机信息获得的方向并不总是正确的(至少对我来说),我让用户选择是否要使用应用程序设置中的参数旋转相机
No the camera orientation is at the current status a real mess on Android platform.
Even the orientation you get with the camera info is not always the right one (at least for me) in my app i'm letting the user choose if he wants to rotate the camera with a parameter in the settings of the app