opencv动态目标检测,出现明显调用表达式前的括号必须具有(指针)函数类型的问题

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了opencv动态目标检测,出现明显调用表达式前的括号必须具有(指针)函数类型的问题相关的知识,希望对你有一定的参考价值。

hog = HOGDescriptor();
hog.setSVMDetector(hog.getDefaultPeopleDetector());

vector<Rect>foundLocations,foundLocations_filtered;
hog.detectMultiScale(Img, foundLocations, 0, Size(8, 8), Size(32, 32), 1.05, 2);
Mat result = Img.clone();
size_t t,j;
for (t = 0; t < foundLocations.size(); t++)
bool toAdd = true;

if (foundLocations[t].width() * 2+10 < foundLocations[t].height())
toAdd = false;
break;
else
for (j = 0; j < foundLocations_filtered.size(); j++)

foundLocations_filtered.push_back(foundLocations[t]);
rectangle(Img, foundLocations_filtered[j], Scalar(255, 0, 0), 2, 8, 0);


namedWindow("HOG SVM Detector Demo", CV_WINDOW_AUTOSIZE);
imshow("HOG SVM Detector Demo", Img);

程序目的:利用hog对动态目标进行检测,出现了许多框。我根据框的长宽比较来选出正确目标。
问题:if (foundLocations[t].width() * 2+10 < foundLocations[t].height())出现明显调用表达式前的括号必须具有(指针)函数类型。不知道如何修改?

参考技术A width 和 height后面的括号去掉,望采纳

明显调用的表达式前的括号必须具有(指针)函数类型 编译器错误 C2064

看到“明显调用的表达式前的括号必须具有(指针)函数类型”这句时我才发现我的语文水平有多烂,怎么看都看不懂,折腾了半天才知道是哪里出了问题。

举个简单的例子

class CTest
{
	void (CTest::*m_pFun)();
	
	void CallFun()
	{
		(this->*m_pFun)();	//OK,对象指针和函数名一定要用括号括起来,函数名前面要加上*号
		this->*m_pFun();	//error
		(this->m_pFun)();	//error
	}
        //本文链接http://www.cnblogs.com/vcpp123/p/5902839.html
};

 

详细说明请参阅MSDN,链接:https://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=ZH-CN&k=k(C2064)&rd=true

编译器错误 C2064

term does not evaluate to a function taking N arguments

A call is made to a function through an expression.The expression does not evaluate to a pointer to a function that takes the specified number of arguments.

In this example, the code attempts to call non-functions as functions.The following sample generates C2064:

// C2064.cpp
int i, j;
char* p;
void func() {
	j = i();    // C2064, i is not a function
	p();        // C2064, p doesn\'t point to a function
}

You must call pointers to non-static member functions from the context of an object instance.The following sample generates C2064, and shows how to fix it:

// C2064b.cpp
struct C {
	void func1() {}
	void func2() {}
};

typedef void (C::*pFunc)();

int main() {
	C c;
	pFunc funcArray[2] = { &C::func1, &C::func2 };
	(funcArray[0])();    // C2064 
	(c.*funcArray[0])(); // OK - function called in instance context
}

Within a class, member function pointers must also indicate the calling object context.The following sample generates C2064 and shows how to fix it:

// C2064d.cpp
// Compile by using: cl /c /W4 C2064d.cpp
struct C {
	typedef void (C::*pFunc)();
	pFunc funcArray[2];
	void func1() {}
	void func2() {}
	C() {
		funcArray[0] = &C::func1;
		funcArray[1] = &C::func2;
	}
	void func3() {
		(funcArray[0])();   // C2064
		(this->*funcArray[0])(); // OK - called in this instance context
	}
};

 

以上是关于opencv动态目标检测,出现明显调用表达式前的括号必须具有(指针)函数类型的问题的主要内容,如果未能解决你的问题,请参考以下文章

明显调用括号前的表达式必须具有(指向)函数类型

明显调用的表达式前的括号必须具有(指针)函数类型 编译器错误 C2064

明显调用的表达式前的括号必须具有(指针)函数类型

使用Java和OpenCV调用YOLOv3完成实施目标检测

运动目标检测——光流法与opencv代码实现

opencv动态背景下运动目标检测 FAST+SURF+FLANN配准差分 17/12/13更新图片