相机方向和预览尺寸 [英] Camera orientation and preview size

查看:287
本文介绍了相机方向和预览尺寸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在Android开发者文档中,他们有 setPreviewSize()

的说明, code>:



DIRECT LINK


假设相机支持480x320和320x480预览大小。应用程序需要3:2的预览比率。如果显示方向设置为0或180,预览大小应设置为480x320。如果显示方向设置为90或270,预览尺寸应设置为320x480。在设置图片大小和缩略图大小时,还应考虑显示方向。


所以在我的代码中,是直的,这工作正常。



现在我想要一个4:3的图片,我支持的预览尺寸是 1440x1080 ,根据上面的块引用,这意味着我需要将我的预览大小更改为:

  p .setPreviewSize(1080,1440); 

但是显然这不是我的设备支持的分辨率,所以应用程序会崩溃。



这里是我支持的预览大小,如果我没有支持的预览,我没有上述情况(块引用文本),我该怎么办

 迭代器D / CAMERA:width:1920 height 1080 ----- 
迭代器D / CAMERA:width:1440 height 1080 -----
迭代器D / CAMERA:width:1088 height 1088 -----
迭代器D / CAMERA:width:1280 height 720 -----
迭代器D / CAMERA:width:1056 height 704 -----
迭代器D / CAMERA:width:1024 height 768 -----
迭代器D / CAMERA:width:960 height 720 -----
迭代器D / CAMERA:width:800 height 450 -----
迭代器D / CAMERA:width:720 height 720 -----
迭代器D / CAMERA:width:720 height 480 ---- -
迭代器D / CAMERA:width:640 height 480 -----
迭代器D / CAMERA:width:352 height 288 -----
迭代器D / CAMERA:width: 320 height 240 -----
迭代器D / CAMERA:width:256 height 144 -----
迭代器D / CAMERA:width:176 height 144 -----

我需要我的图片为4:3

解决方案

根据我研究的内容,您只能使用支持的预览尺寸: stackoverflow.com/a/8051114/ 6286328 stackoverflow.com/a/6952604/6286328 。也许你最好的镜头是获得类似的预览大小(根据你所需的比例),并测试看看它是如何获得。


I just need some clarification with something regarding camera previews

In Android developer documentation they have this under the description for setPreviewSize():

DIRECT LINK

suppose the camera supports both 480x320 and 320x480 preview sizes. The application wants a 3:2 preview ratio. If the display orientation is set to 0 or 180, preview size should be set to 480x320. If the display orientation is set to 90 or 270, preview size should be set to 320x480. The display orientation should also be considered while setting picture size and thumbnail size.

So in my code I am able to rotate the camera orientation to be straight, this works fine. So changing my orientation 90 degrees makes my camera straight.

Now I want a 4:3 image, one of my supported preview sizes is 1440x1080, according to the block quote above this would mean I need to change my preview size to:

p.setPreviewSize(1080,1440);

But obviously this isnt a supported resolution for my device, so the app will crash.

here are my supported preview sizes, what do I do if I dont have a supported preview where I dont have the above scenario (block quote text)

iterator D/CAMERA: width: 1920 height 1080 -----
iterator D/CAMERA: width: 1440 height 1080 -----
iterator D/CAMERA: width: 1088 height 1088 -----
iterator D/CAMERA: width: 1280 height 720 -----
iterator D/CAMERA: width: 1056 height 704 -----
iterator D/CAMERA: width: 1024 height 768 -----
iterator D/CAMERA: width: 960 height 720 -----
iterator D/CAMERA: width: 800 height 450 -----
iterator D/CAMERA: width: 720 height 720 -----
iterator D/CAMERA: width: 720 height 480 -----
iterator D/CAMERA: width: 640 height 480 -----
iterator D/CAMERA: width: 352 height 288 -----
iterator D/CAMERA: width: 320 height 240 -----
iterator D/CAMERA: width: 256 height 144 -----
iterator D/CAMERA: width: 176 height 144 -----

I need my image to be 4:3

解决方案

From what I researched, you can only use supported preview sizes: stackoverflow.com/a/8051114/6286328 and stackoverflow.com/a/6952604/6286328. Perhaps your best shot is to get a similar suppored preview size (according to your required proportion) and test to see how it gets.

这篇关于相机方向和预览尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