相机API:跨设备问题 [英] Camera API: Cross device issues

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

问题描述

我正在开发一个相机应用程序,基本上作为消息应用程序的一部分,以附加图像等。应用程序需要工作> = SDK 2.2和:



无法使用默认的Android相机,因为:


  1. 应用程序的本质决定了图像不应该保存到磁盘,有些OEM(三星)喜欢这样做,而不给你一个选择。


  2. 我无法呼叫任何其他相机应用程式可以拦截的意图,因为该应用程式可以储存图片。


我目前的问题是处理的事实,Android相机显然讨厌纵向。具体来说,在一些挖掘之后,我监视的显示,并在轮播,调用 setDisplayOrientation(90)。这个工作,但surfaceview维度也需要改变,这必须在支持的维度或参数设置崩溃的应用程序。



我使用另一个SO snippet我发现这里 getBestPreviewSize()方法),但它有一个显着的问题,我不能相信我没有找到任何人有。 takePicture 生命周期的一部分包括调用 PostView 图片回调。这是显示当前暂停的 SurfaceView 图像的静态图像,将通过byteArray返回到raw和/或jpeg回调。我的问题是,这个图像仍然倾斜在一些看似随机的测试设备!因此,行为是用户看到完美的4:3宽高比的动态相机图像,直到他们拍摄图片和他们呈现的图像被压扁。注意字节数组本身是正确的,当我在消息结束点构造 Bitmap 时,它显示正常,但这仍然是一个问题。



我看不到如何改变静态图像显示在这一点上。任何人都可以帮我解决这个问题?

解决方案

Android相机系统是一团糟。和beind焊接到主板,相机芯片不会喜欢portait应用程序 - 所有的回调以相机方向(您收到的缓冲区实际上是共享内存块与本机相机应用程序)溢出数据 - 如果你喜欢显示它,而你的应用程序在portait模式下,您将必须通过 xy 翻转此数据。



而不是在表面视图使用相机,我会覆盖它透明 ImageView ,并绘制我的位图。



您可以(希望)在 javaocr项目中找到灵感其中android deamon工作在纵向模式和绘制位图在实时预览。 (请从 git 中签出,因为它正在发布,我正在使用git和maven努力,见demos目录)


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:

I can't use the default Android Camera as much as I'd love to because:

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

  2. I can't call an intent that any other camera app can intercept because then that app could save the image.

My current problem 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.

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.

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 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.

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

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)

这篇关于相机API:跨设备问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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