我正在调用C ++函数给出了这个错误:signal 11 (SIGSEGV), code 1
崩溃转储是:
Build fingerprint: 'google/hammerhead/hammerhead:6.0/MRA58K/2256973:user/release-keys'
pid: 19580, tid: 19706, name: Thread-6405 >>> com.adhamenaya <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0xfa0
Stack frame 10-21 19:25:04.423 200 200 F DEBUG : #00 pc 0041c59e /data/app/com.adhamenaya-2/lib/arm/libGrafty.so (cv::Mat::copyTo(cv::_Outp
utArray const&) const+173): Routine cv::Mat::copyTo(cv::_OutputArray const&) const at ??:?
Stack frame 10-21 19:25:04.423 200 200 F DEBUG : #01 pc 0023b034 /data/app/com.adhamenaya-2/lib/arm/libGrafty.so (cv::Mat::clone() const+56
): Routine cv::Mat::clone() const at D:/scryptech/ndk_project/OpenCV-android-sdk/sdk/native/jni/include/opencv2/core/mat.inl.hpp:628 (discriminator 1)
Stack frame 10-21 19:25:04.423 200 200 F DEBUG : #02 pc 0023b3a4 /data/app/com.adhamenaya-2/lib/arm/libGrafty.so (GraftySystem::setCurrentF
rame(cv::Mat&)+44): Routine GraftySystem::setCurrentFrame(cv::Mat&) at C:\Users\aenaya\git\GraftyAndroid\GraftyAndroid/jni/grafty-system-settings.cpp:
39
Stack frame 10-21 19:25:04.423 200 200 F DEBUG : #03 pc 002b339c /data/app/com.adhamenaya-2/lib/arm/libGrafty.so (Java_com_adhamenaya_Nativ
e_runGrafty+492): Routine Java_com_adhamenaya_Native_runGrafty at C:\Users\aenaya\git\GraftyAndroid\GraftyAndroid/jni/grafty-hr-main.cpp:96 (discrimin
ator 1)
Stack frame 10-21 19:25:04.423 200 200 F DEBUG : #04 pc 0036a627 /data/app/com.adhamenaya-2/oat/arm/base.odex (offset 0x29c000) (byte[] com
.adhamenaya.Native.runGrafty(java.lang.String, java.lang.String, java.lang.String, java.lang.Long)+170)
Stack frame 10-21 19:25:04.423 200 200 F DEBUG : #05 pc 00369f33 /data/app/com.adhamenaya-2/oat/arm/base.odex (offset 0x29c000) (void com.a
dhamenaya.MainActivity$2.run()+574)
Stack frame 10-21 19:25:04.424 200 200 F DEBUG : #06 pc 729298d1 /data/dalvik-cache/arm/system@framework@boot.oat (offset 0x1eb1000)
其中: grafty-hr-main.cpp:96
JNIEXPORT jbyteArray JNICALL Java_com_adhamenaya_Native_runGrafty(JNIEnv * env,
jobject obj, jstring faceCascadeFile, jstring noseCascadeFile,
jstring landmarks, jlong frame) {
cv::Mat& inFrame = *(cv::Mat*) frame;
line 96 >>>> gsys.setCurrentFrame(inFrame);
和:
grafty系统-settings.cpp:39
void GraftySystem::setCurrentFrame(cv::Mat& inFrame) {
cv::Size2d imgRes;
float resRatio;
line 39 >>>>> cv::Mat frame = inFrame.clone();
}
和JNI函数的调用:
Java_com_adhamenaya_Native_runGrafty
是这样的:
private Mat mGray;
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
mRgba = inputFrame.rgba();
Imgproc.cvtColor(mRgba, mGray, Imgproc.COLOR_BGRA2GRAY);
if (mRgba.empty())
return null;
else if (mRgba.channels() > 1)
Imgproc.cvtColor(mRgba, mGray, Imgproc.COLOR_BGRA2GRAY);
else
mGray = mRgba;
return mRgba;
}
...
...
result = Native.runGrafty(mFaceCascadeFile,
mNoseCascadeFile, mLandmarks,
mGray.getNativeObjAddr());
似乎是frame参数中的问题。你能帮我解决一下这个问题吗?
答案 0 :(得分:0)
只需写下
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
mGray = inputFrame.gray()
return inputFrame.rgba();
}
OpenCV为您处理转换。如果直接在onCameraFrame()回调中调用JNI代码会发生什么?