Ask Your Question

cyxcw1's profile - activity

2014-04-07 02:11:37 -0600 received badge  Organizer (source)
2014-04-07 02:09:35 -0600 received badge  Editor (source)
2014-04-07 02:08:30 -0600 asked a question OpenCV vector<type> into InputArry cause the data loss problems

I have asked this question in link:stackoverflow

I want to use solvePnP function, but I found that when I chosed vector as the first parameter(it convert into InputArry), the data in the vector had lost. Part of the code is list below:

double threeD[POINT_NUM][3] = {{-11, 153, 857}, {-10, 104, 865}, {171, 62, 708}, {172, 50, 714}, {-10, 28, 880}};
double twoD[POINT_NUM][2] = {{73, 169}, {226, 173}, {313, 850}, {359, 850}, {461, 173}};

vector<Point3f> outside;
vector<Point2f> inside;

for(int i = 0; i != POINT_NUM; ++i){
        outside.push_back(Point3f(threeD[i][0], threeD[i][1], threeD[i][2]));
        inside.push_back(Point2f(twoD[i][0], twoD[i][1]));
}

InputArray ia = outside;
cout << ia.total() << endl;

the output number is "0". My OpenCV version is 2.3. I compiled the code in VS2005.