如何设置相机的分辨率在Android中使用OpenCV的? [英] How to set camera resolution in Android with OpenCV?

查看:1562
本文介绍了如何设置相机的分辨率在Android中使用OpenCV的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图开发针对Android的应用程序,我需要得到的分辨率尽可能高的相机uncom pressed图片。我试图takePicture的rawCallback和postviewCallback,但他们没有工作。

I'm trying to develop an app for Android, and I would need to get uncompressed pictures with a resolution as high as possible from the camera. I tried takePicture's rawCallback and postviewCallback, but they are not working.

现在,我尝试使用VideoCapture的OpenCV(2.4版本),但我卡在默认960x720,这是可怜的我需要的东西;而我的电话,三星Galaxy S3,能够提供,理论上,最多8Mpx(3,264×2,448的照片,1,920×1080的视频,根据维基百科)。 VideoCapture.set(Highgui.CV_CAP_PROP_FRAME_WIDTH /身高,有的号码),使相机返回一个黑色图像,据我已经找到。

Right now I'm trying with OpenCV (version 2.4) using VideoCapture, but I'm stuck in the default 960x720, which is poor for what I need; and my phone, a Samsung Galaxy S3, is able to provide, theoretically, up to 8Mpx (3,264×2,448 for pictures, and 1,920×1,080 for video, according to Wikipedia). VideoCapture.set(Highgui.CV_CAP_PROP_FRAME_WIDTH/HEIGHT, some number) makes the camera return a black image as far as I've found.

有没有什么办法来获得更高的分辨率,无论是通过OpenCV的或与Android的API,无需COM pressing?

Is there any way to obtain a higher resolution, either through OpenCV or with the Android API, without compressing?

我真的很抱歉,如果这已经问过;我一直在寻找了几天,我发现什么。

I'm really sorry if this has been asked before; I have been looking for days and I have found nothing.

感谢您的时间!

编辑:虽然它不正是我一直在问,我发现有一种方法做一些非常相似:如果设置在previewCallback的摄像头,采用一套previewCallback,你做获得从相机(至少在S3我有工作)的原始图象数据。我离开这里,以防有人发现它在将来有用。

Although it is not exactly what I was asking, I found that there is a way to do something very similar: if you set an OnPreviewCallback for the Camera, using setPreviewCallback, you do get the raw picture data from the camera (at least in the S3 I'm working with). I leave it here in case somebody finds it useful in the future.

编辑:部分解决方案将在下面的答案解释。综上所述,

A partial solution is explained in an answer below. To sum up,

vc.set(Highgui.CV_CAP_PROP_FRAME_WIDTH, desiredFrameWidth);
vc.set(Highgui.CV_CAP_PROP_FRAME_HEIGHT, desiredFrameHeight);

工程在一定条件下;请参阅下面的进一步的细节。

works under some conditions; please see below for further detail.

推荐答案

您必须得到支持的摄像头preVIEW resoultions通过调用<一href="http://developer.android.com/reference/android/hardware/Camera.Parameters.html#getSupported$p$pviewSizes%28%29"相对=nofollow> getSupported previewSizes

You have to get supported camera preview resoultions by calling getSupportedPreviewSizes.

在此,您可以设置方法的任何决议<一href="http://developer.android.com/reference/android/hardware/Camera.Parameters.html#set$p$pviewSize%28int,%20int%29"相对=nofollow> 设置previewSize 。而且不要忘了<一href="http://developer.android.com/reference/android/hardware/Camera.html#setParameters%28android.hardware.Camera.Parameters%29"相对=nofollow> setParameters 到底。 Actally许多OpenCV的Andr​​oid的例子包含该信息(看样本3)。

After this you can set any resolution with method setPreviewSize. And don't forget to setParameters in the end. Actally many OpenCV Android examples contain this information (look at sample3).

这篇关于如何设置相机的分辨率在Android中使用OpenCV的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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