I’m currently translating a Markerless AR source code written in C++ to C#, but somehow my outputs are always off the point it should be. Below picture is my output:

Red circles are supposed to be the correct destination, but instead I got the black circles. And so I’m wondering if anyone here have any suggestions on what might causing this problem.
I’m not good at describing in words, so I try and describe it in this diagram:

Video instance:
https://www.youtube.com/watch?v=3MaKHf3AIUU&feature=youtu.be
In this video:
- Left side image: Image shown are generated from Homography Matrix calculated in step 5 and step 6.
- Right side image: Image shown are generated from Homography Matrix calculated in step 8.
I uploaded my code onto GitHub: https://github.com/abc225313/MarkerLessDetector
Set marker and Train
PatternDetector.cs→train(Pattern pattern)
PatternDetector.cs→buildPatternFromImage(Mat image, Pattern pattern)Input image within
mainfunctionFeature Extraction
PatternDetector.cs→bool extractFeatures (Mat image,ref KeyPoint[] keypoints, ref Mat descriptors)Feature Matching
PatternDetector.cs→void getMatches (Mat queryDescriptors, ref DMatch[] matches)Find Homography
PatternDetector.cs→ withinstatic bool refineMatchesWithHomographyWrapping
PatternDetector.cs→ can be found withinfindPattern()Calculating Homography
PatternDetector.cs → calculated in functionfindPattern()`PerspectiveTransform
PatternDetector.cs→ withinstatic bool refineMatchesWithHomography