增加VideoCapture
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import { Mat } from "./mat";
|
||||
import { FromCV, M, resolveArgs } from "./common";
|
||||
import { __Mat, M, resolveArgs } from "./common";
|
||||
import { BORDER_CONSTANT, BORDER_DEFAULT, INTER_LINEAR } from "./consts";
|
||||
import { CVMat } from "./addon";
|
||||
|
||||
@ -9,14 +9,14 @@ export function crop(src: Mat, dst: Mat, range: CropRange): Mat;
|
||||
export function crop(...args: any[]) {
|
||||
let [src, dst, range] = resolveArgs<[src: Mat, dst: Mat, range: CropRange]>(args, args[1] instanceof Mat);
|
||||
if (!(range instanceof Array)) range = [{ start: range.y, end: range.y + range.height }, { start: range.x, end: range.x + range.width }];
|
||||
return FromCV(CVMat().Crop(M(src), M(dst), range));
|
||||
return __Mat(CVMat().Crop(M(src), M(dst), range));
|
||||
}
|
||||
|
||||
export function resize(src: Mat, width: number, height: number, fx?: number, fy?: number, interpolation?: number): Mat;
|
||||
export function resize(src: Mat, dst: Mat, width: number, height: number, fx?: number, fy?: number, interpolation?: number): Mat;
|
||||
export function resize(...args: any[]) {
|
||||
const [src, dst, width, height, fx, fy, interpolation] = resolveArgs<[src: Mat, dst: Mat, width: number, height: number, fx?: number, fy?: number, interpolation?: number]>(args, args[1] instanceof Mat);
|
||||
return FromCV(CVMat().Resize(M(src), M(dst), width, height, fx ?? 0, fy ?? 0, interpolation ?? INTER_LINEAR));
|
||||
return __Mat(CVMat().Resize(M(src), M(dst), width, height, fx ?? 0, fy ?? 0, interpolation ?? INTER_LINEAR));
|
||||
}
|
||||
|
||||
export function blur(src: Mat, kernelWidth: number, kernelHeight: number, anchorX?: number, anchorY?: number, borderType?: number): Mat
|
||||
@ -24,14 +24,14 @@ export function blur(src: Mat, dst: Mat, kernelWidth: number, kernelHeight: numb
|
||||
export function blur(...args: any[]) {
|
||||
let [src, dst, kernelWidth, kernelHeight, anchorX = -1, anchorY = -1, borderType = BORDER_DEFAULT] = resolveArgs<[src: Mat, dst: Mat, kernelWidth: number, kernelHeight: number, anchorX?: number, anchorY?: number, borderType?: number]>(args, args[1] instanceof Mat);
|
||||
if (anchorX == -1 || anchorY == -1) anchorX = anchorY = -1;
|
||||
return FromCV(CVMat().Blur(M(src), M(dst), kernelWidth, kernelHeight, anchorX, anchorY, borderType));
|
||||
return __Mat(CVMat().Blur(M(src), M(dst), kernelWidth, kernelHeight, anchorX, anchorY, borderType));
|
||||
}
|
||||
|
||||
export function copyMakeBorder(src: Mat, top: number, bottom: number, left: number, right: number, borderType: number): Mat
|
||||
export function copyMakeBorder(src: Mat, dst: Mat, top: number, bottom: number, left: number, right: number, borderType: number): Mat
|
||||
export function copyMakeBorder(...args: any[]) {
|
||||
const [src, dst, top, bottom, left, right, borderType] = resolveArgs<[src: Mat, dst: Mat, top: number, bottom: number, left: number, right: number, borderType: number]>(args, args[1] instanceof Mat);
|
||||
return FromCV(CVMat().CopyMakeBorder(M(src), M(dst), top, bottom, left, right, borderType));
|
||||
return __Mat(CVMat().CopyMakeBorder(M(src), M(dst), top, bottom, left, right, borderType));
|
||||
}
|
||||
|
||||
type FlipCode = 0 | 1 | -1 | "x" | "y" | "both";
|
||||
@ -40,14 +40,14 @@ export function flip(src: Mat, dst: Mat, flipCode: FlipCode): Mat
|
||||
export function flip(...args: any[]) {
|
||||
let [src, dst, flipCode] = resolveArgs<[src: Mat, dst: Mat, flipCode: FlipCode]>(args, args[1] instanceof Mat);
|
||||
if (typeof flipCode == "string") flipCode = ({ x: 0, y: 1, both: -1 } as Record<"x" | "y" | "both", 0 | 1 | -1>)[flipCode];
|
||||
return FromCV(CVMat().Flip(M(src), M(dst), flipCode));
|
||||
return __Mat(CVMat().Flip(M(src), M(dst), flipCode));
|
||||
}
|
||||
|
||||
export function warpAffine(src: Mat, transfromMat: Mat, dwidth: number, dheight: number, flags?: number, borderMode?: number): Mat;
|
||||
export function warpAffine(src: Mat, dst: Mat, transfromMat: Mat, dwidth: number, dheight: number, flags?: number, borderMode?: number): Mat;
|
||||
export function warpAffine(...args: any[]) {
|
||||
const [src, dst, transfromMat, dwidth, dheight, flags, borderMode] = resolveArgs<[src: Mat, dst: Mat, transfromMat: Mat, dwidth: number, dheight: number, flags?: number, borderMode?: number]>(args, () => args[2] instanceof Mat);
|
||||
return FromCV(CVMat().WarpAffine(M(src), M(dst), M(transfromMat), dwidth, dheight, flags ?? INTER_LINEAR, borderMode ?? BORDER_CONSTANT));
|
||||
return __Mat(CVMat().WarpAffine(M(src), M(dst), M(transfromMat), dwidth, dheight, flags ?? INTER_LINEAR, borderMode ?? BORDER_CONSTANT));
|
||||
}
|
||||
|
||||
export function getRotationMatrix2D(centerX: number, centerY: number, angle: number, scale: number) { return FromCV(CVMat().GetRotationMatrix2D(centerX, centerY, angle, scale)); }
|
||||
export function getRotationMatrix2D(centerX: number, centerY: number, angle: number, scale: number) { return __Mat(CVMat().GetRotationMatrix2D(centerX, centerY, angle, scale)); }
|
||||
|
Reference in New Issue
Block a user