将关键点矢量转换为CvSeq

我有一个快速的OpenCV问题.是否可以采用关键点向量并将其转换为CvSeq?

提前致谢.

最佳答案 我不知道你为什么会这么想,但它应该是可能的,通过这些功能,你可以做任何你想做的事情:

我应该补充一点,以下是C和C的混合(在OpenCV中也是如此)

CreateSeq
CvSeq * cvCreateSeq(int seqFlags,int headerSize,int elemSize,CvMemStorage * storage)

SeqPush
char * cvSeqPush(CvSeq * seq,void * element = NULL)

这是代码,我还没有尝试过,如果有错误请告诉我,如果有效,我只是试一试…

vector<KeyPoint> myKeypointVector; //Your KeyPoint vector
// Do whatever you want with your vector

CvMemStorage* storage = cvCreateMemStorage(0) 
// By default the flag 0 is 64K 
// but myKeypointVector.size()*(sizeof(KeyPoint)+sizeof(CvSeq)) should work
// it may be more efficient but be careful there may have seg fault 
// (not sure about the size

CvSeq* myKeypointSeq = cvCreateSeq(0,sizeof(CvSeq),sizeof(KeyPoint),storage);
// Create the seq at the location storage

for (size_t i=0; myKeypointVector.size(); i++) {
    int* added = (int*)cvSeqPush(myKeypointSeq,&(myKeypointVector[i]));
    // Should add the KeyPoint in the Seq
}

cvClearMemStorage( storage ); 
cvReleaseMemStorage(&storage); 

朱利安,

点赞