@@ -46,16 +46,15 @@ describe('warping tests', () => {
46
46
describe ( 'openCV comparison' , ( ) => {
47
47
test ( 'nearest interpolation plants' , ( ) => {
48
48
const image = testUtils . load ( 'various/plants.png' ) ;
49
-
50
49
const openCvResult = testUtils . load (
51
50
'opencv/test_perspective_warp_plants_nearest.png' ,
52
51
) ;
53
52
54
53
const points = [
55
- { column : 166.5 , row : 195 } ,
56
54
{ column : 858.5 , row : 9 } ,
57
55
{ column : 911.5 , row : 786 } ,
58
56
{ column : 154.5 , row : 611 } ,
57
+ { column : 166.5 , row : 195 } ,
59
58
] ;
60
59
const matrix = getPerspectiveWarp ( points , {
61
60
width : 1080 ,
@@ -81,17 +80,17 @@ describe('openCV comparison', () => {
81
80
expect ( result . height ) . toEqual ( openCvResult . height ) ;
82
81
expect ( croppedPiece ) . toEqual ( croppedPieceOpenCv ) ;
83
82
} ) ;
83
+
84
84
test ( 'nearest interpolation card' , ( ) => {
85
85
const image = testUtils . load ( 'various/card.png' ) ;
86
-
87
86
const openCvResult = testUtils . load (
88
87
'opencv/test_perspective_warp_card_nearest.png' ,
89
88
) ;
90
89
const points = [
91
- { column : 55 , row : 140 } ,
92
- { column : 680 , row : 38 } ,
93
90
{ column : 840 , row : 340 } ,
94
91
{ column : 145 , row : 460 } ,
92
+ { column : 55 , row : 140 } ,
93
+ { column : 680 , row : 38 } ,
95
94
] ;
96
95
const matrix = getPerspectiveWarp ( points , {
97
96
width : 700 ,
@@ -121,16 +120,15 @@ describe('openCV comparison', () => {
121
120
} ) ;
122
121
test ( 'nearest interpolation plants' , ( ) => {
123
122
const image = testUtils . load ( 'various/plants.png' ) ;
124
-
125
123
const openCvResult = testUtils . load (
126
124
'opencv/test_perspective_warp_plants_linear.png' ,
127
125
) ;
128
126
129
127
const points = [
130
128
{ column : 166.5 , row : 195 } ,
131
- { column : 858.5 , row : 9 } ,
132
- { column : 911.5 , row : 786 } ,
133
129
{ column : 154.5 , row : 611 } ,
130
+ { column : 911.5 , row : 786 } ,
131
+ { column : 858.5 , row : 9 } ,
134
132
] ;
135
133
const matrix = getPerspectiveWarp ( points , {
136
134
width : 1080 ,
@@ -145,3 +143,13 @@ describe('openCV comparison', () => {
145
143
expect ( result . height ) . toEqual ( openCvResult . height ) ;
146
144
} ) ;
147
145
} ) ;
146
+
147
+ describe ( 'error testing' , ( ) => {
148
+ test ( "should throw if there aren't 4 points" , ( ) => {
149
+ expect ( ( ) => {
150
+ getPerspectiveWarp ( [ { column : 1 , row : 1 } ] ) ;
151
+ } ) . toThrow (
152
+ 'The array pts must have four elements, which are the four corners. Currently, pts have 1 elements' ,
153
+ ) ;
154
+ } ) ;
155
+ } ) ;
0 commit comments