In my application I am doing something like declaring a Mat variable inside a Structure in my main.h file like
struct image_proc { Mat image; };
In my main.cpp function I declared a pointer object for that structure and allocate dynamic memory for that
struct image_proc *obj;
int main() { obj = (struct image_proc )malloc(sizeof(struct image_proc)) /Calling a function "processing with the structure handle" */ processing(obj); }
void processing(struct image_proc handle) { / Trying to access image variable for some operations / handle->image = /operation*/ -> Seg fault comes when I try to access this variable "image"
}
Why I am getting core dump when I try to access the image through pointer I cannot access the image when I do dynamic memory allocation
But when I do static memory allocation. I can able to access the variable and can I do whatever I want to do with that Why its only failing If i do dynamic allocations.
I know that Mat will do automatic memory allocation and de-allocation. I want to pass that through structure and experiment but its getting failed
Please help me with this.
Regards, Sarjoondeen.