| 1104 | return true; |
| 1105 | } |
| 1106 | bool Matrix::setPolyToPoly(const Point src[], const Point dst[], int count) { |
| 1107 | if ((unsigned)count > 4) { |
| 1108 | MNN_ERROR("---::setPolyToPoly count out of range %d\n", count); |
| 1109 | return false; |
| 1110 | } |
| 1111 | |
| 1112 | if (0 == count) { |
| 1113 | this->reset(); |
| 1114 | return true; |
| 1115 | } |
| 1116 | if (1 == count) { |
| 1117 | this->setTranslate(dst[0].fX - src[0].fX, dst[0].fY - src[0].fY); |
| 1118 | return true; |
| 1119 | } |
| 1120 | |
| 1121 | typedef bool (*PolyMapProc)(const Point[], Matrix*); |
| 1122 | Matrix tempMap, result; |
| 1123 | const PolyMapProc gPolyMapProcs[] = {Matrix::Poly2Proc, Matrix::Poly3Proc, Matrix::Poly4Proc}; |
| 1124 | auto proc = gPolyMapProcs[count - 2]; |
| 1125 | |
| 1126 | if (!proc(src, &tempMap)) { |
| 1127 | return false; |
| 1128 | } |
| 1129 | if (!tempMap.invert(&result)) { |
| 1130 | return false; |
| 1131 | } |
| 1132 | if (!proc(dst, &tempMap)) { |
| 1133 | return false; |
| 1134 | } |
| 1135 | this->setConcat(tempMap, result); |
| 1136 | return true; |
| 1137 | } |
| 1138 | /////////////////////////////////////////////////////////////////////////////// |
| 1139 | } // namespace CV |
| 1140 | } // namespace MNN |