的Andr​​oid如何设置相机preVIEW像素像素、如何设置、相机、Andr

2023-09-09 21:03:52 作者:沧海佚夫

有没有什么办法来设置相机preVIEW像素,喜欢把像素或一些其他的方式?结果我的要求:我想提出一些像素的相机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
}