我尝试在 opencv 3.0 中构建基于像素强度比较的对象检测(pico)代码,在构建时出现类似 error: 'CLOCK_MONOTONIC' undeclared (first use in this function) 的错误。谁能告诉我如何克服这些问题吗?代码如下以及我得到的错误
float getticks()
{
struct timespec ts;
if(clock_gettime(CLOCK_MONOTONIC, &ts) < 0)
{
printf("clock_gettime error\n");
return -1.0f;
}
return ts.tv_sec + 1e-9f*ts.tv_nsec;
}
我得到的错误是
picolrn.c:94:18: error: storage size of 'ts' isn't known
struct timespec ts;
^
picolrn.c:96:19: error: 'CLOCK_MONOTONIC' undeclared (first use in this function)
if(clock_gettime(CLOCK_MONOTONIC, &ts) < 0)
^
picolrn.c:96:19: note: each undeclared identifier is reported only once for each function it appears in
make.exe[2]: *** [build/Debug/MinGW_1-Windows/picolrn.o] Error 1