我已经尝试使用我的代码从相机拍照并将其从 RGB 转换为 HSV 颜色空间,但结果没有显示 HSV 颜色,它显示了一些不寻常的东西,请看看这里是我的代码
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button buttonImageCapture = (Button)findViewById(R.id.captureimage);
imageiewImageCaptured = (ImageView)findViewById(R.id.imagecaptured);
buttonImageCapture.setOnClickListener(buttonImageCaptureOnClickListener);
}
Button.OnClickListener buttonImageCaptureOnClickListener
= new Button.OnClickListener(){
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, 0);
}};
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
//try{
if (resultCode == RESULT_OK)
{
Bundle extras = data.getExtras();
Bitmap bmp = (Bitmap) extras.get("data");
bmp = bmp.copy(Bitmap.Config.ARGB_8888, true);
Mat newmat = Utils.bitmapToMat(bmp);
Mat mHSV = new Mat();
Imgproc.cvtColor(newmat, mHSV, Imgproc.COLOR_BGR2HSV,3);
Bitmap newbmp = Bitmap.createBitmap(newmat.cols(), newmat.rows(), Bitmap.Config.ARGB_8888);
Utils.matToBitmap(mHSV, newbmp);
imageiewImageCaptured.setImageBitmap(newbmp);
}
}
}