Ask Your Question

iVlad's profile - activity

2014-10-12 22:05:02 -0500 received badge  Necromancer (source)
2014-04-07 23:24:24 -0500 answered a question Inconsistent results from SolvePnp

with default set of parameters (flag CV_ITERATIVE) you need min 6 points. 4 points will work only with CV_EPNP, CV_P3P flags. I am not sure why, but I got this from practical experimentation.

2014-04-07 19:22:15 -0500 asked a question solvePnP or projectPoints cannot handle lens distortions

I use openCV function projectPoints to rotate/translate and project a set of 3D points and solvePnp to find this rotation/translation. This works when distortion coefficients (lens distortion) are all zero but fails otherwise. The code is below:

const int npoints = 10; // 6 min, but  CV_P3P, CV_P3P can work with 4 points

// extrinsic
const Point3f tvec(10, 20, 30);
Point3f rvec(3, 5, 7);
cout << "Finding extrinsic parameters (PnP)" << endl;
cout<<"Test transformations: ";
cout<<"Rotation: "<<rvec<<"; translation: "<<tvec<<endl;
cout<<"Intrinsic: "<<endl;
rvec*=DEG2RAD;

// intrinsic
Mat_ <double>cameraMatrix(3, 3);
cameraMatrix << 300., 0., 200., 0, 300., 100., 0., 0., 1.;
Mat_ <double>distCoeffs(1, 5); //  (k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6]]) of 4, 5, or 8 elements.
distCoeffs << 1.2, 0.2, 0., 0., 0.;
//distCoeffs << 0.0, 0.0, 0.0, 0.0, 0.0;
cout<<"distrotion coeff: "<<distCoeffs<<endl;

cout<<"============= Running PnP..."<<endl;

vector<Point3f> objectPoints(npoints);
vector<Point2f> imagePoints(npoints);
Mat rvec_est, tvec_est;
vector<Point3f> objPts(npoints);
randu(Mat(objPts), 0.0f, 100.0f);

// project
projectPoints(Mat(objPts), Mat(rvec), Mat(tvec), cameraMatrix, distCoeffs, Mat(imagePoints));

// extrinsic
solvePnP(objPts, imagePoints, cameraMatrix, distCoeffs, rvec_est, tvec_est);
cout<<"Rotation: "<<rvec_est*RAD2DEG<<endl;
cout<<"Translation "<<tvec_est<<endl;

When all distortion coefficients are 0 the result is OK:

Finding extrinsic parameters (PnP) Test transformations: Rotation: [3, 5, 7]; translation: [10, 20, 30] distrotion coeff: [0, 0, 0, 0, 0] ============= Running PnP... Rotation: [2.999999581709123; 4.999997813985293; 6.999999826089725] Translation [9.999999792663072; 19.99999648222693; 29.99999699621362]

However when they aren't zero the result is totally wrong:

Finding extrinsic parameters (PnP) Test transformations: Rotation: [3, 5, 7]; translation: [10, 20, 30] distrotion coeff: [1.2, 0.2, 0, 0, 0] ============= Running PnP... Rotation: [-91.56479629305277; -124.3631985067845; -74.46486950666471] Translation [-69.72473511009439; -117.7463271636532; -87.27777166027946]

2013-04-03 17:02:18 -0500 answered a question Convexity Defects in OpenCV 2.4.2

ConvexityDefects() might not work well in 5-10% of cases, see conv_defect.jpg; as shown in the picture a left image is when a convexity defect was successfully extracted (little red dot between fingers) and the right one is when the function failed. I am looking into the code to report why.

2012-09-22 00:54:06 -0500 commented question comments in OpenCV source code

eventually I will do it. But I wanted to ask you, why are you concerned about merging? I would be concerned with commenting itself since it will take 99% of the overall work. You see, the difference between system guys and computer vision guys is that they really think differently.

2012-09-21 03:19:01 -0500 commented answer comments in OpenCV source code

wiki has versioning and diff functionality. it is easy to use while git is not always intuitive. Anyway, how many people did bother to add comments or do something like this with or without git?

2012-09-21 03:16:18 -0500 commented question comments in OpenCV source code

here is a start: http://opencvcomment.com The files marked with red are in need of more comments

2012-09-05 15:08:38 -0500 received badge  Good Question (source)
2012-09-05 06:18:35 -0500 received badge  Nice Question (source)
2012-09-04 18:13:02 -0500 received badge  Student (source)
2012-09-04 16:45:41 -0500 received badge  Editor (source)
2012-09-04 16:42:52 -0500 asked a question comments in OpenCV source code

It is not a secret that OpenCV source code is poorly commented. So if one wants to dive deep into the source and understand, modify or speed it up it is hard to do. I plan to create a wiki where I would start painstakingly add comments (marked in a special way to distinguish them from original ones) to the most widely used modules/functions (without modifying the original code or comments). My question is whether somebody else has undertaken a similar effort? If not, what is a best way to do this? I currently got a domain and a wiki software and plan to organize it in such a way that crowdsourcing is easy and possible wrongdoing is minimized.

My current problems is to how provide a right color scheme for C++ and what is the best form to prevent users from modifying or shifting around the original code or comments. Currently, I consider keeping new comments separately in some kind of xml file (internally) that can be fused with original code. A wiki user will see it (externally) as a fused version where original code/comments are unavailable for editing.