ms-types 0.10.10 → 0.10.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/package.json +1 -1
  2. package/types/cryptoUtils.d.ts +50 -36
  3. package/types/dotocr.d.ts +9 -2
  4. package/types/file.d.ts +1 -1
  5. package/types/hid.d.ts +46 -4
  6. package/types/image.d.ts +447 -447
  7. package/types/lua/action.lua +6 -6
  8. package/types/lua/cryptoUtils.lua +7 -7
  9. package/types/lua/cv.lua +142 -142
  10. package/types/lua/dotocr.lua +4 -4
  11. package/types/lua/file.lua +1 -1
  12. package/types/lua/global.lua +5 -3
  13. package/types/lua/hid.lua +22 -22
  14. package/types/lua/http.lua +26 -11
  15. package/types/lua/image.lua +9 -5
  16. package/types/lua/node.lua +1 -1
  17. package/types/lua/pip.lua +6 -6
  18. package/types/lua/yolo.lua +1 -1
  19. package/types/lua/yolocls.lua +1 -1
  20. package/types/node.d.ts +1 -0
  21. package/types/opencv.d.ts +571 -38
  22. package/types/paddleocr.d.ts +1 -0
  23. package/types/pip.d.ts +11 -0
  24. package/types/system.d.ts +1 -0
  25. package/types/tts.d.ts +1 -1
  26. package/types/ui.d.ts +2 -0
  27. package/types/web.d.ts +16 -0
  28. package/types/zh/HID/346/250/241/345/235/227.d.ts +46 -4
  29. package/types/zh/PaddleOCR/346/250/241/345/235/227.d.ts +1 -0
  30. package/types/zh//345/212/250/344/275/234/346/250/241/345/235/227.d.ts +1 -1
  31. package/types/zh//346/202/254/346/265/256/347/252/227/346/250/241/345/235/227.d.ts +10 -0
  32. package/types/zh//346/226/207/344/273/266/346/250/241/345/235/227.d.ts +1 -1
  33. package/types/zh//347/202/271/351/230/265OCR/346/250/241/345/235/227.d.ts +9 -2
  34. package/types/zh//347/263/273/347/273/237/346/250/241/345/235/227.d.ts +1 -0
  35. package/types/zh//350/212/202/347/202/271/346/250/241/345/235/227.d.ts +1 -0
  36. package/types/zh//350/247/206/345/233/276/346/250/241/345/235/227.d.ts +2 -0
package/types/lua/cv.lua CHANGED
@@ -729,7 +729,7 @@ local _OpenCV = {}
729
729
  ---@param ex number|nil
730
730
  ---@param ey number|nil
731
731
  ---@return OpenCV.Mat|nil
732
- ---@example cv.capture(x, y, ex, ey)
732
+ ---@example cv.capture(100, 100, 200, 200)
733
733
  function _OpenCV.capture(x, y, ex, ey) return nil end
734
734
 
735
735
  --- 读取图片为 Mat 句柄。`cv` 中**唯一**支持路径类输入的加载入口(与 `image.readImage` 同源):
@@ -738,13 +738,13 @@ function _OpenCV.capture(x, y, ex, ey) return nil end
738
738
  --- 其它算子只接受 Mat 句柄。
739
739
  ---@param path string
740
740
  ---@return OpenCV.Mat|nil
741
- ---@example cv.imread(path)
741
+ ---@example cv.imread("/path/to/file.png")
742
742
  function _OpenCV.imread(path) return nil end
743
743
 
744
744
  --- 仅解码 base64 / data URI;路径与 imageId 请用 `imread`
745
745
  ---@param data string
746
746
  ---@return OpenCV.Mat|nil
747
- ---@example cv.imdecode(data)
747
+ ---@example cv.imdecode("data:image/png;base64,iVBORw0KGgo=")
748
748
  function _OpenCV.imdecode(data) return nil end
749
749
 
750
750
  --- imwrite
@@ -753,7 +753,7 @@ function _OpenCV.imdecode(data) return nil end
753
753
  ---@param path string
754
754
  ---@param mat OpenCV.Mat
755
755
  ---@return boolean
756
- ---@example cv.imwrite(path, mat)
756
+ ---@example cv.imwrite("/tmp/out.png", cv.capture())
757
757
  function _OpenCV.imwrite(path, mat) return false end
758
758
 
759
759
  --- imencode
@@ -762,60 +762,60 @@ function _OpenCV.imwrite(path, mat) return false end
762
762
  ---@param mat OpenCV.Mat
763
763
  ---@param quality number|nil
764
764
  ---@return string|nil
765
- ---@example cv.imencode(ext, mat, quality)
765
+ ---@example cv.imencode(".png", cv.capture(), 90)
766
766
  function _OpenCV.imencode(ext, mat, quality) return nil end
767
767
 
768
768
  --- fromImageId
769
769
  ---@param imageId string
770
770
  ---@return OpenCV.Mat|nil
771
- ---@example cv.fromImageId(imageId)
771
+ ---@example cv.fromImageId("screen")
772
772
  function _OpenCV.fromImageId(imageId) return nil end
773
773
 
774
774
  --- toImageId
775
775
  ---@param mat OpenCV.Mat
776
776
  ---@return string|nil
777
- ---@example cv.toImageId(mat)
777
+ ---@example cv.toImageId(cv.capture())
778
778
  function _OpenCV.toImageId(mat) return nil end
779
779
 
780
780
  --- Mat
781
781
  ---@param options OpenCV.MatCreateOptions
782
782
  ---@return OpenCV.Mat|nil
783
- ---@example cv.Mat(options)
783
+ ---@example cv.Mat({ rows = 100, cols = 100, type = cv.CV_8UC3, scalar = {0, 0, 0} })
784
784
  function _OpenCV.Mat(options) return nil end
785
785
 
786
786
  --- zeros
787
787
  ---@param options OpenCV.MatSizeOptions
788
788
  ---@return OpenCV.Mat|nil
789
- ---@example cv.zeros(options)
789
+ ---@example cv.zeros({ rows = 100, cols = 100, type = cv.CV_8UC1 })
790
790
  function _OpenCV.zeros(options) return nil end
791
791
 
792
792
  --- ones
793
793
  ---@param options OpenCV.MatSizeOptions
794
794
  ---@return OpenCV.Mat|nil
795
- ---@example cv.ones(options)
795
+ ---@example cv.ones({ rows = 100, cols = 100, type = cv.CV_8UC1 })
796
796
  function _OpenCV.ones(options) return nil end
797
797
 
798
798
  --- clone
799
799
  ---@param mat OpenCV.Mat
800
800
  ---@return OpenCV.Mat|nil
801
- ---@example cv.clone(mat)
801
+ ---@example cv.clone(cv.capture())
802
802
  function _OpenCV.clone(mat) return nil end
803
803
 
804
804
  --- empty
805
805
  ---@param mat OpenCV.Mat
806
806
  ---@return boolean
807
- ---@example cv.empty(mat)
807
+ ---@example cv.empty(cv.capture())
808
808
  function _OpenCV.empty(mat) return false end
809
809
 
810
810
  --- isRelease
811
811
  ---@param mat OpenCV.Mat
812
812
  ---@return boolean
813
- ---@example cv.isRelease(mat)
813
+ ---@example cv.isRelease(cv.capture())
814
814
  function _OpenCV.isRelease(mat) return false end
815
815
 
816
816
  --- release
817
817
  ---@param mat OpenCV.Mat
818
- ---@example cv.release(mat)
818
+ ---@example cv.release(cv.capture())
819
819
  function _OpenCV.release(mat) end
820
820
 
821
821
  --- releaseAll
@@ -825,7 +825,7 @@ function _OpenCV.releaseAll() end
825
825
  --- getSize
826
826
  ---@param mat OpenCV.Mat
827
827
  ---@return OpenCV.MatInfo|nil
828
- ---@example cv.getSize(mat)
828
+ ---@example cv.getSize(cv.capture())
829
829
  function _OpenCV.getSize(mat) return nil end
830
830
 
831
831
  --- at
@@ -833,282 +833,282 @@ function _OpenCV.getSize(mat) return nil end
833
833
  ---@param row number
834
834
  ---@param col number
835
835
  ---@return number[]|nil
836
- ---@example cv.at(mat, row, col)
836
+ ---@example cv.at(cv.capture(), 10, 10)
837
837
  function _OpenCV.at(mat, row, col) return nil end
838
838
 
839
839
  --- set
840
840
  ---@param mat OpenCV.Mat
841
841
  ---@param options OpenCV.SetOptions
842
842
  ---@return boolean
843
- ---@example cv.set(mat, options)
843
+ ---@example cv.set(cv.capture(), { row = 10, col = 10, value = {0, 255, 0} })
844
844
  function _OpenCV.set(mat, options) return false end
845
845
 
846
846
  --- copyTo
847
847
  ---@param mat OpenCV.Mat
848
848
  ---@param mask OpenCV.Mat|nil
849
849
  ---@return OpenCV.Mat|nil
850
- ---@example cv.copyTo(mat, mask)
850
+ ---@example cv.copyTo(cv.capture())
851
851
  function _OpenCV.copyTo(mat, mask) return nil end
852
852
 
853
853
  --- cvtColor;源图通道必须和转换码一致,例如 COLOR_BGR2GRAY 要 3 通道。
