如何解决相机拍摄延迟

时间:2019-06-03 21:03:23

标签: java android camera delay freeze

我正在尝试在我的应用上使用相机,但是在按下“捕获”按钮直到捕获图片之间出现了延迟

 btn_cam = (ImageButton) findViewById(R.id.btn_cam);
        btn_cam.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dispatchTakePictureIntent();
            }
        });
        grid = findViewById(R.id.grid_view);
private void dispatchTakePictureIntent() {
        Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        // Ensure that there's a camera activity to handle the intent
        if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
            // Create the File where the photo should go
            File photoFile = null;
            try {
                photoFile = createImageFile();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            // Continue only if the File was successfully created
            if (photoFile != null) {
                Uri photoURI = FileProvider.getUriForFile(this,
                        "com.example.spotfacetest.fileprovider",
                        photoFile);
                takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
                startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
            }
        }
    }

当我按下“相机”按钮时,它会打开相机,而不是我只按下“捕获”按钮,并且相机不会冻结,它仅在2-3秒后才完成捕获,然后显示“冻结的捕获图片”,比我可以选择“ V”(如果要继续)或“ X”(关闭图片)拍摄的时间。但是问题在于那延迟。为什么在按下“捕获”按钮后图片没有立即冻结。

0 个答案:

没有答案