OpenCV: Do we need to delete CvPoint's and how to do it?
So we have something like:
//...
for(i=0;i<out->size;i++)
{
CvPoint pt1 = { out->values[ i * out->dim + 0 ], out->values[ i * out->dim + 1]};
CvPoint pt2 = { out->values[ i * out->dim + 2 ], out->values[ i * out->dim + 3 ] };
cvLine(dest开发者_JS百科ination, pt1, pt2, CV_RGB(240, 255, 255), 1, CV_AA,0);
}
//...
performed 24 times per second for something like 200 lines. Do we need to delete CvPoint's and how to do it?
You do not need to delete them, the compiler deletes the CvPoint instances automatically for you as they are stored on the stack.
You only need to delete pointers, and then only pointers to objects allocated with new
. Normally, clean up in C++ is automatically handled by destructors (e.g. CvPoint::~CvPoint
). Therefore delete
is exceptional outside destructors.
精彩评论