Git Product home page Git Product logo

Comments (8)

WorldThirteen avatar WorldThirteen commented on May 23, 2024 2

@jamesmfriedman, please check out the latest release (0.3.8), which added the Typescript support.

from gammacv.

jamesmfriedman avatar jamesmfriedman commented on May 23, 2024 1

^ plus you get the benefit of being able to specify multiple output formats for different environments.

Currently, my open src project RMWC supports ES and ESNext out of the box. Transpilation for the win. https://jamesmfriedman.github.io/rmwc/

from gammacv.

apilguk avatar apilguk commented on May 23, 2024

We have a little progress to add a ts definitions https://github.com/PeculiarVentures/GammaCV/blob/basic-typings/lib/index.d.ts
I'll try to finish up it ASAP

from gammacv.

rmhrisk avatar rmhrisk commented on May 23, 2024

Moving to TS vs just having types would be good and we would be open to working with you on that change.

Also extensions to the library would also be potentially welcome. Let us know what you’ve added.

from gammacv.

jamesmfriedman avatar jamesmfriedman commented on May 23, 2024

I've done a couple of massive js to ts overhauls at this point. It looks like a lot of it would just be moving your current jsdoc comments to proper typescript types. I'd be happy to make a branch and get the boilerplate handled so it can start being iterated on.

Other than that I've just been lazily adding types where I've needed them.

declare module 'gammacv/dist' {
  export class Operation {}

  export class Session {
    init(input: Tensor | Operation): void;
    runOp(
      /** operation to run */
      op: Tensor | Operation,
      /** context of a run, passing the same context twice in a row will use cached result */
      ctx: any,
      /** if passed, the output is put into it. */
      output?: Tensor
    ): void;
  }

  export class Tensor {
    constructor(
      /** the data type for tensor instance */
      dtype: string,
      /** the list of integers */
      shape: ShapeT,
      /** initial data to store */
      data?: number[],
      /** custom mapping from plain to NDArray */
      stride?: number[],
      /** number of data elements to skip */
      offset?: number
    );

    data: Uint8Array;
    dtype: string;
    shape: ShapeT;
    size: number;
    stride: ShapeT;
    get: (x: number, y: number, z: number) => number;
  }

  export class Line {
    static Intersection(l1: Line, l2: Line): TupleT | false;
    fromParallelCoords(
      x: number,
      y: number,
      w: number,
      h: number,
      maxDistance: number,
      maxAngles: number
    ): void;

    x1: number;
    y1: number;
    x2: number;
    y2: number;
    px: number;
    py: number;
    length: number;
    angle: number;
  }

  export class Rect {
    constructor(...args: number[]);
  }

  type ShapeT = [number, number, number];
  type TupleT = [number, number];

  export const imageTensorFromURL: (
    imgSrc: string,
    type?: string,
    size?: ShapeT,
    cors?: boolean
  ) => Promise<Tensor>;

  export const grayscale: (
    /** The source image to be grayscale. */
    tSrc: Tensor
  ) => Tensor;

  export const downsample: (
    /** The source image to be downsampled. */
    tSrc: Tensor,
    /**  Downsampling coefficient. */
    downsampleCoefficient?: number,
    /** Downsampling support two possible variants of processing. */
    type?: 'max' | 'mean'
  ) => Tensor;

  export const upsample: (
    /** The source image to be downsampled. */
    tSrc: Tensor,
    /**  Upsampling coefficient. */
    upsampleCoefficient?: number,
    /** Downsampling support two possible variants of processing. */
    interpolation?: 'nearest' | 'linear'
  ) => Tensor;

  export const norm: (
    /** Input data */
    tSrc: Tensor,
    /** Normalization type */
    type: 'l2' | 'minmax',
    /** Number of layers for a parallel reduction */
    parallelReductionLayers?: number
  ) => Tensor;

  export const gaussianBlur: (
    /** Input data */
    tSrc: Tensor,
    /**  Size of the kernel. */
    kernelSize: number,
    /** Sigma coeficient value. */
    sigma: number
  ) => Tensor;

  export const morphologyEx: (
    /** Input data */
    tSrc: Tensor,
    /**  Operation type. */
    type?: 'open' | 'close' | 'gradient' | 'tophat' | 'blackhat',
    /** Size structure of element. */
    kernelSize?: TupleT,
    /** Optional Kernel */
    tKernel?: Tensor
  ) => Tensor;

  export const sobelOperator: (
    /** The source image. */
    tSrc: Tensor
  ) => Tensor;

  export const cannyEdges: (
    /** Input data */
    tSrc: Tensor,
    /**  The low threshold to be applied. */
    lowThreshold: number,
    /** The high threshold to be applied. */
    highThreshold: number
  ) => Tensor;

  export const dilate: (
    /** Input data */
    tSrc: Tensor,
    /**  Size of the kernel. */
    kernelSize: TupleT,
    /** Optional kernel. */
    tKernel?: Tensor
  ) => Tensor;

  export const pcLinesEnhance: (
    /** The source image. */
    tSrc: Tensor
  ) => Tensor;

  export const pcLines: (
    /** Image edges image should be binarized to [0, 1], could be used with Canny Edges. */
    tSrc: Tensor,
    /**  count of parallel reduction layers. */
    layers?: number,
    /** discretization step */
    dStep?: number,
    /**  reduction coefficient */
    downsampleCoefficient?: number
  ) => Tensor;

  export const canvasFromTensor: (
    canvas: HTMLCanvasElement,
    tSrc: Tensor,
    rgba?: boolean,
    transposed?: boolean
  ) => void;

  export const canvasDrawLine: (
    canvas: HTMLCanvasElement,
    line: Line,
    color?: string,
    width?: number
  ) => void;

  export const tensorFrom: (
    input: Tensor | Operation,
    cast?: boolean
  ) => Tensor;

  export const generateTransformMatrix: (
    /** A rectangle */
    rect: Rect,
    /** this is an output shape you want to have [height, width], e.g you want your quadrilateral to be fixed to a rectangle with width 640 and height 480 */
    dstBounds: TupleT,
    /** we can use a placeholder instead of returning a new Tensor, because we want to reuse already allocated memory, and change the value from a call to call without reconstructing the graph */
    transformMatrix?: Tensor,
    /** Amount to pad */
    pad?: number
  ) => Tensor;

  export const perspectiveProjection: (
    tSrc: Tensor,
    tTransformMatrix: Tensor,
    shape?: ShapeT,
    dType?: string
  ) => Tensor;
}

from gammacv.

rmhrisk avatar rmhrisk commented on May 23, 2024

Please do

from gammacv.

apilguk avatar apilguk commented on May 23, 2024

@jamesmfriedman @WorldThirteen could we close it?

from gammacv.

jamesmfriedman avatar jamesmfriedman commented on May 23, 2024

Yeah, thanks guys!

from gammacv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.