Android摄像头伸在横向模式横向、摄像头、模式、Android

2023-09-05 00:01:41 作者:记忆深埋那片心海

该应用程序我正在写需要拍摄功能。 因此,要了解如何操作相机,我跟着这个脚本:

The app I'm writing requires camera functionality. So to learn about how to operate the camera, I followed this script:

http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/Camera$p$pview.html

我已经把该活动在我的表现,因为它在横向模式下设置的屏幕方向。

I have put the activity in my manifest, set the screen orientation for it on landscape mode.

我遇到的问题是,当相机侧身举行(所以我认为我的Galaxy Tab P1000在横向位置)图像被拉伸了。

The problem I'm having is, when the camera is held sideways (so I hold my Galaxy Tab P1000 in landscape position) the view is stretched out.

要具体谈谈我的剧本,我用code的精确副本,谷歌做。它可以在Android的SDK中找到\样本\ Android为8 \ ApiDemos的\ src \ COM \例如\机器人\蜜蜂\显卡\

To be more specific about my script, I used an exact copy of code that Google made. It can be found in the android-sdk\samples\android-8\ApiDemos\src\com\example\android\apis\graphics\

该文件本身是一个名为摄像机preVIEW。

The file itself is called CameraPreview.

我真的不知道为什么画面看起来如此捉襟见肘。当然,该格式是怪异而不是正方形,但仍使用安装在设备上的默认摄像头应用程序时,它不会变形的。这款相机变形的图像时,我侧身拿着它和移动摄像机哪怕是一点点。

I really have no clue why the screen looks so stretched. Of course, the format is weird and not square, but still, when using the default camera app installed on the device, it doesn't deform at all. This camera deforms the image when I hold it sideways and move the camera even a little.

我所做的就是:我举起的Galaxy Tab采取一个对象(笔记本电脑在这种情况下)的图片,然后拍了一张照片与我的手机我的银河。在Galaxy我有相机屏幕中的应用程序,我正在做开放。这算个两个图像。其中我认为侧身,一个我在纵向视图举行。该照片是有点不清楚,但你可以看到,在风景照片时,相机已经成为大型宽。

What I did was: I held my galaxy tab to take a picture of an object (laptop in this case) then took a picture with my phone of my Galaxy. On the Galaxy I have the camera screen open in the app i'm making. This counts for both images. One I hold sideways and one I hold in portrait view. The pics are a bit unclear but you can see that in the landscape picture, the camera has become massively wide.

推荐答案

昨天我面临同样的问题。经过研究照相机来源我找到了一个理由摄像头preVIEW被拉伸。

I faced the same problem yesterday. After a researching "Camera" sources I found a reason for camera preview being stretched.

原因是:SurfaceView纵横比(宽/高)必须是相同preVIEW参数用于Camera.Size宽高比。如果高宽比是不一样的,你有扩张的图象。

The reason is: SurfaceView aspect ratio (width/height) MUST be same as Camera.Size aspect ratio used in preview parameters. And if aspect ratio is not the same, you've got stretched image.

因此​​,最快的解决方法是设置SurfaceView像320PX x 240px大小 - 支持的最小距离Parameters.getSupported previewSizes大小()

So, the fastest workaround is to set SurfaceView to size like 320px x 240px - smallest supported size from Parameters.getSupportedPreviewSizes().

此外,您还可以看看相机的标准应用程序的来源,它使用了自定义布局控制SurfaceView尺寸(见previewFrameLayout.java,onMeasure()函数)。

Also, you can look at Camera standard application sources, it uses the custom layout for controlling the SurfaceView size (see PreviewFrameLayout.java, onMeasure() function).

使用

混帐克隆https://android.googlesource.com/platform/packages/apps/Camera.git

让相机的来源。

 
精彩推荐
图片推荐