如何捕获的Android相机原始图像
在takePicture rawCallback返回一个空指针。该getPictureFormat只允许JPG格式。虽然JPEG可以与getParameters()setJpegQuality(100)setParameters得到改善,所返回的图像仍然一个JPEG。为了得到一个位图图像BitmapFactory.de codeByteArray需要被调用,这可能需要1/2秒处理。
The takePicture rawCallback returns a null pointer. The getPictureFormat only allows for .jpg. While the jpeg can be improved with getParameters() setJpegQuality(100) setParameters, the image returned is still a jpeg. To get a bitmap image BitmapFactory.decodeByteArray needs to be called, which can take 1/2 second to process.
我工作的应用程序需要最细致的图像的摄像头可以生产,这并不一定意味着pretty的。原始摄像头芯片采集格式为拜耳。
The application I'm working on needs the most detailed image the camera can produce, which does not necessarily mean pretty. The raw camera chip capture format is bayer.
Android的(至少我的)有2个摄像头参数rawsave模式
和rawfname
,默认 rawsave模式= 0
。通过设置 rawsave模式= 1
,相机将保存原始摄像机图像文件,以及执行等拍照功能一切正常。
The android (at least mine) has 2 camera parameters "rawsave-mode"
and "rawfname"
, with the default rawsave-mode=0
. By setting rawsave-mode=1
, the camera will save the raw camera image file, along with performing the other camera functions as usual.
Camera.Parameters parameters=preview.camera.getParameters();
parameters.set("rawsave-mode", "1");
parameters.set("rawfname", "/mnt/sdcard/test.raw");
preview.camera.setParameters(parameters);
preview.camera.takePicture(shutterCallback, null, jpegCallback);
产生的文件的实际名称被修改,以包括所生产的原始文件的参数。对于我的机器人之一,公司生产的名称为test__1604x1206_10_2.raw
这是A1 1604x1206
图像, 10位
2的格式和test__1284x966_10_3.raw
这是一个1284x966的图像, 10位
格式3. 10字节
如 2字节的短整型(小端)存储
。
The actual name of the file produced get modified to include the parameters of the raw file being produced. For one of my androids, the name produced is "test__1604x1206_10_2.raw"
which is a1 1604x1206
image, 10bit
format 2. and "test__1284x966_10_3.raw"
which is a 1284x966 image, 10 bit
format 3. The 10 bytes
are stored as 2 byte short int (little endian)
.
parameters.set("rawsave-mode", "2");
// setting the rawsave-mode to 2 increased the resolution to 3204x2406
// and output the file test__3204x2406_10_2.raw
图片数据大致 8位
,但浮 10位
中,其中较亮的图像可以使用更高的价值和更暗下。这使得该图像处理软件来创建直方图和捕获图像的有用范围。因为光不是一个常数,它也可以是必要的,以不同地调整一个信道比另一个以使图像的外观颜色正确。有很多在网络上的信息对于色彩理论能够完全解释这一点,但新用户要注意, 10位
到 8 变深快。如果你想有一个pretty的图片,使用android的画面捕捉,而不是原始图像!
The image data is roughly 8 bit
, but floats within the 10 bit
, where a brighter image might use higher values and darker lower. This allows the image processing software to create a histogram and capture the useful range of the image. Because light is not a constant, it can also be necessary to adjust one channel differently than another to make the image look color correct. There is a lot of info on the web regarding color theory which can explain this fully, but new users beware, the conversion of 10 bit
to 8
gets deep quickly. If you want a pretty picture, use the android picture capture and not the raw image!
的格式重新presents的各个位的拜耳图案。拜耳是一个格式,其中的行和列的奇/偶数值表示的颜色的像素再presents,其中 RGB
有一个 8位
的价值为每个像素每个颜色通道,拜耳只有一个 10位
值像素,其中一个像素是红色的,那么接下来的绿色红,绿,红,绿。然后下一行具有蓝,绿,蓝,绿,蓝绿色。要确定 RGB
的像素值需要跨preting周围的像素。
The format represents the bayer pattern of the bits. Bayer is a format where the odd/even value of the row and column indicate which color the pixel represents, where RGB
has an 8 bit
value for each color channel for each pixel, bayer has only one 10 bit
value for pixel, where one pixel is red, then the next green, red, green, red, green. Then the next row has blue, green, blue, green, blue green. To determine the RGB
value of a pixel requires interpreting the surrounding pixels.
Format 2 has pixel order
// 0 1 2 3 4 5
// 0 G R G R G R
// 1 B G B G B G
// 2 G R G R G R
// 3 B G B G B G
格式3具有的像素顺序
format 3 has the pixel order of
// 0 1 2 3 4 5
// 0 R G R G R G
// 1 G B G B G B
// 2 R G R G R G
// 3 G B G B G B
我不知道,如果这种技术将适用于其他机器人或者这是否会在未来的机器人。如果有人试图为此,请添加成功或失败的注释。我的手机是直接的中国的进口解锁iHTC Android手机已经根深蒂固。
I'm not sure if this technique will work on other androids or if it will work on future androids. If anyone tries this, please add a comment on success or failure. My phones are direct chinese import unlocked iHTC Android phones which have been rooted.