Code Monkey home page Code Monkey logo

curvematching's Introduction

CurveMatching

Matching 2D curves in OpenCV

See http://www.morethantechnical.com/2012/12/26/2d-curve-matching-w-code/ for details.

Sample Usage

vector<Point> a,b;

//Get curve from image
GetCurveForImage("binary_image_with_silhuette.png", a, false);
ResampleCurve(a, a, 200, false);

vector<Point2d> a_p2d;
ConvertCurve(a, a_p2d);

//rotate and scale
Scalar meanpt = mean(a);
Mat_<double> trans_to = getRotationMatrix2D(Point2f(meanpt[0],meanpt[1]), 5, 0.65);

//create target curve from original curve
vector<Point2d> b_p2d;
cv::transform(a_p2d,b_p2d,trans_to);

ConvertCurve(b_p2d, b);


//Compare curves
int a_len,a_off,b_len,b_off;
double compare_score;
CompareCurvesUsingSignatureDB(a, 
			  b,
			  a_len,
			  a_off,
			  b_len,
			  b_off,
			  compare_score
			  );

vector<Point2d> a_subset(a.begin() + _a_off, a.begin() + _a_off + _a_len);
vector<Point2d> b_subset(b.begin() + _b_off, b.begin() + _b_off + _b_len);

ResampleCurve(a_subset, a_subset, 200, true);
ResampleCurve(b_subset, b_subset, 200, true);

Mat trans = Find2DRigidTransform(a_subset, b_subset);
cout << trans << endl;
vector<Point2d> a_trans;
cv::transform(a_subset,a_trans,trans);

Compile

mkdir build
cd build
cmake ..
make

curvematching's People

Contributors

royshil avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.