简体   繁体   中英

Parameter passing

In a program in the Learning OpenCV book:

void onTrackbarSlide(int pos)
{
cvSetCaptureProperty(g_capture,CV_CAP_PROP_POS_FRAMES,pos);
}

And, in another location:

if(frames!=0)
{
cvCreateTrackbar("Position","Example3",&g_slider_position,frames,onTrackbarSlide);
}

If you see onTrackbarSlide , there is no parameter passed. In this case, what value will be passed to the onTrackSlide(int pos) method?

You are passing the address of function

void onTrackbarSlide(int pos)

as the last parameter in the function cvCreateTrackbar

This doesn't call the onTrackbarSlide . The cvCreateTrackbar method must be storing the address of the function onTrackbarSlide and using it as an Callback to intimate of some asynchronous happening.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM