OpenCV Android imwrite给我一个蓝色图像

时间:2016-04-04 12:02:02

标签: java android opencv

我使用CvCameraViewListener2实现了一个摄像头,当我写入时,图片保存变为蓝色 这是我的代码

public Mat onCameraFrame(final CvCameraViewFrame inputFrame) {
    img_rgb = inputFrame.rgba();

    return img_rgb;

}

public void captureImage(View v){
    Mat mInter= new Mat(img_rgb.width(),img_rgb.height(),CvType.CV_32FC3);
    File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
    String filename = "temp.jpg";
    File file = new File(path, filename);
    Boolean bool = null;
    filename = file.toString();
    if(img_rgb.height() > img_rgb.width()){
        Core.flip(img_rgb,mInter,1);
        bool = Imgcodecs.imwrite(filename, mInter);
    }
    else{
    bool = Imgcodecs.imwrite(filename,mInter);}
    if (bool == true)
        Log.i(TAG, "SUCCESS writing image to external storage");
    else
        Log.i(TAG, "Fail writing image to external storage");
    String PathName = "";
    Intent i = new Intent(getApplication(),Result.class);
    i.putExtra(EXTRA_MESSAGE ,filename);
    startActivity(i); 

结果:

enter image description here

我找不到问题,我尝试将垫子转换成其他颜色,但没有结果。

0 个答案:

没有答案