Accessing Point<int> (Point2i) data from memory
I've a:
const Point* points
How are datas stored in memory? I need to access points[i].x and points[i].y in ARM assembly. I've tried to load 32 bit (standard int dimension) from memory starting from *points address, but my assumption that this array is stored this way seems wrong:
points[0].x, points[0].y, points[1].x, points[1].y, ...
All elements are stored as a single vector in memory, using a pointer with the bitsize of the element to jump between the different subelements. For example a matrix element can be accessed by using the mat.at<char>(x,y) if the type of the mat elements are CV_8UC1. I guess this is the same for the points element.
What you can also try is to use std::vector of points. This will eliminate the malloc (did you forget to allocate memory in any case? ) step and problems associated with pointers. For example, std::vector<Point> points; and use push_back to add points to the vector, like this, points.push_back( Point(x,y) ); and you can access by points[i] where i is index.
Try to use vectors whenever possible (but sadly there are drawbacks too. :( But on the bright side, its way better and easy to handle than pointers)
Probably I have not explained well. Extending to Array is not the problem here.
Let's suppose we have a single Point (or Point2i, it is the same). Starting from the memory address of Point I have to access to Point.x and Point.y without calling .x and .y because "Point.x" is not a valid memory address. I'll use the memory address to access Point.x and Point.y in an Assembly method. The question is more like: how is Point2i structure stored in memory?