854
854
  ---@param mat OpenCV.Mat
855
855
  ---@param code number
856
856
  ---@return OpenCV.Mat|nil
857
- ---@example cv.cvtColor(mat, code)
857
+ ---@example cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY)
858
858
  function _OpenCV.cvtColor(mat, code) return nil end
859
859
 
860
860
  --- threshold
861
861
  ---@param mat OpenCV.Mat
862
862
  ---@param options OpenCV.ThresholdOptions
863
863
  ---@return OpenCV.Mat|nil
864
- ---@example cv.threshold(mat, options)
864
+ ---@example cv.threshold(cv.capture(), { thresh = 127, maxval = 255, type = cv.THRESH_BINARY })
865
865
  function _OpenCV.threshold(mat, options) return nil end
866
866
 
867
867
  --- adaptiveThreshold,只接受 CV_8UC1。
868
868
  ---@param mat OpenCV.Mat
869
869
  ---@param options OpenCV.AdaptiveThresholdOptions
870
870
  ---@return OpenCV.Mat|nil
871
- ---@example cv.adaptiveThreshold(mat, options)
871
+ ---@example cv.adaptiveThreshold(cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY), { maxValue = 255, adaptiveMethod = cv.ADAPTIVE_THRESH_GAUSSIAN_C, thresholdType = cv.THRESH_BINARY, blockSize = 11, C = 2 })
872
872
  function _OpenCV.adaptiveThreshold(mat, options) return nil end
873
873
 
874
874
  --- inRange
875
875
  ---@param mat OpenCV.Mat
876
876
  ---@param options OpenCV.InRangeOptions
877
877
  ---@return OpenCV.Mat|nil
878
- ---@example cv.inRange(mat, options)
878
+ ---@example cv.inRange(cv.capture(), { lowerb = {0, 0, 0}, upperb = {50, 50, 50} })
879
879
  function _OpenCV.inRange(mat, options) return nil end
880
880
 
881
881
  --- bitwise_and
882
882
  ---@param src1 OpenCV.Mat
883
883
  ---@param options OpenCV.BitwiseOptions
884
884
  ---@return OpenCV.Mat|nil
885
- ---@example cv.bitwise_and(src1, options)
885
+ ---@example cv.bitwise_and(cv.capture(), { src2 = cv.imread("/path/to/tpl.png") })
886
886
  function _OpenCV.bitwise_and(src1, options) return nil end
887
887
 
888
888
  --- bitwise_or
889
889
  ---@param src1 OpenCV.Mat
890
890
  ---@param options OpenCV.BitwiseOptions
891
891
  ---@return OpenCV.Mat|nil
892
- ---@example cv.bitwise_or(src1, options)
892
+ ---@example cv.bitwise_or(cv.capture(), { src2 = cv.imread("/path/to/tpl.png") })
893
893
  function _OpenCV.bitwise_or(src1, options) return nil end
894
894
 
895
895
  --- bitwise_xor
896
896
  ---@param src1 OpenCV.Mat
897
897
  ---@param options OpenCV.BitwiseOptions
898
898
  ---@return OpenCV.Mat|nil
899
- ---@example cv.bitwise_xor(src1, options)
899
+ ---@example cv.bitwise_xor(cv.capture(), { src2 = cv.imread("/path/to/tpl.png") })
900
900
  function _OpenCV.bitwise_xor(src1, options) return nil end
901
901
 
902
902
  --- bitwise_not
903
903
  ---@param mat OpenCV.Mat
904
904
  ---@param options OpenCV.MaskOptions|nil
905
905
  ---@return OpenCV.Mat|nil
906
- ---@example cv.bitwise_not(mat, options)
906
+ ---@example cv.bitwise_not(cv.capture())
907
907
  function _OpenCV.bitwise_not(mat, options) return nil end
908
908
 
909
909
  --- absdiff
910
910
  ---@param src1 OpenCV.Mat
911
911
  ---@param options OpenCV.Src2Options
912
912
  ---@return OpenCV.Mat|nil
913
- ---@example cv.absdiff(src1, options)
913
+ ---@example cv.absdiff(cv.capture(), { src2 = cv.imread("/path/to/tpl.png") })
914
914
  function _OpenCV.absdiff(src1, options) return nil end
915
915
 
916
916
  --- addWeighted
917
917
  ---@param src1 OpenCV.Mat
918
918
  ---@param options OpenCV.AddWeightedOptions
919
919
  ---@return OpenCV.Mat|nil
920
- ---@example cv.addWeighted(src1, options)
920
+ ---@example cv.addWeighted(cv.capture(), { src2 = cv.imread("/path/to/tpl.png"), alpha = 0.5, beta = 0.5, gamma = 0 })
921
921
  function _OpenCV.addWeighted(src1, options) return nil end
922
922
 
923
923
  --- convertScaleAbs
924
924
  ---@param mat OpenCV.Mat
925
925
  ---@param options OpenCV.ScaleOptions|nil
926
926
  ---@return OpenCV.Mat|nil
927
- ---@example cv.convertScaleAbs(mat, options)
927
+ ---@example cv.convertScaleAbs(cv.capture(), { alpha = 1.2, beta = 10 })
928
928
  function _OpenCV.convertScaleAbs(mat, options) return nil end
929
929
 
930
930
  --- countNonZero,只接受单通道 Mat;多通道返回 -1。
931
931
  ---@param mat OpenCV.Mat
932
932
  ---@return number
933
- ---@example cv.countNonZero(mat)
933
+ ---@example cv.countNonZero(cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY))
934
934
  function _OpenCV.countNonZero(mat) return 0 end
935
935
 
936
936
  --- minMaxLoc,只接受单通道 Mat;多通道返回 nil。可选 mask 必须是 CV_8UC1。
937
937
  ---@param mat OpenCV.Mat
938
938
  ---@param options OpenCV.MaskOptions|nil
939
939
  ---@return OpenCV.MinMaxLocResult|nil
940
- ---@example cv.minMaxLoc(mat, options)
940
+ ---@example cv.minMaxLoc(cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY))
941
941
  function _OpenCV.minMaxLoc(mat, options) return nil end
942
942
 
943
943
  --- mean
944
944
  ---@param mat OpenCV.Mat
945
945
  ---@param options OpenCV.MaskOptions|nil
946
946
  ---@return number[]|nil
947
- ---@example cv.mean(mat, options)
947
+ ---@example cv.mean(cv.capture())
948
948
  function _OpenCV.mean(mat, options) return nil end
949
949
 
950
950
  --- split
951
951
  ---@param mat OpenCV.Mat
952
952
  ---@return OpenCV.Mat[]|nil
953
- ---@example cv.split(mat)
953
+ ---@example cv.split(cv.capture())
954
954
  function _OpenCV.split(mat) return nil end
955
955
 
956
956
  --- merge
957
957
  ---@param channels OpenCV.Mat[]
958
958
  ---@return OpenCV.Mat|nil
959
- ---@example cv.merge(channels)
959
+ ---@example cv.merge(cv.split(cv.capture()))
960
960
  function _OpenCV.merge(channels) return nil end
961
961
 
962
962
  --- GaussianBlur
963
963
  ---@param mat OpenCV.Mat
964
964
  ---@param options OpenCV.BlurOptions
965
965
  ---@return OpenCV.Mat|nil
966
- ---@example cv.GaussianBlur(mat, options)
966
+ ---@example cv.GaussianBlur(cv.capture(), { ksize = 5, sigmaX = 1.5 })
967
967
  function _OpenCV.GaussianBlur(mat, options) return nil end
968
968
 
969
969
  --- blur
970
970
  ---@param mat OpenCV.Mat
971
971
  ---@param options OpenCV.KSizeOptions
972
972
  ---@return OpenCV.Mat|nil
973
- ---@example cv.blur(mat, options)
973
+ ---@example cv.blur(cv.capture(), { ksize = 5 })
974
974
  function _OpenCV.blur(mat, options) return nil end
975
975
 
976
976
  --- medianBlur
977
977
  ---@param mat OpenCV.Mat
978
978
  ---@param options OpenCV.MedianBlurOptions
979
979
  ---@return OpenCV.Mat|nil
980
- ---@example cv.medianBlur(mat, options)
980
+ ---@example cv.medianBlur(cv.capture(), { ksize = 5 })
981
981
  function _OpenCV.medianBlur(mat, options) return nil end
982
982
 
983
983
  --- bilateralFilter,只接受 1 或 3 通道,深度 CV_8U 或 CV_32F。
984
984
  ---@param mat OpenCV.Mat
985
985
  ---@param options OpenCV.BilateralFilterOptions
986
986
  ---@return OpenCV.Mat|nil
987
- ---@example cv.bilateralFilter(mat, options)
987
+ ---@example cv.bilateralFilter(cv.capture(), { d = 9, sigmaColor = 75, sigmaSpace = 75 })
988
988
  function _OpenCV.bilateralFilter(mat, options) return nil end
989
989
 
990
990
  --- Canny,只接受 8 位图(CV_8U,1/3/4 通道均可)。
991
991
  ---@param mat OpenCV.Mat
992
992
  ---@param options OpenCV.CannyOptions
993
993
  ---@return OpenCV.Mat|nil
