Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation caveats #1

Open
panstromek opened this issue Nov 18, 2019 · 3 comments
Open

Installation caveats #1

panstromek opened this issue Nov 18, 2019 · 3 comments
Labels
documentation Improvements or additions to documentation

Comments

@panstromek
Copy link

First of all, thanks for this lonely effort, it's literally amazing. I am really glad someone has done this, and with all typescript definitions and jsdoc it's just invaluable.

I got it working after few hours but there were few gotchas that are not mentioned anywhere and I don't really understand them.

  1. When I use this in a Vue project (based on webpack), it throws on initialization saying that it's missing opencv.js file in in url http:/localhost:8080/opencv.js, I got it working by copying the opencv.js file from node_modules to statics folder and with the following code:
import * as Mirada from 'mirada'

export default async ({ }) => {
  await Mirada.installFormatProxy(() => new Mirada.CanvasCodec())
  await Mirada.loadFormatProxies()
  await Mirada.loadOpencv({
    opencvJsLocation: 'statics/opencv.js'
  })
}

I don't really understand what's the problem there, though. I thought it should work just by importing Mirada like this and I haven't found any similar code in your playgrounds. Doesn't seem like you serve your node_modules or anything like that.

  1. Global cv variable. The thing that I did just intuitively was naming the import cv. But apparently (as far as I understand, from one of your comments on opencv repo), opencv creates global cv variable which I shadowed this way. This led me to bunch of pretty confusing errors.

I think I also found some code in the playground that confused me, that seems related, something along the lines of:

 import * as Mirada from 'mirada'
 import * as cv from 'mirada'

Anyway, those are just things I don't really know how to get right, but apart from that, the work is amazing ;)

@panstromek
Copy link
Author

panstromek commented Nov 18, 2019

Another thing are those errors:
image

they usually come from type mismatches from opencv itself I think, that's at least what I've inferred, but it took time to figure out because this number doesn't really say anything. If you have some pointers for how to interpret that, I'd be glad 😉

@cancerberoSgx
Copy link
Owner

Hello there! Thanks for the feedback.

Regarding the first problem, I'm noticing there's no getting started instructions in the readme. I will work on that ASAP putting emphasis on how to define the opencv.js file location and load format proxies using jimp or similar.

import * as Mirada from 'mirada'
import * as cv from 'mirada'

Although the cv global is created automatically the statements above can be used to get its typings and it's OK to redefine it like that. Are you saying it didn't work on your case ?

Finally, regarding the last error which only show a number as error message, that happens when there's an error at the web assembly level (c++ code) and unfortunately, for getting more debug information in these cases, opencv.js needs to be compiled with emscripten debug options which is not. I'm aware of this limitation and probably will PR opencv repo to be able to compile the wasm with more debugging options and probably will distribute two versions of the opencv.js file, one for production and another with debug/trace options enable so it's easy to switch between them.

Stay tuned, thanks!

@cancerberoSgx cancerberoSgx added the documentation Improvements or additions to documentation label Nov 19, 2019
@panstromek
Copy link
Author

Regarding the first problem, I'm noticing there's no getting started instructions in the readme.

Yea, I noticed the instructions missing with TODO but I was like whatever, I'll figure it out somehow because it looks great 😄

Although the cv global is created automatically the statements above can be used to get its typings and it's OK to redefine it like that. Are you saying it didn't work on your case ?

If I do that, I'll get cv is undefined errors. But I use this in files that run through bunch of loaders, so webpack probably can't handle that. If I just use cv as global variable, everything works well and WebStorm will pickup the typings correctly (I also needed to whitelist it in eslint config).

Right now everything is working fine this way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants