在VideoCapture :: Release-C ++文档的链接上,这里http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html?highlight=videocapture%3A%3Aread#videocapture-release
它说这条线
“这些方法由随后的VideoCapture :: open()和VideoCapture析构函数自动调用。”
我希望有人可以告诉我我到底用什么搜索了VideoCapture析构函数,但没有明确的答案...我敢肯定,通常的VideoCapture函数会在指定的时间自动调用它,但是如果有人可以告诉我它到底是什么,确切地调用它的时间以及它在源中的位置,我将是Most Appreciative =)。
这很容易。一旦对象离开作用域,析构函数将被调用。
{ // the capture only lives inside those brackets
VideoCapture cap;
if ( cap.open() )
{
//... do some work
}
} // here it will release itself
如果尝试使用自己的课程,可能会变得更加明显:
class MyClass
{
public:
MyClass() { cerr << "created MyClass" << endl; } // constructor
~MyClass() { cerr << "destroyed MyClass" << endl; } // destructor
};
void foo()
{ // scope starts
MyClass mc;
int z=17;
z *= 3;
cerr << z << endl;
} // scope ends, mc will get destroyed.
int main()
{
return foo();
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句