How can I import Array<Mat> to JNI from Kotlin?

  android-studio, angular, c++, kotlin, opencv

I am new to coding JNI,
So my problem was when I debugging my Android Studio, it gives me this "error: call to implicitly-deleted copy constructor of ‘cv::Mat’"
And I don’t know why. I guess it’s because of how I try to change from ‘jlong’ and ‘jlongArray’ to ‘Mat’. My native-lib.cpp was:

Java_com_android_example_panoramacamera_fragments_CameraFragment_imagesPass(JNIEnv *env,
                                                                            jobject thiz, jlongArray image_in_,
                                                                            jlong image_out_) {
    // TODO: implement imagesPass()
    Stitcher::Mode mode = Stitcher::PANORAMA;
    Mat *image_in = (Mat*) image_in_, *image_out = (Mat*) image_out_;

    // Create a Stitcher class object with mode panoroma
    Ptr<Stitcher> stitcher = Stitcher::create(mode, false);

    // Command to stitch all the images present in the image array
    Stitcher::Status status = stitcher->stitch(*image_in, *image_out);
    if(status == Stitcher::OK){
        return (jlong) image_out;

And my kotlin-sript:

    private external fun imagesPass(imageIn: LongArray, imageOut: Long): Long

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        if (requestCode == pickImageCode && resultCode == RESULT_OK) {
            if (data != null) {
                if (data.clipData != null) {
                    val count = data.clipData!!.itemCount
                    for (i in 0 until count) {
                        val imageUri = data.clipData!!.getItemAt(i).uri
                        val imageStream: InputStream? = context?.contentResolver?.openInputStream(imageUri)
                        val bitmap = BitmapFactory.decodeStream(imageStream)
                        val mat = Mat()
                        Utils.bitmapToMat(bitmap, mat)
                        imagesMat[i] = mat
                else {
                    val imageUri =
                    val imageStream: InputStream? = imageUri?.let { context?.contentResolver?.openInputStream(it) }
                    val bitmap = BitmapFactory.decodeStream(imageStream)
                    val mat = Mat()
                    Utils.bitmapToMat(bitmap, mat)
                    imagesMat[0] = mat
            for(i in imagesMat.indices){
                longArray[i] = imagesMat[i].nativeObj
            long = imagesPass(longArray, imageStitch.nativeObj)
            imageStitch =  Mat(long)
        super.onActivityResult(requestCode, resultCode, data)

and as you can see, I have tried to import Mat but since jni.h is so limited in its language, I have to convert my Mat to Long so I can use both Array and Mat.
But then my "opencv2/core/mat.inl.hpp" start to show error:

inline Mat _InputArray::getMat(int i) const
    if( kind() == MAT && i < 0 )
        return *(const Mat*)obj; //This line gets error
    return getMat_(i);

So my question is how can I convert from jlongArray to InputArray? or How can I import Array to JNI from Kotlin?
Thank you very much.

Source: Windows Questions C++