我想访问此成员函数中的静态数据.现在,成员函数是静态的,因此我可以将它与用C编写的第三方API一起使用,该API具有用于回调目的的typdef函数指针.基于下面的信息,什么是最好的方法来解决创建静态函数的需要,以便在我的类的其他非静态成员函数中使用来自以下函数成员的数据.也许有一种方法仍然可以使用这个静态函数,但仍然克服了无法将静态与非静态变量混合的问题.我的代码按原样工作,但无法访问以下回调函数中的数据.
void TextDetect::vtrCB(vtrTextTrack *track, void *calldata) /*acts as a callback*/
{
/*specifically would like to take data from "track" to a deep copy so that I don't loose scope over the data withing that struct */
}
Run Code Online (Sandbox Code Playgroud)
在用C编写的关联API中,我强制使用以下两行代码:
typedef void (*vtrCallback)(vtrTextTrack *track, void *calldata);
int vtrInitialize(const char *inifile, vtrCallback cb, void *calldata);
Run Code Online (Sandbox Code Playgroud)
这是我班级的标题:
#include <vtrapi.h>
#include <opencv.hpp>
class TextDetect {
const char * inifile;
vtrImage *vtrimage;
int framecount;
public:
TextDetect();
~TextDetect();
static void vtrCB(vtrTextTrack *track, void *calldata);
int vtrTest(cv::Mat);
bool …Run Code Online (Sandbox Code Playgroud)