994
- ---@example cv.Canny(mat, options)
994
+ ---@example cv.Canny(cv.capture(), { threshold1 = 100, threshold2 = 200 })
995
995
  function _OpenCV.Canny(mat, options) return nil end
996
996
 
997
997
  --- Sobel
998
998
  ---@param mat OpenCV.Mat
999
999
  ---@param options OpenCV.SobelOptions
1000
1000
  ---@return OpenCV.Mat|nil
1001
- ---@example cv.Sobel(mat, options)
1001
+ ---@example cv.Sobel(cv.capture(), { dx = 1, dy = 0, ksize = 3 })
1002
1002
  function _OpenCV.Sobel(mat, options) return nil end
1003
1003
 
1004
1004
  --- Laplacian
1005
1005
  ---@param mat OpenCV.Mat
1006
1006
  ---@param options OpenCV.LaplacianOptions
1007
1007
  ---@return OpenCV.Mat|nil
1008
- ---@example cv.Laplacian(mat, options)
1008
+ ---@example cv.Laplacian(cv.capture(), { ksize = 3 })
1009
1009
  function _OpenCV.Laplacian(mat, options) return nil end
1010
1010
 
1011
1011
  --- equalizeHist,只接受 CV_8UC1。
1012
1012
  ---@param mat OpenCV.Mat
1013
1013
  ---@return OpenCV.Mat|nil
1014
- ---@example cv.equalizeHist(mat)
1014
+ ---@example cv.equalizeHist(cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY))
1015
1015
  function _OpenCV.equalizeHist(mat) return nil end
1016
1016
 
1017
1017
  --- resize
1018
1018
  ---@param mat OpenCV.Mat
1019
1019
  ---@param options OpenCV.ResizeOptions
1020
1020
  ---@return OpenCV.Mat|nil
1021
- ---@example cv.resize(mat, options)
1021
+ ---@example cv.resize(cv.capture(), { width = 200, height = 200 })
1022
1022
  function _OpenCV.resize(mat, options) return nil end
1023
1023
 
1024
1024
  --- crop
1025
1025
  ---@param mat OpenCV.Mat
1026
1026
  ---@param options OpenCV.CropOptions
1027
1027
  ---@return OpenCV.Mat|nil
1028
- ---@example cv.crop(mat, options)
1028
+ ---@example cv.crop(cv.capture(), { x = 10, y = 10, ex = 200, ey = 200 })
1029
1029
  function _OpenCV.crop(mat, options) return nil end
1030
1030
 
1031
1031
  --- rotate
1032
1032
  ---@param mat OpenCV.Mat
1033
1033
  ---@param rotateCode number
1034
1034
  ---@return OpenCV.Mat|nil
1035
- ---@example cv.rotate(mat, rotateCode)
1035
+ ---@example cv.rotate(cv.capture(), cv.ROTATE_90_CLOCKWISE)
1036
1036
  function _OpenCV.rotate(mat, rotateCode) return nil end
1037
1037
 
1038
1038
  --- flip
1039
1039
  ---@param mat OpenCV.Mat
1040
1040
  ---@param flipCode number
1041
1041
  ---@return OpenCV.Mat|nil
1042
- ---@example cv.flip(mat, flipCode)
1042
+ ---@example cv.flip(cv.capture(), 1)
1043
1043
  function _OpenCV.flip(mat, flipCode) return nil end
1044
1044
 
1045
1045
  --- copyMakeBorder
1046
1046
  ---@param mat OpenCV.Mat
1047
1047
  ---@param options OpenCV.CopyMakeBorderOptions
1048
1048
  ---@return OpenCV.Mat|nil
1049
- ---@example cv.copyMakeBorder(mat, options)
1049
+ ---@example cv.copyMakeBorder(cv.capture(), { top = 10, bottom = 10, left = 10, right = 10, borderType = cv.BORDER_CONSTANT })
1050
1050
  function _OpenCV.copyMakeBorder(mat, options) return nil end
1051
1051
 
1052
1052
  --- getRotationMatrix2D
1053
1053
  ---@param options OpenCV.GetRotationMatrix2DOptions
1054
1054
  ---@return OpenCV.Mat|nil
1055
- ---@example cv.getRotationMatrix2D(options)
1055
+ ---@example cv.getRotationMatrix2D({ center = { x = 100, y = 100 }, angle = 45, scale = 1 })
1056
1056
  function _OpenCV.getRotationMatrix2D(options) return nil end
1057
1057
 
1058
1058
  --- warpAffine
1059
1059
  ---@param mat OpenCV.Mat
1060
1060
  ---@param options OpenCV.WarpAffineOptions
1061
1061
  ---@return OpenCV.Mat|nil
1062
- ---@example cv.warpAffine(mat, options)
1062
+ ---@example cv.warpAffine(cv.capture(), { M = cv.getRotationMatrix2D({ center = { x = 100, y = 100 }, angle = 45, scale = 1 }), width = 200, height = 200 })
1063
1063
  function _OpenCV.warpAffine(mat, options) return nil end
1064
1064
 
1065
1065
  --- 就地绘制,返回同一句柄
1066
1066
  ---@param mat OpenCV.Mat
1067
1067
  ---@param options OpenCV.RectangleOptions
1068
1068
  ---@return OpenCV.Mat|nil
1069
- ---@example cv.rectangle(mat, options)
1069
+ ---@example cv.rectangle(cv.capture(), { pt1 = { x = 10, y = 10 }, pt2 = { x = 200, y = 200 }, color = {0, 0, 255}, thickness = 2 })
1070
1070
  function _OpenCV.rectangle(mat, options) return nil end
1071
1071
 
1072
1072
  --- circle
1073
1073
  ---@param mat OpenCV.Mat
1074
1074
  ---@param options OpenCV.CircleOptions
1075
1075
  ---@return OpenCV.Mat|nil
1076
- ---@example cv.circle(mat, options)
1076
+ ---@example cv.circle(cv.capture(), { center = { x = 100, y = 100 }, radius = 40, color = {0, 0, 255}, thickness = 2 })
1077
1077
  function _OpenCV.circle(mat, options) return nil end
1078
1078
 
1079
1079
  --- line
1080
1080
  ---@param mat OpenCV.Mat
1081
1081
  ---@param options OpenCV.LineOptions
1082
1082
  ---@return OpenCV.Mat|nil
1083
- ---@example cv.line(mat, options)
1083
+ ---@example cv.line(cv.capture(), { pt1 = { x = 10, y = 10 }, pt2 = { x = 200, y = 200 }, color = {0, 0, 255}, thickness = 2 })
1084
1084
  function _OpenCV.line(mat, options) return nil end
1085
1085
 
1086
1086
  --- putText
1087
1087
  ---@param mat OpenCV.Mat
1088
1088
  ---@param options OpenCV.PutTextOptions
1089
1089
  ---@return OpenCV.Mat|nil
1090
- ---@example cv.putText(mat, options)
1090
+ ---@example cv.putText(cv.capture(), { text = "hello", org = { x = 20, y = 40 }, fontScale = 1, color = {0, 0, 255} })
1091
1091
  function _OpenCV.putText(mat, options) return nil end
1092
1092
 
1093
1093
  --- fillPoly
1094
1094
  ---@param mat OpenCV.Mat
1095
1095
  ---@param options OpenCV.FillPolyOptions
1096
1096
  ---@return OpenCV.Mat|nil
1097
- ---@example cv.fillPoly(mat, options)
1097
+ ---@example cv.fillPoly(cv.capture(), { pts = {{{ x = 100, y = 100 }, { x = 200, y = 100 }, { x = 150, y = 200 }}}, color = {0, 0, 255} })
1098
1098
  function _OpenCV.fillPoly(mat, options) return nil end
1099
1099
 
1100
1100
  --- polylines
1101
1101
  ---@param mat OpenCV.Mat
1102
1102
  ---@param options OpenCV.PolylinesOptions
1103
1103
  ---@return OpenCV.Mat|nil
1104
- ---@example cv.polylines(mat, options)
1104
+ ---@example cv.polylines(cv.capture(), { pts = {{{ x = 100, y = 100 }, { x = 200, y = 100 }, { x = 150, y = 200 }}}, isClosed = true, color = {0, 0, 255}, thickness = 2 })
1105
1105
  function _OpenCV.polylines(mat, options) return nil end
1106
1106
 
1107
1107
  --- drawContours
1108
1108
  ---@param mat OpenCV.Mat
1109
1109
  ---@param options OpenCV.DrawContoursOptions
1110
1110
  ---@return OpenCV.Mat|nil
1111
- ---@example cv.drawContours(mat, options)
1111
+ ---@example cv.drawContours(cv.capture(), { contours = {{{ x = 100, y = 100 }, { x = 200, y = 100 }, { x = 150, y = 200 }}}, color = {0, 0, 255}, thickness = 2 })
1112
1112
  function _OpenCV.drawContours(mat, options) return nil end
1113
1113
 
1114
1114
  --- matchTemplate
@@ -1116,7 +1116,7 @@ function _OpenCV.drawContours(mat, options) return nil end
1116
1116
  ---@param templ OpenCV.Mat
1117
1117
  ---@param options OpenCV.MatchTemplateOptions|nil
1118
1118
  ---@return OpenCV.Mat|nil
