6
Tôi đang sử dụng thư viện opencv mới hơn của willowgarage trong nhật thực. Và tôi muốn chuyển đổi một biến mat thành màu xám, tôi đã thử tất cả mọi thứ tôi tìm thấy trên mạng nhưng họ đã không làm việc cho tôi.android-opencv chuyển đổi mat sang màu xám với việc sử dụng matToBitmap/bitmapToMat
Đây là mã của tôi
package com.deneme.deneme;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageView;
import org.opencv.android.Utils;
import org.opencv.core.Mat;
import org.opencv.imgproc.Imgproc;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
public class main extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView img=(ImageView) findViewById(R.id.pic);
Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.p26);
Mat imgToProcess=Utils.bitmapToMat(bmp);
//******
//right here I need to convert this imgToProcess to grayscale for future opencv processes
//******
Bitmap bmpOut = Bitmap.createBitmap(imgToProcess.cols(), imgToProcess.rows(), Bitmap.Config.ARGB_8888);
Utils.matToBitmap(imgToProcess, bmpOut);
img.setImageBitmap(bmpOut);
}
}
Chỉ cần nhớ rằng opencv doesnt sử dụng những trọng số này. Dưới đây là những gì họ sử dụng: http://stackoverflow.com/questions/19181323/what-grayscale-conversion-algorithm-does-opencv-cvtcolor-use – Dinidiniz