opencv-wasm icon indicating copy to clipboard operation
opencv-wasm copied to clipboard

Better types

Open morozovsk opened this issue 3 years ago • 3 comments

Hi. I found miranda project. I think you can use these types for better syntax highlighting: https://github.com/cancerberoSgx/mirada/tree/c8721d6bbe004e31ec7578b30443c01274528a3f/mirada/src/types/opencv

morozovsk avatar Aug 16 '20 15:08 morozovsk

Hello @morozovsk ,

Thanks for the suggestion!

Previously, I attempted to take the typings from that project (in this branch). But unfortunately, I found some errors in the typings, for example: MatVector and Mat types.

These errors make some false alarms in valid codes, so I haven't merged the that branch to the master yet.

echamudi avatar Aug 17 '20 08:08 echamudi

If you are looking for types that are closer to the generated opencv.js/wasm , I'm currently working on generating typescript types directly from opencv codebase https://github.com/peteruhnak/opencv-ts (with the intention for this to eventually be part of opencv itself). Feel free to copy the lib/typings and lib/index.d.ts to your library/project to test it out and report any typing issues in the linked repo.

peteruhnak avatar Jan 10 '21 16:01 peteruhnak

@peteruhnak that's interesting! I'll keep track of the project.

echamudi avatar Jan 11 '21 02:01 echamudi

@echamudi just update the index.d.ts as follows ( it will export all types from underlying OpenCV without any additional hassle)

import type * as openCV from './types/';
export type * as openCV from './types/';

/**
 * OpenCV Object
 */
export declare const cv: typeof openCV;

/**
 * Translate error number from OpenCV into a meaningful message
 * @param cvObject OpenCV object
 * @param err OpenCV error number 
 */
export function cvTranslateError(cvObject: typeof openCV, err: any): string | Error | undefined;

studentutu avatar Jun 22 '24 22:06 studentutu