的Andr​​oid如何设置相机preVIEW像素 [英] Android How to set pixels on camera preview

查看:112
本文介绍了的Andr​​oid如何设置相机preVIEW像素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有什么办法来设置相机preVIEW像素,<一个href=\"http://www.41post.com/3470/programming/android-retrieving-the-camera-$p$pview-as-a-pixel-array\"相对=nofollow>喜欢把像素或一些其他的方式?结果
我的要求:我想提出一些像素的相机preVIEW特定位置或将一些点的某些像素值的摄像头preVIEW到另一个值

Is there is any way to set pixels on cameraPreview, like getting pixel or some other ways?
My requirement: I want to put some pixels on a particular positions on camera preview or convert some pixel value of some points in camera preview into another value.

推荐答案

我已经放置在表面观前的自定义视图,每个解决了这个问题, previewCallback 我绘制图像,并设置它作为自定义视图的背景。感觉相机preVIEW绘制像素。 我不知道这是实际的方法,如果我得到最佳的解决方案,我会在这里更新结果
自定义视图

I have solved this issue by placing a custom view in front of the surface view, on each PreviewCallback I draw an image and set it as background of that custom view. It feels drawing pixels on camera preview. I dont know this is the actual method, if I get optimal solution I will update here
Custom view

public class DrawOnTop  extends View {

public DrawOnTop(Context context) {
        super(context);
        // TODO Auto-generated constructor stub
}}

结果
创建摄像头活动器具 previewCallback 结果
要设置自定义查看surfaceview结果


Create camera activity implements PreviewCallback
To set custom view infront of surfaceview

DrawOnTop mDraw = new DrawOnTop(this);
    addContentView(mDraw, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

上previewFrame ,你可以做code根据preVIEW显示创建图像,并设置图像作为自定义视图的背景。

In onPreviewFrame you can do code for creating image according to preview display and set that image as background of the custom view.

@Override  
public void onPreviewFrame(byte[] data, Camera camera) {  
    //your code
}

这篇关于的Andr​​oid如何设置相机preVIEW像素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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