android opencv c,Android的Opencv SDK中的opencv「C」方法

好的,如果你已經安裝OpenCV for Android,你可以使用Java類和方法來達到你的目的;如果你真的想要使用C++對象,你必須去開發NDK ...

但在你的情況下,確實沒有Java的OpenDSP for Android CvHaardetectobjects;但在這種情況下,您可以將HaarCascade加載到CascadeClassifier之後,然後您可以使用detectMultiScale執行基於HaarCascade的檢測。

而你得到的結果與CvHaardetectobjects相同。

請參見下面的代碼:爲Android

/Load the HaarCascade file into the clsssifier

try {

InputStream is3 = getResources().openRawResource(R.raw.haarcascade_mcs_mouth);

File cascadeDir = getDir("cascade", Context.MODE_PRIVATE);

File mCascadeFile = new File(cascadeDir, "haarcascade_mcs_mouth.xml");

FileOutputStream os3 = new FileOutputStream(mCascadeFile);

byte[] buffer = new byte[4096];

int bytesRead;

Log.e("","Non c'è problema PRIMA della lettura del file");

while ((bytesRead = is3.read(buffer)) != -1) {

os3.write(buffer, 0, bytesRead);

}

is3.close();

os3.close();

Log.e("","Non c'è problema con la lettura del file");

mJavaDetector = new CascadeClassifier(mCascadeFile.getAbsolutePath());

if (mJavaDetector.empty()) {

Log.e(TAG, "Failed to load cascade classifier");

mJavaDetector = null;

} else

Log.e(TAG, "Loaded cascade classifier from " + mCascadeFile.getAbsolutePath());

} catch (IOException e) {

e.printStackTrace();

Log.e(TAG, "Failed to load cascade. Exception thrown: " + e);

}

//Call detectMultiScale with the Detector that contains the cascade

mJavaDetector.detectMultiScale(mat,MapofRect,1.15,4,0,new Size(25,15),new Size(face.width(),face.height()/2));

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值