theothergrantdavidson / opencv-ts

A place for the typescript bindings for OpencvJS
Apache License 2.0
51 stars 18 forks source link

Exporte/Expose enum types. #11

Closed Piemontez closed 2 years ago

Piemontez commented 2 years ago

Hello. Thanks for your projet idea.

I´d like to suggest an ideia.

Is it possible to expose enum type, like a BorderTypes or ColorConversionCodes, from "import cv from "opencv-ts""

Until the moment the enum types just are "enum" inside a "declare module". Because of this, i can´t use all enums as enumeration, and i would really like to use this enum as enumeration like this:

import { BorderTypes } from 'opencv-ts/src/core/CoreArray';

const selectables = Object.values(BorderTypes).map((_: any) => ({
      value: _,
      columns: [_],
    }))

or like this:

import cv from 'opencv-ts';

const selectables = Object.values(cv.BorderTypes).map((_: any) => ({
      value: _,
      columns: [_],
    }))

The reason I want to use it this way. It's because I'm creating the OpenCVFlow IDE to work with opencv and tensorflow. And in it you'll have a panel to change the properties of opencv components. And without access to the enums I will have to rewrite them all, so the user can change them.

theothergrantdavidson commented 2 years ago

Border types have been exposed here https://github.com/theothergrantdavidson/opencv-ts/commit/747b85857e3fdf5c85d18a4b0d96fd94bb14a885