embiem / react-canvas-draw

React Component for drawing in canvas
https://embiem.github.io/react-canvas-draw/
MIT License
902 stars 315 forks source link

Can I get access to the canvas element? #107

Closed umkatakam closed 3 years ago

umkatakam commented 3 years ago

I am trying to use tensorflow js to classify the drawing done on a canvas that is rendered using react-canvas-draw. However, when I try to access the canvas.ref.current it is not an HTMLCanvasElement. E.g code

import * as mobilenet from "@tensorflow-models/mobilenet";
....
const model = await mobilenet.load();
....
<CanvasDraw ref={canvasRef} .../>
<Button onClick={()=>model.classify(canvasRef.current)> Classify </Button>
....

This code fails inside the click handler during classification.

This is the tensorflow model I am using.

Thanks for the help.