这是我的java类,我从中调用了我的c ++代码,我在c ++中编写了opencv函数代码
InputStream is;
is = this.getResources().openRawResource(R.drawable.foot);
Bitmap bmInImg = BitmapFactory.decodeStream(is);
int [] mPhotoIntArray;
int [] mCannyOutArray;
mPhotoIntArray = new int[bmInImg.getWidth() * bmInImg.getHeight()];
// Copy pixel data from the Bitmap into the 'intArray' array
bmInImg.getPixels(mPhotoIntArray, 0, bmInImg.getWidth(), 0, 0, bmInImg.getWidth(), bmInImg.getHeight());
//create the Brightness result buffer
mCannyOutArray = new int[bmInImg.getWidth() * bmInImg.getHeight()];
//
// Do Brightness
//
BrightnessJNI(bmInImg.getHeight(), bmInImg.getWidth(), mPhotoIntArray, mCannyOutArray);
//
// Convert the result to Bitmap
//
Bitmap bmOutImg = Bitmap.createBitmap(bmInImg.getWidth(), bmInImg.getHeight(), Config.ARGB_8888);
bmOutImg.setPixels(mCannyOutArray, 0, bmInImg.getWidth(), 0, 0, bmInImg.getWidth(), bmInImg.getHeight());
imageview_2.setImageBitmap(bmOutImg);
//
// Save the result to file
//
String extStorageDirectory = Environment.getExternalStorageDirectory().toString();
String outFileName = extStorageDirectory + "/Brightness";
OutputBitmapToFile(bmOutImg, outFileName);
}
void OutputBitmapToFile(Bitmap InBm, String Filename)
{
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
InBm.compress(Bitmap.CompressFormat.PNG, 100, bytes);
File f = new File(Filename);
try
{
f.createNewFile();
//write the bytes in file
FileOutputStream fo = new FileOutputStream(f);
fo.write(bytes.toByteArray());
}
catch (Exception e)
{
e.printStackTrace();
}
}
这是我的用于histrogram均衡的opencv函数代码
jint* _in = env->GetIntArrayElements(in, 0);
jint* _out = env->GetIntArrayElements(out, 0);
//Build the Mat structure for input data
Mat mSrc(height, width, CV_8UC4, (unsigned char *)_in);
//Build the Mat structure for output data
Mat mOut(height, width, CV_8UC4, (unsigned char *)_out);
//Convert Mat to IplImage
IplImage mSrcImg = mSrc;
IplImage mOutImg = mOut;
vector<IplImage*> b , g ,r;
cvSplit(&mSrcImg , &b , &g , &r , NULL);
cvEqualizeHist(&b, &b);
cvEqualizeHist(&g, &g);
cvEqualizeHist(&r, &r);
cvMerge(&b, &g, &r, NULL, &mOutImg );
因为我在这里使用C
界面,所以我假设我在C
代码
错误
Tasks
Description Resource Path Location Type
FIXME: do we need release() here? MatOfByte.java /OpenCV Library - 2.4.7/src/org/opencv/core line 19 Java Task
FIXME: do we need release() here? MatOfByte.java /OpenCV Library - 2.4.7/src/org/opencv/core line 30 Java Task
FIXME: do we need release() here? MatOfDMatch.java /OpenCV Library - 2.4.7/src/org/opencv/core line 32 Java Task
FIXME: do we need release() here? MatOfDMatch.java /OpenCV Library - 2.4.7/src/org/opencv/core line 21 Java Task
FIXME: do we need release() here? MatOfDouble.java /OpenCV Library - 2.4.7/src/org/opencv/core line 19 Java Task
我的设备上也显示错误,错误消息运行然后突然打开应用程序然后关闭