updated
This commit is contained in:
parent
365e6b7b98
commit
2d2cc3ecdf
@ -270,7 +270,7 @@ static Point3f triangulatePoint(const vector<Point2f>& ps,
|
|||||||
{
|
{
|
||||||
Mat_<double> K(cameraMatrix);
|
Mat_<double> K(cameraMatrix);
|
||||||
|
|
||||||
if( ps.size() > 2 )
|
/*if( ps.size() > 2 )
|
||||||
{
|
{
|
||||||
Mat_<double> L(ps.size()*3, 4), U, evalues;
|
Mat_<double> L(ps.size()*3, 4), U, evalues;
|
||||||
Mat_<double> P(3,4), Rt(3,4), Rt_part1=Rt.colRange(0,3), Rt_part2=Rt.colRange(3,4);
|
Mat_<double> P(3,4), Rt(3,4), Rt_part1=Rt.colRange(0,3), Rt_part2=Rt.colRange(3,4);
|
||||||
@ -296,7 +296,7 @@ static Point3f triangulatePoint(const vector<Point2f>& ps,
|
|||||||
double W = fabs(U(3,3)) > FLT_EPSILON ? 1./U(3,3) : 0;
|
double W = fabs(U(3,3)) > FLT_EPSILON ? 1./U(3,3) : 0;
|
||||||
return Point3f((float)(U(3,0)*W), (float)(U(3,1)*W), (float)(U(3,2)*W));
|
return Point3f((float)(U(3,0)*W), (float)(U(3,1)*W), (float)(U(3,2)*W));
|
||||||
}
|
}
|
||||||
else
|
else*/
|
||||||
{
|
{
|
||||||
Mat_<float> iK = K.inv();
|
Mat_<float> iK = K.inv();
|
||||||
Mat_<float> R1t = Mat_<float>(Rs[0]).t();
|
Mat_<float> R1t = Mat_<float>(Rs[0]).t();
|
||||||
@ -497,18 +497,10 @@ static void build3dmodel( const Ptr<FeatureDetector>& detector,
|
|||||||
|
|
||||||
double e1 = norm(imgpts1[0] - keypoints1[i1].pt);
|
double e1 = norm(imgpts1[0] - keypoints1[i1].pt);
|
||||||
double e2 = norm(imgpts2[0] - keypoints2[i2].pt);
|
double e2 = norm(imgpts2[0] - keypoints2[i2].pt);
|
||||||
if( e1 + e2 > 10 )
|
if( e1 + e2 > 5 )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
pairsFound++;
|
pairsFound++;
|
||||||
//pts_k[0] = imgpts1[0];
|
|
||||||
//pts_k[1] = imgpts2[0];
|
|
||||||
//objpt = triangulatePoint(pts_k, Rs_k, ts_k, cameraMatrix);
|
|
||||||
//objpts[0] = objpt;
|
|
||||||
//projectPoints(Mat(objpts), Rs_k[0], ts_k[0], cameraMatrix, Mat(), imgpts1);
|
|
||||||
//projectPoints(Mat(objpts), Rs_k[1], ts_k[1], cameraMatrix, Mat(), imgpts2);
|
|
||||||
//double e1 = norm(imgpts1[0] - keypoints1[i1].pt);
|
|
||||||
//double e2 = norm(imgpts2[0] - keypoints2[i2].pt);
|
|
||||||
|
|
||||||
//model.points.push_back(objpt);
|
//model.points.push_back(objpt);
|
||||||
pairs[Pair2i(i1+dstart[i], i2+dstart[j])] = 1;
|
pairs[Pair2i(i1+dstart[i], i2+dstart[j])] = 1;
|
||||||
|
@ -67,7 +67,7 @@ static Point3f image2plane(Point2f imgpt, const Mat& R, const Mat& tvec,
|
|||||||
|
|
||||||
static Rect extract3DBox(const Mat& frame, Mat& shownFrame, Mat& selectedObjFrame,
|
static Rect extract3DBox(const Mat& frame, Mat& shownFrame, Mat& selectedObjFrame,
|
||||||
const Mat& cameraMatrix, const Mat& rvec, const Mat& tvec,
|
const Mat& cameraMatrix, const Mat& rvec, const Mat& tvec,
|
||||||
const vector<Point3f>& box, int nobjpt)
|
const vector<Point3f>& box, int nobjpt, bool runExtraSegmentation)
|
||||||
{
|
{
|
||||||
selectedObjFrame = Mat::zeros(frame.size(), frame.type());
|
selectedObjFrame = Mat::zeros(frame.size(), frame.type());
|
||||||
if( nobjpt == 0 )
|
if( nobjpt == 0 )
|
||||||
@ -120,8 +120,13 @@ static Rect extract3DBox(const Mat& frame, Mat& shownFrame, Mat& selectedObjFram
|
|||||||
convexHull(Mat_<Point>(Mat(imgpt)), hull);
|
convexHull(Mat_<Point>(Mat(imgpt)), hull);
|
||||||
Mat selectedObjMask = Mat::zeros(frame.size(), CV_8U);
|
Mat selectedObjMask = Mat::zeros(frame.size(), CV_8U);
|
||||||
fillConvexPoly(selectedObjMask, &hull[0], hull.size(), Scalar::all(255), 8, 0);
|
fillConvexPoly(selectedObjMask, &hull[0], hull.size(), Scalar::all(255), 8, 0);
|
||||||
|
Rect roi = boundingRect(Mat(hull)) & Rect(Point(), frame.size());
|
||||||
|
|
||||||
|
///////////////// insert GrabCut here ////////////////////
|
||||||
|
//////////////////////////////////////////////////////////
|
||||||
|
|
||||||
frame.copyTo(selectedObjFrame, selectedObjMask);
|
frame.copyTo(selectedObjFrame, selectedObjMask);
|
||||||
return boundingRect(Mat(hull)) & Rect(Point(), frame.size());
|
return roi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -211,7 +216,7 @@ static int select3DBox(const string& windowname, const string& selWinName, const
|
|||||||
|
|
||||||
frame.copyTo(shownFrame);
|
frame.copyTo(shownFrame);
|
||||||
extract3DBox(frame, shownFrame, selectedObjFrame,
|
extract3DBox(frame, shownFrame, selectedObjFrame,
|
||||||
cameraMatrix, rvec, tvec, box, npt);
|
cameraMatrix, rvec, tvec, box, npt, false);
|
||||||
imshow(windowname, shownFrame);
|
imshow(windowname, shownFrame);
|
||||||
imshow(selWinName, selectedObjFrame);
|
imshow(selWinName, selectedObjFrame);
|
||||||
|
|
||||||
@ -500,7 +505,7 @@ int main(int argc, char** argv)
|
|||||||
if( !box.empty() )
|
if( !box.empty() )
|
||||||
{
|
{
|
||||||
Rect r = extract3DBox(frame, shownFrame, selectedObjFrame,
|
Rect r = extract3DBox(frame, shownFrame, selectedObjFrame,
|
||||||
cameraMatrix, rvec, tvec, box, 4);
|
cameraMatrix, rvec, tvec, box, 4, true);
|
||||||
if( r.area() )
|
if( r.area() )
|
||||||
{
|
{
|
||||||
const int maxFrameIdx = 10000;
|
const int maxFrameIdx = 10000;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user