Android摄像头API跨设备的噩梦 [英] android camera API cross device nightmare

查看:138
本文介绍了Android摄像头API跨设备的噩梦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OK,我对我的绳子结束了,所以我真的很希望有人能指出我的东西有帮助的。

OK, I am about at the end of my rope here so I'm really hoping someone can point me to something helpful.

我基本上开发相机应用作为一个消息应用程序,以附加图像部分等应用程序需要工作> = SDK 2.2,并注意有关该应用程序的摄像头部分的要求如下:

I'm developing a camera app basically as part of a messaging app to attach images etc. The app needs to work for >= SDK 2.2 and note the following about the requirements of the camera portion of the app:

我不能使用默认的Andr​​oid摄像头,就像我很乐意     (通过意图),因为

I CANNOT use the default android camera as much as I'd love to (via intents) because

  1. 应用程序的特性决定了其采取的不是图像保存 磁盘曾经和一些OEM(三星)喜欢这样做不     给你一个选择,以及

  1. The nature of the app dictates that the image taken not be saved to disk ever and some OEMs (Samsung) love to do this without giving you a choice and

再次,由于它的性质,即使(1)不是一个问题,我不能叫意图,任何其他的相机应用可以拦截,因为     那么该应用程序可以将图像保存等等等等

again due to it's nature even if (1) weren't a problem I can't call an intent that any other camera app can intercept because then THAT app could save the image etc etc

我现在的问题(虽然有很多)正在处理的事实是,Android摄像头显然不喜欢在纵向之中。具体而言,一些挖后,我在监控显示器,并在旋转,要求 setDisplayOrientation(90)。这工作,但在surfaceview尺寸必须也改变了,这必须支持的尺寸内完成或参数设置崩溃的应用程序。

My current problem (although there are many) is dealing with the fact that the Android camera apparently hates being in portrait orientation. Specifically, after some digging I'm monitoring the display and, on rotation, calling setDisplayOrientation(90). This works but the surfaceview dimensions need to be altered also and this must be done within supported dimensions or the parameter setting crashes the app.

我做这与其他SO片断,我发现<一href="http://stackoverflow.com/questions/5540981/picture-distorted-with-camera-and-getoptimal$p$pviewsize">here (在 getBest previewSize()方法),但它有一个突出的问题,我不能相信我还没有发现其他任何人拥有。

I'm doing this with another SO snippet I found here (the getBestPreviewSize() method) but it has one glaring problem that I can't believe I haven't found anyone else having.

takePicture部分生命周期涉及调用后览图片回调。这是表明,将通过的字节数组返回到原始和/或JPEG回调目前已暂停 SurfaceView 图像的静止图像。我的问题是,这个形象依然偏向于少数看似随意的测试设备!因此,行为是一个用户看到一个动态的摄像机图像完美的4:3纵横比,直到他们拍照,他们psented与被压扁$ P $的形象。需要注意的是字节数组本身是正确的,当我构建位图在消息端点它显示了罚款,但这仍然是一个问题。

Part of the takePicture lifecycle involves calling the PostView picture callback. This is what shows the still image of the current paused SurfaceView image that will be returned via byteArray to the raw and/or jpeg callback. My problem is, this image is still skewed on a handful of seemingly random test devices! So the behavior is a user sees a dynamic camera image in perfect 4:3 aspect ratio until they take the picture and the image they are presented with is squished. Note that the byte array itself is correct and when I construct the Bitmap at the messaging end point it shows up fine but this is still a problem.

我不明白我怎么可以改变静止图像显示在这一点上。谁能帮我这个?

I can't see how I can alter the still image display at this point. Can anyone help me with this?

推荐答案

Android摄像头系统是一个烂摊子。而beind焊接到主板上,摄像头芯片是不会喜欢波泰特应用程序 - 所有的回调溢出数据照相机方向(缓冲收到实际上是共享内存片与本机摄像头的应用程序) - 如果你想显示它,而你的应用程序在波泰特模式下,你将不得不翻转这个数据超过 XY

Android camera system is a mess. And beind soldered to motherboard, camera chip is not going to like portait application - all the callbacks spill out data in camera orientation (buffer you receive is actually shared memory piece with native camera app) - if you like to display it while your application is in portait mode, you will have to flip this data over xy.

,我将它覆盖有透明的ImageView 并提请我的位图存在。

Instead of showing image on the surface view used by camera, I would overlay it with transparent ImageView and draw my bitmap there.

您可以(希望)找出来 javaocr项目的一些灵感凡在纵向模式的Andr​​oid守护进程的工作和位图绘制在实况preVIEW。 (请从混帐结账,因为它现在正在释放,我挣扎与GIT和Maven,看演示目录)

You may (hopefully) find some inspiration in out javaocr project where android deamon work in portrait mode and draw bitmaps over live preview. (please checkout from git, as it is being released now and I'm struggling with git and maven, see demos directory)

这篇关于Android摄像头API跨设备的噩梦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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