Skip to content

OpenCV.js build fails to recognize custom config file #19493

@bosper351

Description

@bosper351

When I try to build OpenCV.js with custom config file using --config option, the build results in an error:

Traceback (most recent call last):
  File "/home/work/Projects/opencv/modules/js/generator/embindgen.py", line 910, in <module>
    exec(open(whiteListFile).read())
FileNotFoundError: [Errno 2] No such file or directory: './my.config.py'

...

make: *** [Makefile:502: opencv.js] Error 2
Traceback (most recent call last):
  File "/home/work/Projects/opencv/./platforms/js/build_js.py", line 287, in <module>
    builder.build_opencvjs()
  File "/home/work/Projects/opencv/./platforms/js/build_js.py", line 195, in build_opencvjs
    execute(["make", "-j", str(multiprocessing.cpu_count()), "opencv.js"])
  File "/home/work/Projects/opencv/./platforms/js/build_js.py", line 23, in execute
    raise Fail("Child returned: %s" % retcode)
__main__.Fail: Child returned: 2
System information (version)
  • OpenCV => 4.5.1 (master)
  • Operating System / Platform => Linux
  • Compiler => emscripten
Steps to reproduce
  1. Create config file with custom module whitelist
  2. Build opencv.js using emcmake and specify --config option
$ cp ./platforms/js/opencv_js.config.py ./my.config.py
$ emcmake python ./platforms/js/build_js.py build_js --config="./my.config.py"
Detailed description

It seems that the relative path ./my.config.py is passed as-is to the environmental variable OPENCV_JS_WHITELIST. Then it is read by embindgen.py in another directory, resulting in file not found. Passing the file path as absolute solves the issue. Solution in PR.

Issue submission checklist
  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues,
    forum.opencv.org, Stack Overflow, etc and have not found solution
  • I updated to latest OpenCV version and the issue is still there
  • There is reproducer code and related data files: videos, images, onnx, etc

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions