Reputation: 13
I want to use image which I used by Mat img=imread("Nature.jpg"); to inside of all functions that are in the program, I think, this can be implemented as Mat img is defined such volatile variable, is this posible?
Upvotes: 0
Views: 129
Reputation: 368
I would not recommend to declare a variable cv :: Mat as volatile, because if you are doing this surely these need to update this variable from different threads, if what you want is to use a type cv :: Mat global then type the following line outside of any function or class
cv::Mat img;
Now if you want to use this variable from another file you must write:
extern cv::Mat img;
Now if you need access multithreaded I recommend you look for a guide on mutex and multithreaded programming, because if two or more functions access the variable img at the same time your program will fail at runtime by segmentation violation.
Upvotes: 1