I am currently developing some stuff using OpenCv's Android API and the JNI for faster processing.

Currently, the program gets a frame from the device-camera and just forwards the RGBA-Matrix to the JNI-interfaced C++ algorithm.

This generally works, but when trying to process the matrix in any way, I get a SIGABRT -6 error with following trace:

```
D/JNI/LaneDetection(15547): Processing frame
D/JNI/LaneDetection(15547): frame type: 24
D/JNI/LaneDetection(15547): frame rows, cols: 1080, 1920
D/JNI/LaneDetection(15547): grey_frame type: 24
D/JNI/LaneDetection(15547): grey_frame rows, cols: 1080, 1920
I/DEBUG   (  242):     #00 pc 00036d58  /system/lib/libc.so (tgkill+12)
I/DEBUG   (  242):     #01 pc 00014231  /system/lib/libc.so (pthread_kill+52)
I/DEBUG   (  242):     #02 pc 00014f93  /system/lib/libc.so (raise+10)
I/DEBUG   (  242):     #03 pc 000116a5  /system/lib/libc.so (__libc_android_abort+36)
I/DEBUG   (  242):     #04 pc 0000fd3c  /system/lib/libc.so (abort+4)
I/DEBUG   (  242):     #05 pc 00724ce4  /data/app/at.sapps.sdo-2/lib/arm/libopencv_java.so (__gnu_cxx::__verbose_terminate_handler()+276)
I/DEBUG   (  242):     #06 pc 007220e8  /data/app/at.sapps.sdo-2/lib/arm/libopencv_java.so (__cxxabiv1::__terminate(void (*)())+8)
I/DEBUG   (  242):     #07 pc 0072212c  /data/app/at.sapps.sdo-2/lib/arm/libopencv_java.so (std::terminate()+20)
I/DEBUG   (  242):     #08 pc 007222b4  /data/app/at.sapps.sdo-2/lib/arm/libopencv_java.so (__cxa_throw+148)
I/DEBUG   (  242):     #09 pc 001a5a41  /data/app/at.sapps.sdo-2/lib/arm/libopencv_java.so (cv::error(cv::Exception const&)+80)
I/DEBUG   (  242):     #10 pc 00267243  /data/app/at.sapps.sdo-2/lib/arm/libopencv_java.so (cv::cvarrToMat(void const*, bool, bool, int)+134)
I/DEBUG   (  242):     #11 pc 0035bcbb  /data/app/at.sapps.sdo-2/lib/arm/libopencv_java.so (cvCvtColor+22)
I/DEBUG   (  242):     #12 pc 00006195  /data/app/at.sapps.sdo-2/lib/arm/liblane_tracker_module.so (onFrame(cv::Mat*)+252)

```

the corresponding C++ call which causes the error is the following:

```
cvCvtColor(frame, grey, CV_RGBA2GRAY); // convert to grayscale

```

As you might have noticed, matrix types and dimensions are the same. I've also tried CV\_BGRA2GRAY with the same result. (However, I am pretty sure it's an RGBA matrix, since the javaapi call is inputframe.rgba() to get the matrix..)

the Mat grey gets initialized with the following calls:

```
    Mat *grey = new Mat(frame_size, 24); // global, 24=type= same as original frame Mat
    // method init:
    video_size.height = frame->rows;
    video_size.width = frame->cols;
    frame_size = cvSize(video_size.width, video_size.height);
    grey = new cv::Mat(frame_size, 24, 3);

```

I can't figure out what the actual problem is, maybe due to my lack of c++ skills.

I appreciate every help & thank you in advance.

java code in a nutshell:

```
@Override
public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
 rgbaMat = inputFrame.rgba();
 nativeDetect(rgbaMat.getNativeObjAddr(), lanes.getNativeObjAddr());
 return rgbaMat;
}

private static native void nativeDetect(long inputImage, long lanes);

```

ANSWER: The used C methods were the root of all evil. Changing them to their C++ equivalents resolved this issue