1119
- ---@example cv.matchTemplate(image, templ, options)
1119
+ ---@example cv.matchTemplate(cv.capture(), cv.imread("/path/to/tpl.png"), { method = cv.TM_CCOEFF_NORMED })
1120
1120
  function _OpenCV.matchTemplate(image, templ, options) return nil end
1121
1121
 
1122
1122
  --- matchTemplateLoc
@@ -1124,74 +1124,74 @@ function _OpenCV.matchTemplate(image, templ, options) return nil end
1124
1124
  ---@param templ OpenCV.Mat
1125
1125
  ---@param options OpenCV.MatchTemplateOptions|nil
1126
1126
  ---@return OpenCV.MatchLocResult|nil
1127
- ---@example cv.matchTemplateLoc(image, templ, options)
1127
+ ---@example cv.matchTemplateLoc(cv.capture(), cv.imread("/path/to/tpl.png"), { method = cv.TM_CCOEFF_NORMED })
1128
1128
  function _OpenCV.matchTemplateLoc(image, templ, options) return nil end
1129
1129
 
1130
1130
  --- findContours
1131
1131
  ---@param mat OpenCV.Mat
1132
1132
  ---@param options OpenCV.FindContoursOptions|nil
1133
1133
  ---@return OpenCV.FindContoursResult|nil
1134
- ---@example cv.findContours(mat, options)
1134
+ ---@example cv.findContours(cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY), { mode = cv.RETR_EXTERNAL, method = cv.CHAIN_APPROX_SIMPLE })
1135
1135
  function _OpenCV.findContours(mat, options) return nil end
1136
1136
 
1137
1137
  --- boundingRect
1138
1138
  ---@param matOrPoints OpenCV.Mat|OpenCV.Point[]
1139
1139
  ---@return OpenCV.Rect|nil
1140
- ---@example cv.boundingRect(matOrPoints)
1140
+ ---@example cv.boundingRect({{ x = 100, y = 100 }, { x = 200, y = 100 }, { x = 150, y = 200 }})
1141
1141
  function _OpenCV.boundingRect(matOrPoints) return nil end
1142
1142
 
1143
1143
  --- minAreaRect
1144
1144
  ---@param points OpenCV.Point[]
1145
1145
  ---@return OpenCV.RotatedRect|nil
1146
- ---@example cv.minAreaRect(points)
1146
+ ---@example cv.minAreaRect({{ x = 100, y = 100 }, { x = 200, y = 100 }, { x = 150, y = 200 }})
1147
1147
  function _OpenCV.minAreaRect(points) return nil end
1148
1148
 
1149
1149
  --- contourArea
1150
1150
  ---@param matOrPoints OpenCV.Mat|OpenCV.Point[]
1151
1151
  ---@param oriented boolean|nil
1152
1152
  ---@return number
1153
- ---@example cv.contourArea(matOrPoints, oriented)
1153
+ ---@example cv.contourArea({{ x = 100, y = 100 }, { x = 200, y = 100 }, { x = 150, y = 200 }}, false)
1154
1154
  function _OpenCV.contourArea(matOrPoints, oriented) return 0 end
1155
1155
 
1156
1156
  --- arcLength
1157
1157
  ---@param points OpenCV.Point[]
1158
1158
  ---@param closed boolean|nil
1159
1159
  ---@return number
1160
- ---@example cv.arcLength(points, closed)
1160
+ ---@example cv.arcLength({{ x = 100, y = 100 }, { x = 200, y = 100 }, { x = 150, y = 200 }}, true)
1161
1161
  function _OpenCV.arcLength(points, closed) return 0 end
1162
1162
 
1163
1163
  --- approxPolyDP
1164
1164
  ---@param points OpenCV.Point[]
1165
1165
  ---@param options OpenCV.ApproxPolyOptions
1166
1166
  ---@return OpenCV.Point[]|nil
1167
- ---@example cv.approxPolyDP(points, options)
1167
+ ---@example cv.approxPolyDP({{ x = 100, y = 100 }, { x = 200, y = 100 }, { x = 150, y = 200 }}, { epsilon = 2, closed = true })
1168
1168
  function _OpenCV.approxPolyDP(points, options) return nil end
1169
1169
 
1170
1170
  --- erode
1171
1171
  ---@param mat OpenCV.Mat
1172
1172
  ---@param options OpenCV.MorphOptions
1173
1173
  ---@return OpenCV.Mat|nil
1174
- ---@example cv.erode(mat, options)
1174
+ ---@example cv.erode(cv.capture(), { kernel = cv.getStructuringElement({ shape = cv.MORPH_RECT, ksize = 3 }), iterations = 1 })
1175
1175
  function _OpenCV.erode(mat, options) return nil end
1176
1176
 
1177
1177
  --- dilate
1178
1178
  ---@param mat OpenCV.Mat
1179
1179
  ---@param options OpenCV.MorphOptions
1180
1180
  ---@return OpenCV.Mat|nil
1181
- ---@example cv.dilate(mat, options)
1181
+ ---@example cv.dilate(cv.capture(), { kernel = cv.getStructuringElement({ shape = cv.MORPH_RECT, ksize = 3 }), iterations = 1 })
1182
1182
  function _OpenCV.dilate(mat, options) return nil end
1183
1183
 
1184
1184
  --- morphologyEx
1185
1185
  ---@param mat OpenCV.Mat
1186
1186
  ---@param options OpenCV.MorphologyExOptions
1187
1187
  ---@return OpenCV.Mat|nil
1188
- ---@example cv.morphologyEx(mat, options)
1188
+ ---@example cv.morphologyEx(cv.capture(), { op = cv.MORPH_OPEN, kernel = cv.getStructuringElement({ shape = cv.MORPH_RECT, ksize = 3 }) })
1189
1189
  function _OpenCV.morphologyEx(mat, options) return nil end
1190
1190
 
1191
1191
  --- getStructuringElement
1192
1192
  ---@param options OpenCV.StructuringElementOptions
1193
1193
  ---@return OpenCV.Mat|nil
1194
- ---@example cv.getStructuringElement(options)
1194
+ ---@example cv.getStructuringElement({ shape = cv.MORPH_RECT, ksize = 3 })
1195
1195
  function _OpenCV.getStructuringElement(options) return nil end
1196
1196
 
1197
1197
  --- SIFT 检测并计算描述子。
@@ -1205,14 +1205,14 @@ function _OpenCV.SIFT(mat, options) return nil end
1205
1205
  ---@param mat OpenCV.Mat
1206
1206
  ---@param options OpenCV.ORBOptions|nil
1207
1207
  ---@return OpenCV.FeatureResult|nil
1208
- ---@example cv.ORB(mat, options)
1208
+ ---@example cv.ORB(cv.capture(), { nfeatures = 500 })
1209
1209
  function _OpenCV.ORB(mat, options) return nil end
1210
1210
 
1211
1211
  --- FAST,只接受 CV_8UC1。
1212
1212
  ---@param mat OpenCV.Mat
1213
1213
  ---@param options OpenCV.FASTOptions|nil
1214
1214
  ---@return OpenCV.FASTResult|nil
1215
- ---@example cv.FAST(mat, options)
1215
+ ---@example cv.FAST(cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY), { threshold = 20 })
1216
1216
  function _OpenCV.FAST(mat, options) return nil end
1217
1217
 
1218
1218
  --- 暴力匹配描述子,返回 DMatch 数组
@@ -1220,7 +1220,7 @@ function _OpenCV.FAST(mat, options) return nil end
1220
1220
  ---@param trainDescriptors OpenCV.Mat
1221
1221
  ---@param options OpenCV.MatcherOptions|nil
1222
1222
  ---@return OpenCV.DMatch[]|nil
1223
- ---@example cv.BFMatcher(queryDescriptors, trainDescriptors, options)
1223
+ ---@example cv.BFMatcher(cv.capture(), cv.imread("/path/to/tpl.png"), { normType = cv.NORM_HAMMING })
1224
1224
  function _OpenCV.BFMatcher(queryDescriptors, trainDescriptors, options) return nil end
1225
1225
 
1226
1226
  --- K 近邻匹配;可设 ratio 做 Lowe 筛选
@@ -1228,116 +1228,116 @@ function _OpenCV.BFMatcher(queryDescriptors, trainDescriptors, options) return n
1228
1228
  ---@param trainDescriptors OpenCV.Mat
1229
1229
  ---@param options OpenCV.KnnMatchOptions|nil
1230
1230
  ---@return OpenCV.DMatch[][]|nil
1231
- ---@example cv.knnMatch(queryDescriptors, trainDescriptors, options)
1231
+ ---@example cv.knnMatch(cv.capture(), cv.imread("/path/to/tpl.png"), { k = 2, ratio = 0.75 })
1232
1232
  function _OpenCV.knnMatch(queryDescriptors, trainDescriptors, options) return nil end
1233
1233
 
1234
1234
  --- 绘制关键点,返回新 Mat 句柄
1235
1235
  ---@param mat OpenCV.Mat
1236
1236
  ---@param options OpenCV.DrawKeypointsOptions
1237
1237
  ---@return OpenCV.Mat|nil
1238
- ---@example cv.drawKeypoints(mat, options)
1238
+ ---@example cv.drawKeypoints(cv.capture(), { keypoints = {{ x = 100, y = 100, size = 8 }}, color = {0, 0, 255} })
1239
1239
  function _OpenCV.drawKeypoints(mat, options) return nil end
