问题描述
Bradski指出:当你想删除一个序列,可以使用cvClearSeq(),即清除序列的所有元素的程序。
Bradski states that "When you want to delete a sequence, you can use cvClearSeq(), a routine that clears all elements of the sequence."
然而,这个功能不存在于存储器存储返回分配的块要么商店或系统
HOWEVER, this function does not return allocated blocks in the memory store to either the store or to the system.
他说:如果你想获取用于其他目的的记忆,你必须通过cvClearMemStore()清除内存存储。
He says that "If you want to retrieve that memory for some other purpose, you must clear the memory store via cvClearMemStore()".
这个功能似乎并不存在:
This function does not appear to exist:
error C3861: 'cvClearMemStore': identifier not found
在勘误的书,它指出:'cvClearMemStore'应该是'cvClearMemStorage'不过这个功能需要一个指向CvMemStorage,不CvSeq
In the errata for the book, it states that: " 'cvClearMemStore' should be 'cvClearMemStorage' " but this function expects a pointer to CvMemStorage, not CvSeq.
error C2664: 'cvClearMemStorage' : cannot convert parameter 1 from 'CvSeq *' to 'CvMemStorage *'
任何想法?
推荐答案
我相信,他的意思 cvClearMemStorage()
:
清除存储器。这是唯一的方法(!!!)(除cvRestoreMemStoragePos)
重用分配给存储器 - cvClearSeq,cvClearSet ...
不释放任何内存。
孩子存储返回所有块,当它被清除父。
文本从头复制:核心/ core_c.h
Text copied from the header: core/core_c.h
你可以从错误告知,要传递错误的数据类型此功能。 ,以确切地知道如何给他们打电话。
As you can tell from the error, you are passing the wrong data type to this function. Check the docs of these functions to know exactly how to call them.
我会尝试用下面的code来说明:
I'll try to illustrate with the code below:
// Create variable to hold the memory allocated for calculations
CvMemStorage* storage = 0;
// Allocate the memory storage. Param 0 will set the block size to a default value - currently it is about 64K.
storage = cvCreateMemStorage(0);
IplImage* gray = NULL;
// <insert code to load a gray image here>
/* Retrieves contours from the binary image and returns the number of retrieved contours.
* cvFindContours will scan through the image and store connected contours in "storage".
* "contours" will point to the first contour detected.
*/
CvSeq* contours = 0;
cvFindContours(gray, storage, &contours );
// Clear the memory storage which was used before
cvClearMemStorage(storage);
// Release memory
cvReleaseMemStorage(&storage);
有一些教程在那里,说明了如何使用 cvSeq 。我发现挺有意思的。有在文章底部的源$ C $ C的链接。
There are a few tutorials out there that shows the use of cvSeq. I found this one quite interesting. There's a link to the source code at the bottom of the post.
这篇关于你如何删除OpenCV的一个cvseq?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!