[英]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.