Ask Your Question
0

how to use Mat img on all function without any calling function

asked 2015-10-10 05:12:53 -0600

Berkay gravatar image

updated 2015-10-10 10:01:32 -0600

ı want to use Mat img=imread("Nature.jpg"); to all func. such volatile int temp; is there any way for this?

edit retag flag offensive close merge delete

Comments

what ?????

berak gravatar imageberak ( 2015-10-10 05:17:44 -0600 )edit

ı meant that if you state volatile variable in C, you can use it on any loop as variable. it's not necassary to introduce one more times in loop which uses volatile variable. ı want to do like this for an image that ı loaded

Berkay gravatar imageBerkay ( 2015-10-10 05:26:22 -0600 )edit

please edit your question , and try to make your situation much more clear.

are you afraid, the compiler tries to optimize the imread call away ?

berak gravatar imageberak ( 2015-10-10 05:34:52 -0600 )edit

1 answer

Sort by » oldest newest most voted
1

answered 2015-10-10 06:10:46 -0600

Mehdi.Am gravatar image

updated 2015-10-10 06:15:22 -0600

Hi,I think your problem can be solved by defining a global variable.

something like this:

void main void()
{
Mat img=imread("Nature.jpg");
for(;;) //for loop #1
{
//use img here
}

for(;;) //for loop #2
{
//use img here
}
and so on...

return 0;
}
edit flag offensive delete link more

Comments

this does not solve my problem because actually ı had to indicate that any function instead of any loop. it's my mistake... ı want to use that image all functions which are out of main()

Berkay gravatar imageBerkay ( 2015-10-10 08:58:22 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-10-10 05:12:53 -0600

Seen: 222 times

Last updated: Oct 10 '15