1240
1240
 
1241
1241
  --- 绘制匹配连线
1242
1242
  ---@param mat OpenCV.Mat
1243
1243
  ---@param options OpenCV.DrawMatchesOptions
1244
1244
  ---@return OpenCV.Mat|nil
1245
- ---@example cv.drawMatches(mat, options)
1245
+ ---@example cv.drawMatches(cv.capture(), { img2 = cv.imread("/path/to/tpl.png"), keypoints1 = {{ x = 40, y = 40, size = 8 }}, keypoints2 = {{ x = 80, y = 80, size = 8 }}, matches = {{ queryIdx = 0, trainIdx = 0, distance = 0.1 }} })
1246
1246
  function _OpenCV.drawMatches(mat, options) return nil end
1247
1247
 
1248
1248
  --- 计算单应矩阵,返回 3x3 Mat 句柄
1249
1249
  ---@param options OpenCV.FindHomographyOptions
1250
1250
  ---@return OpenCV.Mat|nil
1251
- ---@example cv.findHomography(options)
1251
+ ---@example cv.findHomography({ srcPoints = {{ x = 100, y = 100 }, { x = 200, y = 100 }, { x = 150, y = 200 }}, dstPoints = {{ x = 10, y = 10 }, { x = 110, y = 10 }, { x = 60, y = 110 }} })
1252
1252
  function _OpenCV.findHomography(options) return nil end
1253
1253
 
1254
1254
  --- 透视变换图像
1255
1255
  ---@param mat OpenCV.Mat
1256
1256
  ---@param options OpenCV.WarpPerspectiveOptions
1257
1257
  ---@return OpenCV.Mat|nil
1258
- ---@example cv.warpPerspective(mat, options)
1258
+ ---@example cv.warpPerspective(cv.capture(), { M = cv.getPerspectiveTransform({ srcPoints = {{ x = 100, y = 100 }, { x = 200, y = 100 }, { x = 150, y = 200 }}, dstPoints = {{ x = 0, y = 0 }, { x = 200, y = 0 }, { x = 100, y = 200 }} }), width = 200, height = 200 })
1259
1259
  function _OpenCV.warpPerspective(mat, options) return nil end
1260
1260
 
1261
1261
  --- 用单应矩阵变换点集
1262
1262
  ---@param points OpenCV.Point[]
1263
1263
  ---@param options OpenCV.MatrixOptions
1264
1264
  ---@return OpenCV.Point[]|nil
1265
- ---@example cv.perspectiveTransform(points, options)
1265
+ ---@example cv.perspectiveTransform({{ x = 100, y = 100 }, { x = 200, y = 100 }, { x = 150, y = 200 }}, { M = cv.getPerspectiveTransform({ srcPoints = {{ x = 100, y = 100 }, { x = 200, y = 100 }, { x = 150, y = 200 }}, dstPoints = {{ x = 0, y = 0 }, { x = 200, y = 0 }, { x = 100, y = 200 }} }) })
1266
1266
  function _OpenCV.perspectiveTransform(points, options) return nil end
1267
1267
 
1268
1268
  --- Shi-Tomasi 角点
1269
1269
  ---@param mat OpenCV.Mat
1270
1270
  ---@param options OpenCV.GoodFeaturesOptions
1271
1271
  ---@return OpenCV.Point[]|nil
1272
- ---@example cv.goodFeaturesToTrack(mat, options)
1272
+ ---@example cv.goodFeaturesToTrack(cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY), { maxCorners = 50, qualityLevel = 0.01, minDistance = 10 })
1273
1273
  function _OpenCV.goodFeaturesToTrack(mat, options) return nil end
1274
1274
 
1275
1275
  --- 概率霍夫直线,返回 {x1,y1,x2,y2}[]
1276
1276
  ---@param mat OpenCV.Mat
1277
1277
  ---@param options OpenCV.HoughLinesPOptions
1278
1278
  ---@return OpenCV.HoughLine[]|nil
1279
- ---@example cv.HoughLinesP(mat, options)
1279
+ ---@example cv.HoughLinesP(cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY), { rho = 1, theta = 3.14 / 180, threshold = 50 })
1280
1280
  function _OpenCV.HoughLinesP(mat, options) return nil end
1281
1281
 
1282
1282
  --- 霍夫圆,返回 {x,y,radius}[]
1283
1283
  ---@param mat OpenCV.Mat
1284
1284
  ---@param options OpenCV.HoughCirclesOptions
1285
1285
  ---@return OpenCV.HoughCircle[]|nil
1286
- ---@example cv.HoughCircles(mat, options)
1286
+ ---@example cv.HoughCircles(cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY), { dp = 1, minDist = 20 })
1287
1287
  function _OpenCV.HoughCircles(mat, options) return nil end
1288
1288
 
1289
1289
  --- CLAHE 对比度受限自适应直方图均衡
1290
1290
  ---@param mat OpenCV.Mat
1291
1291
  ---@param options OpenCV.CLAHEOptions|nil
1292
1292
  ---@return OpenCV.Mat|nil
1293
- ---@example cv.CLAHE(mat, options)
1293
+ ---@example cv.CLAHE(cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY), { clipLimit = 2.0, tileGridSize = {8, 8} })
1294
1294
  function _OpenCV.CLAHE(mat, options) return nil end
1295
1295
 
1296
1296
  --- pyrDown
1297
1297
  ---@param mat OpenCV.Mat
1298
1298
  ---@return OpenCV.Mat|nil
1299
- ---@example cv.pyrDown(mat)
1299
+ ---@example cv.pyrDown(cv.capture())
1300
1300
  function _OpenCV.pyrDown(mat) return nil end
1301
1301
 
1302
1302
  --- pyrUp
1303
1303
  ---@param mat OpenCV.Mat
1304
1304
  ---@return OpenCV.Mat|nil
1305
- ---@example cv.pyrUp(mat)
1305
+ ---@example cv.pyrUp(cv.capture())
1306
1306
  function _OpenCV.pyrUp(mat) return nil end
1307
1307
 
1308
1308
  --- Scharr
1309
1309
  ---@param mat OpenCV.Mat
1310
1310
  ---@param options OpenCV.ScharrOptions
1311
1311
  ---@return OpenCV.Mat|nil
1312
- ---@example cv.Scharr(mat, options)
1312
+ ---@example cv.Scharr(cv.capture(), { dx = 1, dy = 0 })
1313
1313
  function _OpenCV.Scharr(mat, options) return nil end
1314
1314
 
1315
1315
  --- boxFilter
1316
1316
  ---@param mat OpenCV.Mat
1317
1317
  ---@param options OpenCV.BoxFilterOptions
1318
1318
  ---@return OpenCV.Mat|nil
1319
- ---@example cv.boxFilter(mat, options)
1319
+ ---@example cv.boxFilter(cv.capture(), { ksize = 5 })
1320
1320
  function _OpenCV.boxFilter(mat, options) return nil end
1321
1321
 
1322
1322
  --- 就地洪水填充,返回填充像素数与外接矩形
1323
1323
  ---@param mat OpenCV.Mat
1324
1324
  ---@param options OpenCV.FloodFillOptions
1325
1325
  ---@return OpenCV.FloodFillResult|nil
1326
- ---@example cv.floodFill(mat, options)
1326
+ ---@example cv.floodFill(cv.capture(), { seedPoint = { x = 10, y = 10 }, newVal = {0, 0, 255} })
1327
1327
  function _OpenCV.floodFill(mat, options) return nil end
1328
1328
 
1329
1329
  --- convexHull
1330
1330
  ---@param points OpenCV.Point[]
1331
1331
  ---@param options OpenCV.ConvexHullOptions|nil
1332
1332
  ---@return OpenCV.Point[]|nil
1333
- ---@example cv.convexHull(points, options)
1333
+ ---@example cv.convexHull({{ x = 100, y = 100 }, { x = 200, y = 100 }, { x = 150, y = 200 }})
1334
1334
  function _OpenCV.convexHull(points, options) return nil end
1335
1335
 
1336
1336
  --- moments;Mat 输入必须是单通道栅格或 2 通道点集。
1337
1337
  ---@param matOrPoints OpenCV.Mat|OpenCV.Point[]
1338
1338
  ---@param options OpenCV.MomentsOptions|nil
1339
1339
  ---@return OpenCV.MomentsResult|nil
1340
- ---@example cv.moments(matOrPoints, options)
1340
+ ---@example cv.moments({{ x = 100, y = 100 }, { x = 200, y = 100 }, { x = 150, y = 200 }})
1341
1341
  function _OpenCV.moments(matOrPoints, options) return nil end
1342
1342
 
1343
1343
  --- matchShapes
@@ -1345,106 +1345,106 @@ function _OpenCV.moments(matOrPoints, options) return nil end
1345
1345
  ---@param contour2 OpenCV.Mat|OpenCV.Point[]
1346
1346
  ---@param options OpenCV.MatchShapesOptions|nil
1347
1347
  ---@return number
1348
- ---@example cv.matchShapes(contour1, contour2, options)
1348
+ ---@example cv.matchShapes({{ x = 100, y = 100 }, { x = 200, y = 100 }, { x = 150, y = 200 }}, {{ x = 100, y = 100 }, { x = 200, y = 100 }, { x = 150, y = 200 }})
1349
1349
  function _OpenCV.matchShapes(contour1, contour2, options) return 0 end
