I’ve done some testing with code similar to what you have posted, and I wasn’t able to get the same error. DeepAR should accept a programatically generated canvas like you have posted just fine.
One thing to check before we look further, are you running this code in the browser? If you run document.createElement('canvas') in a node server it will not return a canvas element, which could cause an error like you’re seeing.
Another thing to try - does it work if you create the canvas in HTML beforehand and then pass that to DeepAR?