Skip to content

Commit

Permalink
fix typings + improve exports
Browse files Browse the repository at this point in the history
  • Loading branch information
UrielCh committed Apr 30, 2024
1 parent 64322ad commit 766d9b3
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 69 deletions.
136 changes: 68 additions & 68 deletions src/lib/opencv4nodejs.ts

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion test/tests/imgproc/Contour.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ if (toTest.imgproc) {
});

describe('matchShapes', () => {
// @ts-expect-error multuple variable name depending on openCV version
const method = cvVersionGreaterEqual(4, 0, 0) ? cv.CONTOURS_MATCH_I1 : cv.CV_CONTOURS_MATCH_I1;
it('should return zero for same shapes', () => {
const similarity = leftmostContour.matchShapes(leftmostContour, method);
Expand Down
5 changes: 5 additions & 0 deletions typings/constants.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ export const INTER_CUBIC: number;
export const INTER_LANCZOS4: number;
export const INTER_LINEAR: number;
export const INTER_MAX: number;
export const INTER_LINEAR_EXACT: number;
export const INTER_NEAREST: number;
export const KMEANS_PP_CENTERS: number;
export const KMEANS_RANDOM_CENTERS: number;
Expand All @@ -657,6 +658,7 @@ export const MORPH_RECT: number;
export const MORPH_TOPHAT: number;
export const NORM_HAMMING: number;
export const NORM_HAMMING2: number;
export const NORM_TYPE_MASK: number;
export const NORM_INF: number;
export const NORM_L1: number;
export const NORM_L2: number;
Expand All @@ -670,6 +672,9 @@ export const REGULAR: number;
export const RETR_CCOMP: number;
export const RETR_EXTERNAL: number;
export const RETR_FLOODFILL: number;
export const CONTOURS_MATCH_I1: number;
export const CONTOURS_MATCH_I2: number;
export const CONTOURS_MATCH_I3: number;
export const RETR_LIST: number;
export const RETR_TREE: number;
export const RHO: number;
Expand Down
8 changes: 8 additions & 0 deletions typings/cv.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export function calcHist(img: Mat, histAxes: HistAxes[], mask?: Mat): Mat;
export function calcHistAsync(img: Mat, histAxes: HistAxes[], mask?: Mat): Promise<Mat>;

export function canny(dx: Mat, dy: Mat, threshold1: number, threshold2: number, L2gradient?: boolean): Mat;
export function cannyAsync(dx: Mat, dy: Mat, threshold1: number, threshold2: number, L2gradient?: boolean): Promise<Mat>;

export function computeCorrespondEpilines(points: Point2[], whichImage: number, F: Mat): Vec3[];
export function computeCorrespondEpilinesAsync(points: Point2[], whichImage: number, F: Mat): Promise<Vec3[]>;
Expand All @@ -48,6 +49,7 @@ export function drawKeyPoints(img: Mat, keyPoints: KeyPoint[]): Mat;
export function drawMatches(img1: Mat, img2: Mat, keyPoints1: KeyPoint[], keyPoints2: KeyPoint[], matches: DescriptorMatch[]): Mat;

export function fastNlMeansDenoisingColored(src: Mat, h?: number, hColor?: number, templateWindowSize?: number, searchWindowSize?: number): Mat;
export function fastNlMeansDenoisingColoredAsync(src: Mat, h?: number, hColor?: number, templateWindowSize?: number, searchWindowSize?: number): Promise<Mat>;
export function inpaint(src: Mat, mask: Mat, inpaintRadius: number, flags: number): Mat;
export function inpaintAsync(src: Mat, mask: Mat, inpaintRadius: number, flags: number): Promise<Mat>;

Expand Down Expand Up @@ -169,3 +171,9 @@ export function maxAsync(src1: Mat, src2: Mat, dst: Mat): Promise<Mat>;

export function magnitude(x: Mat, y: Mat, magnitude: Mat): Mat;
export function magnitudeAsync(x: Mat, y: Mat, magnitude: Mat): Promise<Mat>;

export const haarCascades: any;
export const lbpCascades: any;
export const KeyPointMatch: any;
export const StatModel: any;
export const HOGHistogramNormType: any;
10 changes: 10 additions & 0 deletions typings/group/calib3d.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ export interface FindHomographyRet {
}

export function findHomography(srcPoints: Point2[], dstPoints: Point2[], method?: number, ransacReprojThreshold?: number, maxIters?: number, confidence?: number): FindHomographyRet;
export function findHomographyAsync(srcPoints: Point2[], dstPoints: Point2[], method?: number, ransacReprojThreshold?: number, maxIters?: number, confidence?: number): Promise<FindHomographyRet>;

// Finds a perspective transformation between two planes. More...
//
Expand Down Expand Up @@ -300,6 +301,15 @@ export function solvePnPRansac(objectPoints: Point3[], imagePoints: Point2[], ca
flags: number,
}): SolvePnPRansacRet;

export function solvePnPRansacAsync(objectPoints: Point3[], imagePoints: Point2[], cameraMatrix: Mat, distCoeffs: number[], args: {
rvec: Vec3,
tvec: Vec3,
useExtrinsicGuess: boolean,
iterationsCount: number,
reprojectionError: number,
confidence: number,
flags: number,
}): Promise<SolvePnPRansacRet>;


//void cv::solvePnPRefineLM (InputArray objectPoints, InputArray imagePoints, InputArray cameraMatrix, InputArray distCoeffs, InputOutputArray rvec, InputOutputArray tvec, TermCriteria criteria=TermCriteria(TermCriteria::EPS+TermCriteria::COUNT, 20, FLT_EPSILON))
Expand Down
1 change: 1 addition & 0 deletions typings/group/imgproc_colormap.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ import { Mat } from '../Mat.d';
// Applies a user colormap on a given image. More...

export function applyColorMap(src: Mat, colormap: number | Mat): Mat;
export function applyColorMapAsync(src: Mat, colormap: number | Mat): Promise<Mat>;

0 comments on commit 766d9b3

Please sign in to comment.