vector back to matrix

Hey guys

I have a matrix which has values stored e.g.

x1,y1
x2,y2
x3,y3

i pushed it into vector and sorted it but now i can't seem to find a way to push back into the original matrix.

code is below

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Mat ncorners;  //new corner to store the sorted vector before storing to original vector.

for (int i = 0; i < corners.rows; i++)
			vectx.push_back(corners.at<float>(i,0));

		sort( vectx.begin(), vectx.end(), compareFunction );

		for(int k=0;k<vectx.size(); k++)
		{
			for(int i=0;i<corners.rows;i++)
			{
				if(corners.at<float>(i,0)==vectx[k])
				{
					ncorners.at<Point2f>(k)=corners.at<Point2f>(i);
				}
			}
		}


i get error at ncorners.at<point2f>(k)=corners.at<Point2f>(i);

big error basically saying maybe cannot access that location of ncorners i don't know.

btw; (k,0) is x value
(k,1) is value

i want to sort it because the corner detection, when it detects corners, sometimes it would store corner i.e.

2,2; 3,5; 9,3; 4,1
2,2; 9,3; 3,5; 4,1

as you can see it detects the same corners but places in different order i don't know why, this really creates problems for my program.
thanks
Last edited on
Topic archived. No new replies allowed.