1350
1350
 
1351
1351
  --- connectedComponentsWithStats
1352
1352
  ---@param mat OpenCV.Mat
1353
1353
  ---@return OpenCV.ConnectedComponentsResult|nil
1354
- ---@example cv.connectedComponentsWithStats(mat)
1354
+ ---@example cv.connectedComponentsWithStats(cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY))
1355
1355
  function _OpenCV.connectedComponentsWithStats(mat) return nil end
1356
1356
 
1357
1357
  --- distanceTransform
1358
1358
  ---@param mat OpenCV.Mat
1359
1359
  ---@param options OpenCV.DistanceTransformOptions|nil
1360
1360
  ---@return OpenCV.Mat|nil
1361
- ---@example cv.distanceTransform(mat, options)
1361
+ ---@example cv.distanceTransform(cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY))
1362
1362
  function _OpenCV.distanceTransform(mat, options) return nil end
1363
1363
 
1364
1364
  --- add
1365
1365
  ---@param src1 OpenCV.Mat
1366
1366
  ---@param options OpenCV.ArithMaskOptions
1367
1367
  ---@return OpenCV.Mat|nil
1368
- ---@example cv.add(src1, options)
1368
+ ---@example cv.add(cv.capture(), { src2 = cv.imread("/path/to/tpl.png") })
1369
1369
  function _OpenCV.add(src1, options) return nil end
1370
1370
 
1371
1371
  --- subtract
1372
1372
  ---@param src1 OpenCV.Mat
1373
1373
  ---@param options OpenCV.ArithMaskOptions
1374
1374
  ---@return OpenCV.Mat|nil
1375
- ---@example cv.subtract(src1, options)
1375
+ ---@example cv.subtract(cv.capture(), { src2 = cv.imread("/path/to/tpl.png") })
1376
1376
  function _OpenCV.subtract(src1, options) return nil end
1377
1377
 
1378
1378
  --- multiply
1379
1379
  ---@param src1 OpenCV.Mat
1380
1380
  ---@param options OpenCV.ArithScaleOptions
1381
1381
  ---@return OpenCV.Mat|nil
1382
- ---@example cv.multiply(src1, options)
1382
+ ---@example cv.multiply(cv.capture(), { src2 = cv.imread("/path/to/tpl.png") })
1383
1383
  function _OpenCV.multiply(src1, options) return nil end
1384
1384
 
1385
1385
  --- divide
1386
1386
  ---@param src1 OpenCV.Mat
1387
1387
  ---@param options OpenCV.ArithScaleOptions
1388
1388
  ---@return OpenCV.Mat|nil
1389
- ---@example cv.divide(src1, options)
1389
+ ---@example cv.divide(cv.capture(), { src2 = cv.imread("/path/to/tpl.png") })
1390
1390
  function _OpenCV.divide(src1, options) return nil end
1391
1391
 
1392
1392
  --- normalize
1393
1393
  ---@param mat OpenCV.Mat
1394
1394
  ---@param options OpenCV.NormalizeOptions|nil
1395
1395
  ---@return OpenCV.Mat|nil
1396
- ---@example cv.normalize(mat, options)
1396
+ ---@example cv.normalize(cv.capture(), { alpha = 0, beta = 255, normType = cv.NORM_MINMAX })
1397
1397
  function _OpenCV.normalize(mat, options) return nil end
1398
1398
 
1399
1399
  --- norm
1400
1400
  ---@param mat OpenCV.Mat
1401
1401
  ---@param options OpenCV.NormOptions|nil
1402
1402
  ---@return number
1403
- ---@example cv.norm(mat, options)
1403
+ ---@example cv.norm(cv.capture())
1404
1404
  function _OpenCV.norm(mat, options) return 0 end
1405
1405
 
1406
1406
  --- meanStdDev
1407
1407
  ---@param mat OpenCV.Mat
1408
1408
  ---@param options OpenCV.MaskOptions|nil
1409
1409
  ---@return OpenCV.MeanStdDevResult|nil
1410
- ---@example cv.meanStdDev(mat, options)
1410
+ ---@example cv.meanStdDev(cv.capture())
1411
1411
  function _OpenCV.meanStdDev(mat, options) return nil end
1412
1412
 
1413
1413
  --- findNonZero
1414
1414
  ---@param mat OpenCV.Mat
1415
1415
  ---@return OpenCV.Point[]|nil
1416
- ---@example cv.findNonZero(mat)
1416
+ ---@example cv.findNonZero(cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY))
1417
1417
  function _OpenCV.findNonZero(mat) return nil end
1418
1418
 
1419
1419
  --- hconcat
1420
1420
  ---@param mats OpenCV.Mat[]
1421
1421
  ---@return OpenCV.Mat|nil
1422
- ---@example cv.hconcat(mats)
1422
+ ---@example cv.hconcat({cv.capture(), cv.imread("/path/to/tpl.png")})
1423
1423
  function _OpenCV.hconcat(mats) return nil end
1424
1424
 
1425
1425
  --- vconcat
1426
1426
  ---@param mats OpenCV.Mat[]
1427
1427
  ---@return OpenCV.Mat|nil
1428
- ---@example cv.vconcat(mats)
1428
+ ---@example cv.vconcat({cv.capture(), cv.imread("/path/to/tpl.png")})
1429
1429
  function _OpenCV.vconcat(mats) return nil end
1430
1430
 
1431
1431
  --- getPerspectiveTransform
1432
1432
  ---@param options OpenCV.PointPairOptions
1433
1433
  ---@return OpenCV.Mat|nil
1434
- ---@example cv.getPerspectiveTransform(options)
1434
+ ---@example cv.getPerspectiveTransform({ srcPoints = {{ x = 100, y = 100 }, { x = 200, y = 100 }, { x = 150, y = 200 }}, dstPoints = {{ x = 0, y = 0 }, { x = 200, y = 0 }, { x = 100, y = 200 }} })
1435
1435
  function _OpenCV.getPerspectiveTransform(options) return nil end
1436
1436
 
1437
1437
  --- getAffineTransform
1438
1438
  ---@param options OpenCV.PointPairOptions
1439
1439
  ---@return OpenCV.Mat|nil
1440
- ---@example cv.getAffineTransform(options)
1440
+ ---@example cv.getAffineTransform({ srcPoints = {{ x = 0, y = 0 }, { x = 100, y = 0 }, { x = 0, y = 100 }}, dstPoints = {{ x = 10, y = 10 }, { x = 110, y = 10 }, { x = 10, y = 110 }} })
1441
1441
  function _OpenCV.getAffineTransform(options) return nil end
1442
1442
 
1443
1443
  --- FlannBasedMatcher
1444
1444
  ---@param queryDescriptors OpenCV.Mat
1445
1445
  ---@param trainDescriptors OpenCV.Mat
1446
1446
  ---@return OpenCV.DMatch[]|nil
1447
- ---@example cv.FlannBasedMatcher(queryDescriptors, trainDescriptors)
1447
+ ---@example cv.FlannBasedMatcher(cv.capture(), cv.imread("/path/to/tpl.png"))
1448
1448
  function _OpenCV.FlannBasedMatcher(queryDescriptors, trainDescriptors) return nil end
1449
1449
 
1450
1450
  --- flannKnnMatch
@@ -1452,14 +1452,14 @@ function _OpenCV.FlannBasedMatcher(queryDescriptors, trainDescriptors) return ni
1452
1452
  ---@param trainDescriptors OpenCV.Mat
1453
1453
  ---@param options OpenCV.FlannKnnOptions|nil
1454
1454
  ---@return OpenCV.DMatch[][]|nil
1455
- ---@example cv.flannKnnMatch(queryDescriptors, trainDescriptors, options)
1455
+ ---@example cv.flannKnnMatch(cv.capture(), cv.imread("/path/to/tpl.png"), { k = 2, ratio = 0.75 })
1456
1456
  function _OpenCV.flannKnnMatch(queryDescriptors, trainDescriptors, options) return nil end
1457
1457
 
1458
1458
  --- calcHist
1459
1459
  ---@param mat OpenCV.Mat
1460
1460
  ---@param options OpenCV.CalcHistOptions|nil
1461
1461
  ---@return OpenCV.Mat|nil
1462
- ---@example cv.calcHist(mat, options)
1462
+ ---@example cv.calcHist(cv.capture(), { channels = {0}, histSize = {256}, ranges = {0, 256} })
1463
1463
  function _OpenCV.calcHist(mat, options) return nil end
1464
1464
 
1465
1465
  --- compareHist
@@ -1467,239 +1467,239 @@ function _OpenCV.calcHist(mat, options) return nil end
1467
1467
  ---@param H2 OpenCV.Mat
1468
1468
  ---@param options OpenCV.MethodOptions|nil
1469
1469
  ---@return number
1470
- ---@example cv.compareHist(H1, H2, options)
1470
+ ---@example cv.compareHist(cv.capture(), cv.imread("/path/to/tpl.png"), { method = cv.HISTCMP_CORREL })
1471
1471
  function _OpenCV.compareHist(H1, H2, options) return 0 end
1472
1472
 
