拍照不SurfaceView或没有照片意向活动 [英] Taking picture without SurfaceView or without Photo Intent Activity

查看:100
本文介绍了拍照不SurfaceView或没有照片意向活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从手机拍照的照片来分析它,但我并不需要出示SurfaceView内容(摄像机的图像)。我可以使用Camera类没有SurfaceView持有人?一种方法是简单地隐藏SurfaceView但是,有没有办法不使用它呢?

我想这样的,但它抛出一个错误:takePicture失败。

的onCreate:

  mCamera = getCameraInstance(); //私人相机mCamera;
mCamera.start preVIEW();button.setOnClickListener(新OnClickListener(){
   @覆盖
   公共无效的onClick(视图v){      mCamera.takePicture(NULL,NULL,mPicture);   }
});

相机:

 公共静态相机getCameraInstance(){
            相机C = NULL;
            尝试{
                C = Camera.open(); //试图得到一个摄像头实例
            }赶上(例外五){
                e.printStackTrace();
            }
            返回℃; //如果相机不可用,则返回null
        }    私人Camera.PictureCallback mPicture =新Camera.PictureCallback(){        @覆盖
        公共无效onPictureTaken(字节[]数据,相机摄像头){            的System.out.println(点击);
        }
    };


解决方案

我解决这么surficeView没有看到在SurficeView思想促进新视图我的问题。我通过搜索其他的解决办法,但都没有成功花费相当的时间。

I need to take a photo from phone camera to analyze it, but I do not need to show the content (image of camera) on SurfaceView. Can I use Camera class without SurfaceView holder? One way is to simply hide SurfaceView but Is there a way to not using it at all?

I tried like this but it throws an error: takePicture failed

onCreate:

mCamera = getCameraInstance();   //private Camera mCamera;  
mCamera.startPreview();

button.setOnClickListener(new OnClickListener() {
   @Override
   public void onClick(View v) {

      mCamera.takePicture(null, null, mPicture);

   }
});

Camera:

public static Camera getCameraInstance() {
            Camera c = null;
            try {
                c = Camera.open(); // attempt to get a Camera instance
            } catch (Exception e) {
                e.printStackTrace();
            }
            return c; // returns null if camera is unavailable
        }

    private Camera.PictureCallback mPicture = new Camera.PictureCallback() {

        @Override
        public void onPictureTaken(byte[] data, Camera camera) {

            System.out.println("CLICK");
        }
    };

解决方案

I solve my problem by puting new view over the SurficeView so surficeView was not seen. I spend quite a time by searching for other solution but without success.

这篇关于拍照不SurfaceView或没有照片意向活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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