小编QAI*_*AIS的帖子

OpenCV与Android捕获图像

在Android中捕获图像并使用opencv处理它们的最佳方法是什么?我应该使用表面视图在这里或我应该使用opencv相机中的opencv相机吗?以及如何加载捕获的图像并将其转换为Mat?提前致谢

 private PictureCallback mPicture = new PictureCallback() {

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

        File pictureFile = getOutputMediaFile(MEDIA_TYPE_IMAGE);
        if (pictureFile == null) {
            Log.d("E",
                    "Error creating media file, check storage permissions ");
            return;
        }

        try {

            FileOutputStream fos = new FileOutputStream(pictureFile);
            fos.write(data);
            fos.close();
            //processImage();
        } catch (FileNotFoundException e) {
            Log.d("E", "File not found: " + e.getMessage());
        } catch (IOException e) {
            Log.d("E", "Error accessing file: " + e.getMessage());
        }
    }
Run Code Online (Sandbox Code Playgroud)

android opencv android-camera

2
推荐指数
1
解决办法
5431
查看次数

拍摄照片时启用快门声音

拍摄照片时如何启用快门声?我试过这个,但它不起作用!我在Galaxy y上测试它(目标2.3.6)任何提示或想法?提前致谢.

public boolean onTouchEvent(MotionEvent event) {
    // TODO Auto-generated method stub
    mCamera.takePicture(shutterCallback, null, mPicture);
    return super.onTouchEvent(event);
}
private final ShutterCallback shutterCallback = new ShutterCallback() {
    public void onShutter() {
        AudioManager mgr = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
        mgr.playSoundEffect(AudioManager.FLAG_PLAY_SOUND);
    }
};
Run Code Online (Sandbox Code Playgroud)

android android-camera

2
推荐指数
1
解决办法
1765
查看次数

标签 统计

android ×2

android-camera ×2

opencv ×1