1473
1473
  --- boxPoints
1474
1474
  ---@param options OpenCV.BoxPointsOptions
1475
1475
  ---@return OpenCV.Point[]|nil
1476
- ---@example cv.boxPoints(options)
1476
+ ---@example cv.boxPoints({ center = { x = 100, y = 100 }, size = { width = 80, height = 40 }, angle = 15 })
1477
1477
  function _OpenCV.boxPoints(options) return nil end
1478
1478
 
1479
1479
  --- pointPolygonTest
1480
1480
  ---@param contour OpenCV.Point[]
1481
1481
  ---@param ptOrOptions OpenCV.Point|OpenCV.PointPolygonTestOptions
1482
1482
  ---@return number
1483
- ---@example cv.pointPolygonTest(contour, ptOrOptions)
1483
+ ---@example cv.pointPolygonTest({{ x = 100, y = 100 }, { x = 200, y = 100 }, { x = 150, y = 200 }}, { pt = { x = 150, y = 120 }, measureDist = true })
1484
1484
  function _OpenCV.pointPolygonTest(contour, ptOrOptions) return 0 end
1485
1485
 
1486
1486
  --- minEnclosingCircle
1487
1487
  ---@param points OpenCV.Point[]
1488
1488
  ---@return OpenCV.MinEnclosingCircleResult|nil
1489
- ---@example cv.minEnclosingCircle(points)
1489
+ ---@example cv.minEnclosingCircle({{ x = 100, y = 100 }, { x = 200, y = 100 }, { x = 150, y = 200 }})
1490
1490
  function _OpenCV.minEnclosingCircle(points) return nil end
1491
1491
 
1492
1492
  --- 椭圆拟合,至少 5 个点;可用于圆形/椭圆控件轮廓
1493
1493
  ---@param points OpenCV.Point[]
1494
1494
  ---@return OpenCV.RotatedRect|nil
1495
- ---@example cv.fitEllipse(points)
1495
+ ---@example cv.fitEllipse({{ x = 100, y = 100 }, { x = 200, y = 100 }, { x = 150, y = 200 }})
1496
1496
  function _OpenCV.fitEllipse(points) return nil end
1497
1497
 
1498
1498
  --- filter2D
1499
1499
  ---@param mat OpenCV.Mat
1500
1500
  ---@param options OpenCV.Filter2DOptions
1501
1501
  ---@return OpenCV.Mat|nil
1502
- ---@example cv.filter2D(mat, options)
1502
+ ---@example cv.filter2D(cv.capture(), { kernel = cv.getStructuringElement({ shape = cv.MORPH_RECT, ksize = 3 }) })
1503
1503
  function _OpenCV.filter2D(mat, options) return nil end
1504
1504
 
1505
1505
  --- ellipse
1506
1506
  ---@param mat OpenCV.Mat
1507
1507
  ---@param options OpenCV.EllipseOptions
1508
1508
  ---@return OpenCV.Mat|nil
1509
- ---@example cv.ellipse(mat, options)
1509
+ ---@example cv.ellipse(cv.capture(), { center = { x = 100, y = 100 }, axes = { width = 60, height = 40 }, angle = 0, color = {0, 0, 255}, thickness = 2 })
1510
1510
  function _OpenCV.ellipse(mat, options) return nil end
1511
1511
 
1512
1512
  --- getTextSize
1513
1513
  ---@param options OpenCV.GetTextSizeOptions
1514
1514
  ---@return OpenCV.TextSizeResult|nil
1515
- ---@example cv.getTextSize(options)
1515
+ ---@example cv.getTextSize({ text = "hello", fontScale = 1, thickness = 2 })
1516
1516
  function _OpenCV.getTextSize(options) return nil end
1517
1517
 
1518
1518
  --- 编码二维码为可显示/可识别的 BGR Mat(已放大并加静区,可直接 detectQRCode)
1519
1519
  ---@param text string
1520
1520
  ---@return OpenCV.Mat|nil
1521
- ---@example cv.encodeQRCode(text)
1521
+ ---@example cv.encodeQRCode("https://example.com")
1522
1522
  function _OpenCV.encodeQRCode(text) return nil end
1523
1523
 
1524
1524
  --- detectQRCode
1525
1525
  ---@param mat OpenCV.Mat
1526
1526
  ---@return OpenCV.QRCodeResult|nil
1527
- ---@example cv.detectQRCode(mat)
1527
+ ---@example cv.detectQRCode(cv.capture())
1528
1528
  function _OpenCV.detectQRCode(mat) return nil end
1529
1529
 
1530
1530
  --- detectBarcode
1531
1531
  ---@param mat OpenCV.Mat
1532
1532
  ---@return OpenCV.BarcodeResult|nil
1533
- ---@example cv.detectBarcode(mat)
1533
+ ---@example cv.detectBarcode(cv.capture())
1534
1534
  function _OpenCV.detectBarcode(mat) return nil end
1535
1535
 
1536
1536
  --- inpaint
1537
1537
  ---@param mat OpenCV.Mat
1538
1538
  ---@param options OpenCV.InpaintOptions
1539
1539
  ---@return OpenCV.Mat|nil
1540
- ---@example cv.inpaint(mat, options)
1540
+ ---@example cv.inpaint(cv.capture(), { mask = cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY), inpaintRadius = 3 })
1541
1541
  function _OpenCV.inpaint(mat, options) return nil end
1542
1542
 
1543
1543
  --- fastNlMeansDenoising
1544
1544
  ---@param mat OpenCV.Mat
1545
1545
  ---@param options OpenCV.DenoiseOptions|nil
1546
1546
  ---@return OpenCV.Mat|nil
1547
- ---@example cv.fastNlMeansDenoising(mat, options)
1547
+ ---@example cv.fastNlMeansDenoising(cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY), { h = 3 })
1548
1548
  function _OpenCV.fastNlMeansDenoising(mat, options) return nil end
1549
1549
 
1550
1550
  --- fastNlMeansDenoisingColored
1551
1551
  ---@param mat OpenCV.Mat
1552
1552
  ---@param options OpenCV.DenoiseColoredOptions|nil
1553
1553
  ---@return OpenCV.Mat|nil
1554
- ---@example cv.fastNlMeansDenoisingColored(mat, options)
1554
+ ---@example cv.fastNlMeansDenoisingColored(cv.capture(), { h = 3, hColor = 3 })
1555
1555
  function _OpenCV.fastNlMeansDenoisingColored(mat, options) return nil end
1556
1556
 
1557
1557
  --- LUT
1558
1558
  ---@param mat OpenCV.Mat
1559
1559
  ---@param options OpenCV.LUTOptions
1560
1560
  ---@return OpenCV.Mat|nil
1561
- ---@example cv.LUT(mat, options)
1561
+ ---@example cv.LUT(cv.capture(), { lut = cv.Mat({ rows = 1, cols = 256, type = cv.CV_8UC1 }) })
1562
1562
  function _OpenCV.LUT(mat, options) return nil end
1563
1563
 
1564
1564
  --- compare
1565
1565
  ---@param src1 OpenCV.Mat
1566
1566
  ---@param options OpenCV.CompareOptions
1567
1567
  ---@return OpenCV.Mat|nil
1568
- ---@example cv.compare(src1, options)
1568
+ ---@example cv.compare(cv.capture(), { src2 = cv.imread("/path/to/tpl.png"), cmpop = cv.CMP_EQ })
1569
1569
  function _OpenCV.compare(src1, options) return nil end
1570
1570
 
1571
1571
  --- min
1572
1572
  ---@param src1 OpenCV.Mat
1573
1573
  ---@param options OpenCV.Src2Options
1574
1574
  ---@return OpenCV.Mat|nil
1575
- ---@example cv.min(src1, options)
1575
+ ---@example cv.min(cv.capture(), { src2 = cv.imread("/path/to/tpl.png") })
1576
1576
  function _OpenCV.min(src1, options) return nil end
1577
1577
 
1578
1578
  --- max
1579
1579
  ---@param src1 OpenCV.Mat
1580
1580
  ---@param options OpenCV.Src2Options
1581
1581
  ---@return OpenCV.Mat|nil
1582
- ---@example cv.max(src1, options)
1582
+ ---@example cv.max(cv.capture(), { src2 = cv.imread("/path/to/tpl.png") })
1583
1583
  function _OpenCV.max(src1, options) return nil end
1584
1584
 
1585
1585
  --- extractChannel
1586
1586
  ---@param mat OpenCV.Mat
1587
1587
  ---@param options OpenCV.ExtractChannelOptions
1588
1588
  ---@return OpenCV.Mat|nil
1589
- ---@example cv.extractChannel(mat, options)
1589
+ ---@example cv.extractChannel(cv.capture(), { coi = 0 })
1590
1590
  function _OpenCV.extractChannel(mat, options) return nil end
1591
1591
 
1592
1592
  --- sum
1593
1593
  ---@param mat OpenCV.Mat
1594
1594
  ---@return number[]|nil
1595
- ---@example cv.sum(mat)
1595
+ ---@example cv.sum(cv.capture())
1596
1596
  function _OpenCV.sum(mat) return nil end
1597
1597
 
1598
1598
  --- invertAffineTransform
1599
1599
  ---@param M OpenCV.Mat
1600
1600
  ---@return OpenCV.Mat|nil
