tags:

views:

331

answers:

1

i get the error at line below

Vertex2 = (CvPoint*)Vertices[I]; //where vertices is cvseq of contour and Vertex2 is cvpoint

i get error invalid cast from type ‘CvSeq’ to type ‘CvPoint*

how do i solve this

A: 

Are you just trying to get the address of the element in the array? in which case you would go

cvseq* Vertex2 = &Vertices[i];

A pointer called Vertex2 of type cvseq pointer whose value is the address of element i in the array Vertices.

UPDATE:

Just to help you know exactly what is wrong with your code.

'CvSeq' to type 'CvPoint*'

This is saying the you have a varaible of type CvPoint* (that would be your Vertex2) and you are trying to assign data of the type CvSeq.

thecoshman
Hai Vertex2 is of CVPoint and Vertices is of Cvseq type its not working with a bove it says cannot convert ‘CvSeq*’ to ‘CvPoint*’ in initialization
smile
with the line of code I have? Are you later trying to use Vertex2 for a function that likes to take a Cvpoint* ? what is the difference between cvseq and cvpoint? You can't alway cast from one type to another. it works for things like casting a float to an int to cut the decimal part, but trying to cast say a 'cat' to a 'flower' is too complex. to cast 'cat' to a 'flower' you would need to extend class cat to have a function that returns it data in the format of an instance of type 'flower'
thecoshman
My code looks like this else { Vertex2 = (CvPoint*)Vertices[I];//here is the error i get if(I<Vertices->total-1) { Vertex3 = (CvPoint)Vertices[I + 1]; if (Vertex3.X == -1 curve = true; }
smile
am i clear i am not able to post whole code but at first line i get the error after changing it says "convert ‘CvSeq*’ to ‘CvPoint*’ in initialization"
smile
Don't forget that you can edit you 'question' to help explain things better. I assume that this code is in a loop of some sort. "Vertex2 = (CvPoint*)Vertices[I];" this line is getting Vertices[i] and type casting it to a point to a CvPoint. This is assuming then the Vertex2 is actaully of type Cvpoint*, but your error says it can't convert CvPoint* to CvSeq* meaning, Vertex* is of type Cvseq*. thus that is what you should be typecasting to, or you should change the definition of Vertex2. your probably don't need to be typecasting or using pointers. You would use points so that you use less RAM
thecoshman