@@ -812,6 +812,87 @@ describe('Mat', () => {
812
812
} ) ;
813
813
} ) ;
814
814
815
+ describe ( 'mean' , ( ) => {
816
+ const mask = new cv . Mat ( 1 , 2 , cv . CV_8U , 255 ) ;
817
+ describe ( 'C1' , ( ) => {
818
+ const matData = [
819
+ [ 0.5 , 1 ]
820
+ ] ;
821
+
822
+ generateAPITests ( {
823
+ getDut : ( ) => new cv . Mat ( matData , cv . CV_32FC1 ) ,
824
+ methodName : 'mean' ,
825
+ methodNameSpace : 'Mat' ,
826
+ getOptionalArgs : ( ) => ( [
827
+ mask
828
+ ] ) ,
829
+ expectOutput : ( res ) => {
830
+ expect ( res . at ( 0 ) ) . to . eq ( 0.75 ) ;
831
+ }
832
+ } ) ;
833
+ } ) ;
834
+
835
+ describe ( 'C2' , ( ) => {
836
+ const matData = [
837
+ [ [ 0.5 , 0.5 ] , [ 1 , 1.5 ] ]
838
+ ] ;
839
+
840
+ generateAPITests ( {
841
+ getDut : ( ) => new cv . Mat ( matData , cv . CV_32FC2 ) ,
842
+ methodName : 'mean' ,
843
+ methodNameSpace : 'Mat' ,
844
+ getOptionalArgs : ( ) => ( [
845
+ mask
846
+ ] ) ,
847
+ expectOutput : ( res ) => {
848
+ expect ( res . at ( 0 ) ) . to . eq ( 0.75 ) ;
849
+ expect ( res . at ( 1 ) ) . to . eq ( 1 ) ;
850
+ }
851
+ } ) ;
852
+ } ) ;
853
+
854
+ describe ( 'C3' , ( ) => {
855
+ const matData = [
856
+ [ [ 0.5 , 0.5 , 0.5 ] , [ 1 , 1.5 , 2.5 ] ]
857
+ ] ;
858
+
859
+ generateAPITests ( {
860
+ getDut : ( ) => new cv . Mat ( matData , cv . CV_32FC3 ) ,
861
+ methodName : 'mean' ,
862
+ methodNameSpace : 'Mat' ,
863
+ getOptionalArgs : ( ) => ( [
864
+ mask
865
+ ] ) ,
866
+ expectOutput : ( res ) => {
867
+ expect ( res . at ( 0 ) ) . to . eq ( 0.75 ) ;
868
+ expect ( res . at ( 1 ) ) . to . eq ( 1 ) ;
869
+ expect ( res . at ( 2 ) ) . to . eq ( 1.5 ) ;
870
+ }
871
+ } ) ;
872
+ } ) ;
873
+
874
+ describe ( 'C4' , ( ) => {
875
+ const matData = [
876
+ [ [ 0.5 , 0.5 , 0.5 , 0.5 ] , [ 1 , 1.5 , 2.5 , 3.5 ] ]
877
+ ] ;
878
+
879
+ generateAPITests ( {
880
+ getDut : ( ) => new cv . Mat ( matData , cv . CV_32FC4 ) ,
881
+ methodName : 'mean' ,
882
+ methodNameSpace : 'Mat' ,
883
+ getOptionalArgs : ( ) => ( [
884
+ mask
885
+ ] ) ,
886
+ expectOutput : ( res ) => {
887
+ expect ( res . at ( 0 ) ) . to . eq ( 0.75 ) ;
888
+ expect ( res . at ( 1 ) ) . to . eq ( 1 ) ;
889
+ expect ( res . at ( 2 ) ) . to . eq ( 1.5 ) ;
890
+ expect ( res . at ( 3 ) ) . to . eq ( 2 ) ;
891
+ }
892
+ } ) ;
893
+ } ) ;
894
+ } ) ;
895
+
815
896
describe ( 'meanStdDev' , ( ) => {
816
897
const mask = new cv . Mat ( 20 , 20 , cv . CV_8U , 255 ) ;
817
898
generateAPITests ( {
0 commit comments