1601
- ---@example cv.invertAffineTransform(M)
1601
+ ---@example cv.invertAffineTransform(cv.getAffineTransform({ srcPoints = {{ x = 0, y = 0 }, { x = 100, y = 0 }, { x = 0, y = 100 }}, dstPoints = {{ x = 10, y = 10 }, { x = 110, y = 10 }, { x = 10, y = 110 }} }))
1602
1602
  function _OpenCV.invertAffineTransform(M) return nil end
1603
1603
 
1604
1604
  --- getRectSubPix
1605
1605
  ---@param mat OpenCV.Mat
1606
1606
  ---@param options OpenCV.GetRectSubPixOptions
1607
1607
  ---@return OpenCV.Mat|nil
1608
- ---@example cv.getRectSubPix(mat, options)
1608
+ ---@example cv.getRectSubPix(cv.capture(), { patchSize = { width = 32, height = 32 }, center = { x = 100, y = 100 } })
1609
1609
  function _OpenCV.getRectSubPix(mat, options) return nil end
1610
1610
 
1611
1611
  --- 相位相关估计两图位移(如滚动/拖拽前后帧)
1612
1612
  ---@param src1 OpenCV.Mat
1613
1613
  ---@param options OpenCV.PhaseCorrelateOptions
1614
1614
  ---@return OpenCV.PhaseCorrelateResult|nil
1615
- ---@example cv.phaseCorrelate(src1, options)
1615
+ ---@example cv.phaseCorrelate(cv.capture(), { src2 = cv.imread("/path/to/tpl.png") })
1616
1616
  function _OpenCV.phaseCorrelate(src1, options) return nil end
1617
1617
 
1618
1618
  --- cornerHarris
1619
1619
  ---@param mat OpenCV.Mat
1620
1620
  ---@param options OpenCV.CornerHarrisOptions|nil
1621
1621
  ---@return OpenCV.Mat|nil
1622
- ---@example cv.cornerHarris(mat, options)
1622
+ ---@example cv.cornerHarris(cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY), { blockSize = 2, ksize = 3, k = 0.04 })
1623
1623
  function _OpenCV.cornerHarris(mat, options) return nil end
1624
1624
 
1625
1625
  --- cornerSubPix
1626
1626
  ---@param mat OpenCV.Mat
1627
1627
  ---@param options OpenCV.CornerSubPixOptions
1628
1628
  ---@return OpenCV.Point[]|nil
1629
- ---@example cv.cornerSubPix(mat, options)
1629
+ ---@example cv.cornerSubPix(cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY), { corners = {{ x = 100, y = 100 }, { x = 200, y = 100 }, { x = 150, y = 200 }}, winSize = { width = 5, height = 5 } })
1630
1630
  function _OpenCV.cornerSubPix(mat, options) return nil end
1631
1631
 
1632
1632
  --- calcBackProject
1633
1633
  ---@param mat OpenCV.Mat
1634
1634
  ---@param options OpenCV.CalcBackProjectOptions
1635
1635
  ---@return OpenCV.Mat|nil
1636
- ---@example cv.calcBackProject(mat, options)
1636
+ ---@example cv.calcBackProject(cv.capture(), { hist = cv.calcHist(cv.capture(), { channels = {0}, histSize = {256}, ranges = {0, 256} }), channels = {0}, ranges = {0, 256} })
1637
1637
  function _OpenCV.calcBackProject(mat, options) return nil end
1638
1638
 
1639
1639
  --- HuMoments
1640
1640
  ---@param contourOrMoments OpenCV.Point[]|OpenCV.MomentsResult
1641
1641
  ---@return number[]|nil
1642
- ---@example cv.HuMoments(contourOrMoments)
1642
+ ---@example cv.HuMoments({{ x = 100, y = 100 }, { x = 200, y = 100 }, { x = 150, y = 200 }})
1643
1643
  function _OpenCV.HuMoments(contourOrMoments) return nil end
1644
1644
 
1645
1645
  --- connectedComponents
1646
1646
  ---@param mat OpenCV.Mat
1647
1647
  ---@param options OpenCV.ConnectedComponentsOptions|nil
1648
1648
  ---@return OpenCV.ConnectedComponentsCountResult|nil
1649
- ---@example cv.connectedComponents(mat, options)
1649
+ ---@example cv.connectedComponents(cv.cvtColor(cv.capture(), cv.COLOR_BGR2GRAY))
1650
1650
  function _OpenCV.connectedComponents(mat, options) return nil end
1651
1651
 
1652
1652
  --- convexityDefects
1653
1653
  ---@param contour OpenCV.Point[]
1654
1654
  ---@param options OpenCV.ConvexityDefectsOptions
1655
1655
  ---@return OpenCV.ConvexityDefect[]|nil
1656
- ---@example cv.convexityDefects(contour, options)
1656
+ ---@example cv.convexityDefects({{ x = 100, y = 100 }, { x = 200, y = 100 }, { x = 150, y = 200 }}, { hull = cv.convexHull({{ x = 100, y = 100 }, { x = 200, y = 100 }, { x = 150, y = 200 }}) })
1657
1657
  function _OpenCV.convexityDefects(contour, options) return nil end
1658
1658
 
1659
1659
  --- isContourConvex
1660
1660
  ---@param contour OpenCV.Point[]
1661
1661
  ---@return boolean
1662
- ---@example cv.isContourConvex(contour)
1662
+ ---@example cv.isContourConvex({{ x = 100, y = 100 }, { x = 200, y = 100 }, { x = 150, y = 200 }})
1663
1663
  function _OpenCV.isContourConvex(contour) return false end
1664
1664
 
1665
1665
  --- fitLine
1666
1666
  ---@param points OpenCV.Point[]
1667
1667
  ---@param options OpenCV.FitLineOptions|nil
1668
1668
  ---@return number[]|nil
1669
- ---@example cv.fitLine(points, options)
1669
+ ---@example cv.fitLine({{ x = 100, y = 100 }, { x = 200, y = 100 }, { x = 150, y = 200 }})
1670
1670
  function _OpenCV.fitLine(points, options) return nil end
1671
1671
 
1672
1672
  --- 就地绘制标记点,返回原句柄
1673
1673
  ---@param mat OpenCV.Mat
1674
1674
  ---@param options OpenCV.DrawMarkerOptions
1675
1675
  ---@return OpenCV.Mat|nil
1676
- ---@example cv.drawMarker(mat, options)
1676
+ ---@example cv.drawMarker(cv.capture(), { position = { x = 100, y = 100 }, color = {0, 0, 255}, markerType = cv.MARKER_CROSS })
1677
1677
  function _OpenCV.drawMarker(mat, options) return nil end
1678
1678
 
1679
1679
  --- 就地画箭头线,返回原句柄
1680
1680
  ---@param mat OpenCV.Mat
1681
1681
  ---@param options OpenCV.ArrowedLineOptions
1682
1682
  ---@return OpenCV.Mat|nil
1683
- ---@example cv.arrowedLine(mat, options)
1683
+ ---@example cv.arrowedLine(cv.capture(), { pt1 = { x = 10, y = 10 }, pt2 = { x = 200, y = 200 }, color = {0, 0, 255} })
1684
1684
  function _OpenCV.arrowedLine(mat, options) return nil end
1685
1685
 
1686
1686
  --- 就地填充凸多边形,返回原句柄
1687
1687
  ---@param mat OpenCV.Mat
1688
1688
  ---@param options OpenCV.FillConvexPolyOptions
1689
1689
  ---@return OpenCV.Mat|nil
1690
- ---@example cv.fillConvexPoly(mat, options)
1690
+ ---@example cv.fillConvexPoly(cv.capture(), { pts = {{ x = 100, y = 100 }, { x = 200, y = 100 }, { x = 150, y = 200 }}, color = {0, 0, 255} })
1691
1691
  function _OpenCV.fillConvexPoly(mat, options) return nil end
1692
1692
 
1693
1693
  --- estimateAffine2D
1694
1694
  ---@param options OpenCV.EstimateAffineOptions
1695
1695
  ---@return OpenCV.Mat|nil
1696
- ---@example cv.estimateAffine2D(options)
1696
+ ---@example cv.estimateAffine2D({ srcPoints = {{ x = 100, y = 100 }, { x = 200, y = 100 }, { x = 150, y = 200 }}, dstPoints = {{ x = 10, y = 10 }, { x = 110, y = 10 }, { x = 60, y = 110 }} })
1697
1697
  function _OpenCV.estimateAffine2D(options) return nil end
1698
1698
 
1699
1699
  --- 相似变换(平移+旋转+等比缩放,无剪切),点对齐/跨分辨率匹配常用
1700
1700
  ---@param options OpenCV.EstimateAffineOptions
1701
1701
  ---@return OpenCV.Mat|nil
1702
- ---@example cv.estimateAffinePartial2D(options)
1702
+ ---@example cv.estimateAffinePartial2D({ srcPoints = {{ x = 100, y = 100 }, { x = 200, y = 100 }, { x = 150, y = 200 }}, dstPoints = {{ x = 10, y = 10 }, { x = 110, y = 10 }, { x = 60, y = 110 }} })
1703
1703
  function _OpenCV.estimateAffinePartial2D(options) return nil end
1704
1704
 
1705
1705
  ---@type OpenCV