我们在哪里得到这个参数的值? [英] Where are we getting the value of this parameter?

查看:83
本文介绍了我们在哪里得到这个参数的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

学习OpenCV 书中的一个程序:

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

而在另一个位置:

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

我们在哪里检索 pos onTrackSlide(int pos)函数从?从 cvCreateTrackbar()

Where are we retrieving the value of pos in the onTrackSlide(int pos) function from? What value will be passed to it from cvCreateTrackbar()?

推荐答案

检查文档,您会看到函数签名为:

Check the docs and you'll see the function signature is:

cvCreateTrackbar(const char* trackbarName, const char* windowName, int* value, int count, CvTrackbarCallback onChange)

请注意,最后一个参数的类型为 CvTrackbarCallback 。显然,这不是一个内置类型,而是一个由OpenCV定义的类型。因此,我们回到文档以了解更多信息,有趣的是,此信息显示:

Notice that the last parameter has the type CvTrackbarCallback. Obviously, this is not a built-in type, but a type defined by OpenCV. So we go back to the documentation to find more about it and interestingly enough, this information shows up:


函数cvCreateTrackbar具有指定名称和范围的trackbar(aka滑块或范围控制),指定要与trackbar位置同步的变量,并指定要在trackbar位置更改时调用的回调函数

在此段下面,您可以看到如何声明 CvTrackbarCallback

And right below this paragraph, you can see how a CvTrackbarCallback should be declared:

CV_EXTERN_C_FUNCPTR( void (*CvTrackbarCallback)(int pos) );

总而言之,为了调用 cvCreateTrackbar()你需要声明一个带有签名 void some_fun(int pos)的函数,以便在更新trackbar的滑块时能够被OpenCV通知。参数 int pos 通知滑块的新位置。

To summarize, in order to call cvCreateTrackbar() you need to declared a function with the signature void some_fun(int pos), to be able to be notified by OpenCV when the slider of the trackbar is updated. The argument int pos informs the new position of the slider.

这篇关于我们在哪里得到这个参数的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