5
我只是想重現here發佈的結果。如何使PerspectiveTransform工作?
我將源重寫爲EmguCV表單。
Image<Bgr, byte> image = new Image<Bgr, byte>(@"B:\perspective.png");
CvInvoke.cvShowImage("Hello World!", image);
float[,] scrp = { { 43, 18 }, { 280,40}, {19,223 }, { 304,200} };
float[,] dstp = { { 0,0}, { 320,0}, { 0,240 }, { 320,240 } };
float[,] homog = new float[3, 3];
Matrix<float> c1 = new Matrix<float>(scrp);
Matrix<float> c2 = new Matrix<float>(dstp);
Matrix<float> homogm = new Matrix<float>(homog);
CvInvoke.cvFindHomography(c1.Ptr, c2.Ptr, homogm.Ptr, Emgu.CV.CvEnum.HOMOGRAPHY_METHOD.DEFAULT, 0, IntPtr.Zero);
CvInvoke.cvGetPerspectiveTransform(c1, c2, homogm);
Image<Bgr, byte> newImage = image.WarpPerspective(homogm, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC, Emgu.CV.CvEnum.WARP.CV_WARP_DEFAULT, new Bgr(0, 0, 0));
CvInvoke.cvShowImage("newImage", newImage);
這是測試圖像。
newImage始終是空白圖像。
任何人都可以幫助我使我的源代碼工作?
爽,TNX!你有一個想法,如果我有一些與矩形對象的圖像,我怎麼能得到邊緣的比例? – Michael
你是指「邊緣比例」是什麼意思?如果您的意思是像253,211這樣的值,則必須在Paint程序或其他類似程序中手動測量圖像。 – Gqqnbig