如何在OpenCV中删除cvseq? [英] How do you delete a cvseq in OpenCV?

查看:118
本文介绍了如何在OpenCV中删除cvseq?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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()".

此函数似乎不存在:

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 *' 


b $ b

任何想法?

Any ideas?

推荐答案

我相信他的意思是 cvClearMemStorage


清除内存存储。这是唯一的方法(!!!)(除了cvRestoreMemStoragePos)
重用为存储分配的内存 - cvClearSeq,cvClearSet ...
不释放任何内存。

Clears memory storage. This is the only way(!!!) (besides cvRestoreMemStoragePos) to reuse memory allocated for the storage - cvClearSeq,cvClearSet ... do not free any memory. A child storage returns all the blocks to the parent when it is cleared.

从标题复制的文本:core / 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.

我将尝试用下面的代码来说明:

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 。我发现这个很有趣。有一个链接到源代码在帖子的底部。

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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