Skip to content
This repository was archived by the owner on Jul 26, 2025. It is now read-only.

Commit 8eb8297

Browse files
committed
fix: fix bug and modify tests for coverage
1 parent ec3ceb3 commit 8eb8297

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/geometry/__tests__/getPerspectiveWarp.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ describe('openCV comparison', () => {
8787
'opencv/test_perspective_warp_card_nearest.png',
8888
);
8989
const points = [
90-
{ column: 840, row: 340 },
9190
{ column: 145, row: 460 },
9291
{ column: 55, row: 140 },
9392
{ column: 680, row: 38 },
93+
{ column: 840, row: 340 },
9494
];
9595
const matrix = getPerspectiveWarp(points, {
9696
width: 700,
@@ -125,10 +125,10 @@ describe('openCV comparison', () => {
125125
);
126126

127127
const points = [
128+
{ column: 858.5, row: 9 },
128129
{ column: 166.5, row: 195 },
129130
{ column: 154.5, row: 611 },
130131
{ column: 911.5, row: 786 },
131-
{ column: 858.5, row: 9 },
132132
];
133133
const matrix = getPerspectiveWarp(points, {
134134
width: 1080,

src/geometry/getPerspectiveWarp.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,12 @@ function order4Points(pts: Point[]) {
109109
let minX2 = pts[(indexMinX + 1) % pts.length].column;
110110
let indexMinX2 = (indexMinX + 1) % pts.length;
111111

112-
for (let i = 1; i < pts.length; i++) {
112+
for (let i = 0; i < pts.length; i++) {
113113
if (pts[i].column < minX2 && i !== indexMinX) {
114114
minX2 = pts[i].column;
115115
indexMinX2 = i;
116116
}
117117
}
118-
119118
if (pts[indexMinX2].row < pts[indexMinX].row) {
120119
tl = pts[indexMinX2];
121120
bl = pts[indexMinX];

0 commit comments

Comments
 (0)