我习惯于包装函数,但我试图包装函数 cvStartWriteSeq 并且它似乎使用宏 - CV_WRITE_SEQ_ELEM - 将元素写入opencv序列......
这是我发现的代码isaw:
CvSeqWriter writer;
cvStartWriteSeq( CV_32SC2, sizeof(CvSeq), sizeof(CvPoint), storage, &writer );
for( i = 0; i < 100; i++ )
{
CvPoint pt; pt.x = rand()%320; pt.y = rand()%240;
CV_WRITE_SEQ_ELEM( pt, writer );
}
CvSeq* seq = cvEndWriteSeq( &writer );
我熟悉使用 defcfun 来包装函数,但是在 /modules/core/include/opencv2/core/types_c.h 中我看到了宏,我很好奇我将如何完成任务。这是宏定义...
#define CV_WRITE_SEQ_ELEM( elem, writer ) \
{ \
assert( (writer).seq->elem_size == sizeof(elem)); \
if( (writer).ptr >= (writer).block_max ) \
{ \
cvCreateSeqBlock( &writer); \
} \
assert( (writer).ptr <= (writer).block_max - sizeof(elem));\
memcpy((writer).ptr, &(elem), sizeof(elem)); \
(writer).ptr += sizeof(elem); \
}
任何关于我如何做到这一点的指导都将加快获得完整 Lisp opencv 包装器的过程,非常感谢 =)