Streaming from webcam: is it normal that the frame does not have refcount?

99封情书 提交于 2019-12-11 12:07:37

问题


I have the following code:

#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;
}

then

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.

Everything seems to be working fine, but I have looked into things and it turned out that the refcount of the frame is just a null pointer (and stays so after clone()), whereas other mats (say its clone) have refcount pointing to an int >= 0.

What is the reason for this?


回答1:


According to the docs:

clone() returns deep copy of the matrix, i.e. the data is copied.

So it makes sense that there's no increase in refcount. For more information on this subject, take a look at Memory management and reference counting.



来源:https://stackoverflow.com/questions/13400082/streaming-from-webcam-is-it-normal-that-the-frame-does-not-have-refcount

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!