@@ -46,16 +46,15 @@ describe('warping tests', () => {
4646describe ( 'openCV comparison' , ( ) => {
4747 test ( 'nearest interpolation plants' , ( ) => {
4848 const image = testUtils . load ( 'various/plants.png' ) ;
49-
5049 const openCvResult = testUtils . load (
5150 'opencv/test_perspective_warp_plants_nearest.png' ,
5251 ) ;
5352
5453 const points = [
55- { column : 166.5 , row : 195 } ,
5654 { column : 858.5 , row : 9 } ,
5755 { column : 911.5 , row : 786 } ,
5856 { column : 154.5 , row : 611 } ,
57+ { column : 166.5 , row : 195 } ,
5958 ] ;
6059 const matrix = getPerspectiveWarp ( points , {
6160 width : 1080 ,
@@ -81,17 +80,17 @@ describe('openCV comparison', () => {
8180 expect ( result . height ) . toEqual ( openCvResult . height ) ;
8281 expect ( croppedPiece ) . toEqual ( croppedPieceOpenCv ) ;
8382 } ) ;
83+
8484 test ( 'nearest interpolation card' , ( ) => {
8585 const image = testUtils . load ( 'various/card.png' ) ;
86-
8786 const openCvResult = testUtils . load (
8887 'opencv/test_perspective_warp_card_nearest.png' ,
8988 ) ;
9089 const points = [
91- { column : 55 , row : 140 } ,
92- { column : 680 , row : 38 } ,
9390 { column : 840 , row : 340 } ,
9491 { column : 145 , row : 460 } ,
92+ { column : 55 , row : 140 } ,
93+ { column : 680 , row : 38 } ,
9594 ] ;
9695 const matrix = getPerspectiveWarp ( points , {
9796 width : 700 ,
@@ -121,16 +120,15 @@ describe('openCV comparison', () => {
121120 } ) ;
122121 test ( 'nearest interpolation plants' , ( ) => {
123122 const image = testUtils . load ( 'various/plants.png' ) ;
124-
125123 const openCvResult = testUtils . load (
126124 'opencv/test_perspective_warp_plants_linear.png' ,
127125 ) ;
128126
129127 const points = [
130128 { column : 166.5 , row : 195 } ,
131- { column : 858.5 , row : 9 } ,
132- { column : 911.5 , row : 786 } ,
133129 { column : 154.5 , row : 611 } ,
130+ { column : 911.5 , row : 786 } ,
131+ { column : 858.5 , row : 9 } ,
134132 ] ;
135133 const matrix = getPerspectiveWarp ( points , {
136134 width : 1080 ,
@@ -145,3 +143,13 @@ describe('openCV comparison', () => {
145143 expect ( result . height ) . toEqual ( openCvResult . height ) ;
146144 } ) ;
147145} ) ;
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