ATG
ATG

Reputation: 752

How does cvSeqPush work?

I am creating an application where I need to push some element in the sequence, I am using cvSeqPush, but I am not getting its second argument const void * element, I need to push a point of type cvPoint.

How is this done in C?

Upvotes: 0

Views: 1356

Answers (2)

MobileDev
MobileDev

Reputation: 3795

A couple things need to be added: 1. you will need to allocate memory to store your srcSeq 2. release memory when you're done using srcSeq

CvMemStorage* srcSeq_storage = cvCreateMemStorage(0);

CvSeq* srcSeq = cvCreateSeq(0, sizeof(CvSeq), sizeof(CvPoint), srcSeq_storage);

// now push your point element to srcSeq

cvSeqPush(srcSeq,&pnt);

// don't forget release memory

cvReleaseMemStorage(&srcSeq_storage);

Upvotes: 0

Adrian
Adrian

Reputation: 2036

That method is called to push on the sequence whatever data you have, but in your case as I guess your sequence is configured to contain CvPoints's you will have to point to that kind of data to have a correct program.

CvPoint pnt = cvPoint(x,y);
cvSeqPush(srcSeq, (CvPoint *)&pnt);

Something like this should work for you, just point to some data the sequence needs. If you need something more specific to your case you should post some code.

Upvotes: 1

Related Questions