我有以下代码:
#include<opencv2/core/core.hpp>
#include<opencv2/highgui/highgui.hpp>
int main()
{
cv::VideoCapture capture(0);
cv::Mat frame;
capture>>frame;
cv::Mat img = frame.clone();
cv::Mat img2 = frame; // here still the refcount stays null in xcode.
return 0;
}
然后
frame.refcount ==NULL; // could be wrong
img->refcount == 1; // good
img2.refcount ==NULL; // certainly wrong, should be pointing to 2, at the same address as frame.refcount.
一切似乎都工作正常,但我调查了一些事情,结果发现 refcountframe
只是一个空指针(并且在 之后保持不变clone()
),而其他垫子(比如它的克隆)的 refcount 指向一个 int >= 0。
这是什么原因?