1

カメラアクティビティで写真を撮り、保存した場所から読み取ろうとしています。残念ながら、ビットマップは次の人から返されました。

Bitmap bimage = BitmapFactory.decodeFile( path );

高さと幅は-1です。私はOpenCVを使用していて、画像を

Mat img = Highgui.imread(path);

適切な行列を取得します。私はそれをビットマップに変換することはできませんが。するとき

bmp = Bitmap.createBitmap(img.cols(), img.rows(), Config.ARGB_8888);
Utils.matToBitmap(img, bmp);

再び同じ結果が得られます:幅と高さが-1のビットマップ。画像形式に注意する必要がありますか?カメラのインテントに設定できますか?すべきではない

BitmapFactory.decodeFile( path );

フォーマットが何であるかを自動的に認識しますか?

私はこれをAndroid2.3.1とOpenCV2.3.1を搭載したSamsungGalaxySで実行しています

ご協力いただきありがとうございます。

4

1 に答える 1

0

Samsungにはカメラインテントにいくつかの問題があります写真キャプチャインテントはSamsung電話でのみNullPointerExceptionを引き起こします

この方法を試してください

//カメラを呼び出す

String _path = Environment.getExternalStorageDirectory()
                    + File.separator + "TakenFromCamera.png";
            File file = new File(_path);
            Uri outputFileUri = Uri.fromFile(file);
            Intent intent = new Intent(
                    android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
            startActivityForResult(intent, 1212);

//アクティビティonResultで

if (requestCode == 1212) {
            String _path = Environment.getExternalStorageDirectory()
                    + File.separator + "TakenFromCamera.png";
            mBitmap = BitmapFactory.decodeFile(_path);
            if (mBitmap == null) {
            } else {
                Intent intent = new Intent(AYGCamActivity.this,
                        myGalleryImage.class);

                startActivity(intent);
            }

        }
于 2012-01-28T11:37:49.417 に答える