Transplant the three-party source code used by opencv