I’ve been trying to understand why the following code gives me a bad pointer on the string ‘filename’:
Mat imread(const string& filename, int flags) {
// some code returning a Mat object
}
int main() {
string s = "test.jpg";
imread(s, 0);
}
I’ve debugged step-by-step and all I’ve got was that before entering imread, the string was fine (I was able to inspect each element of it), but afterwards it was impossible to do so, and the debugger accused a Bad Ptr. I’m not sure I understand why that happens.
Just so you know, I’m using Visual Studio 2008 and OpenCV 2.2.
EDIT: I have indeed forgotten to say one important thing, that was essential for me to solve this issue: I was writing this code on a .cu file, therefore being compiled by nvcc in a first instance.
I solved this issue by separating in different files all OpenCV code from the code that involved the CUDA extension. Therefore, imread was now being called from a .cpp file and everything that involved CUDA was on different .cu and .h files.
Correct me if I’m wrong, but I don’t think this is supposed to be that way, maybe it’s a bug.