简体   繁体   English

C ++-SIGSEGV在向量上执行push_back <Mat>

[英]C++ - SIGSEGV doing push_back on a vector<Mat>

I'm developing an Android App and I have this problem in my native code. 我正在开发一个Android应用,而我的本机代码中有这个问题。

These vectors are global. 这些向量是全局的。

vector<Mat> listaMatDes;
vector<Mat> listaMatKey;
vector<int> listaCols;
vector<int> listaRows;

I also have this function, in which descriptors and keyPoints contain the addresses of some Mats (using this function getNativeObjAddr()): 我也有此函数,其中描述符和关键点包含某些Mat的地址(使用此函数getNativeObjAddr()):

void rellenarObjetos(jlong* keyPoints, jlong* descriptors, jint* cols, jint* rows, int length){

    for(int i=0; i<length; i++){

        listaCols.push_back(cols[i]);
        listaRows.push_back(rows[i]);

        Mat* aux_des=(Mat*)descriptors[i];
        listaMatDes.push_back(aux_des->clone());

        Mat* aux_key=(Mat*)keyPoints[i];
        listaMatKey.push_back(aux_key->clone());
    }

}

I've checked the two auxiliary Mat and they are created well. 我已经检查了两个辅助垫,它们创建得很好。

I've this error Fatal signal 11 (SIGSEGV) at 0x00000001 (code=1) and it's caused by the line 在0x00000001(代码= 1)遇到此错误致命信号11(SIGSEGV),它是由以下行引起的

listaMatDes.push_back(aux_des->clone());

but i don't know why. 但我不知道为什么。

Try to separate listaMatDes.push_back(aux_des->clone()); 尝试分离listaMatDes.push_back(aux_des->clone()); in: 在:

Mat m = aux_des->clone();
listaMatDes.push_back(m);

This way, you can see if the error really is in the push_back, I would say it's probably in the clone. 这样,您可以查看错误是否确实在push_back中,我想可能是在克隆中。

Programming the whole day makes you crazy (and silly, at least to me), I was passing from java code an array of LOCAL mat addresses (long[] created using the function getNativeObjAddr() which return the address in memory of the mat), so It wasn't going to work... 一整天的编程使您发疯(至少对我来说是愚蠢的),我从Java代码传递了一个本地 Mat地址数组(使用函数getNativeObjAddr()创建的long [],该函数返回该Mat内存中的地址) ,所以它行不通...

I solved it by creating a long array as a class field and passing this array. 我通过创建一个长数组作为类字段并传递此数组来解决它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 TObject 后代调用 std::vector::push_back 时出现 C++ Builder bccarm 错误 - C++ Builder bccarm error when calling std::vector::push_back with TObject descendant 使用std :: vector :: push_back()时,Android本机应用程序无法启动 - Android, native app can't start when I use std::vector::push_back() android + pthread + c ++ = SIGSEGV - android + pthread + c++ = SIGSEGV Android C ++异常引发导致SIGSEGV - Android C++ exception throw causes SIGSEGV 将Mat转换为Blob,然后返回到Mat - Convert Mat to Blob and then back to Mat Android NDK C ++异常抛出SIGSEGV和__gnu_cxx :: __ verbose_terminate_handler - Android NDK C++ exception throws SIGSEGV and __gnu_cxx::__verbose_terminate_handler 使用Android NDK C ++时出现致命信号11(SIGSEGV),代码1错误 - Fatal signal 11 (SIGSEGV), code 1 error when using Android NDK C++ Android C ++到Java上的Qt与SIGSEGV的void或原始返回类型失败 - Qt on Android C++ to Java interoperability fails with SIGSEGV for void or primitive return type 创建动态链接时,Android上的Firebase C ++ SDK会因SIGSEGV Fault Addr 0x0而崩溃 - Firebase C++ SDK on Android Crashes with SIGSEGV fault addr 0x0 when creating dynamic link 如何通过android NDK(c ++)将图像放入openCV的MAT中 - How to put an image into a MAT in openCV, through the android NDK (c++)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM