class A
{
public:
virtual ~A() {}
virtual Process(cv::Mat& img) {}
} ;
class B : public A
{
public:
Process(cv::Mat& inputimage)
{
if (img.empty())
{
img = inputimage.clone();
return;
}
else
cv::imshow ("image", img);
}
private:
cv::Mat img;
};
遇到这种情况时,这个img总是空的。 我在我的主要代码中使用此代码的方式是:
PSEUDO CODE
int main ()`
{
A* a;
a = new B;
while(avi.notempty()
{
a.Process(nextFrame);
}
}
代码不完整但基本上问题是变量没有以某种方式存储。
答案 0 :(得分:0)
当我改变
时,问题就解决了 img.copyTo(img2);
到
img2 = img.clone();
谢谢!