问题
I have tried to build opencv.js
from the tutorial on their page.
I have done all the steps except the last one to build it:
C:\Users\student>python C:\Users\student\opencv\platforms\js\build_js.py documents
which gives me this error:
Args: Namespace(build_dir='documents', build_doc=False, build_test=False, build_wasm=False, clean_build_dir=False, config_only=False, emscripten_dir=None, enable_exception=False, opencv_dir='C:\\Users\\student\\opencv', skip_config=False)
Cannot get Emscripten path, please specify it either by EMSCRIPTEN environment variable or --emscripten_dir option.
I try using this then
C:\Users\student>python C:\Users\student\opencv\platforms\js\build_js.py --emscripten=C:\Users\student\emsdk\emscripten\1.37.36 documents
with the --emscripten
option but I got this instead:
Args: Namespace(build_dir='documents', build_doc=False, build_test=False, build_wasm=False, clean_build_dir=False, config_only=False, emscripten_dir='C:\\Users\\student\\emsdk\\emscripten\\1.37.36', enable_exception=False, opencv_dir='C:\\Users\\student\\opencv', skip_config=False)
Check dir C:\Users\student\documents (create: True, clean: False)
Check dir C:\Users\student\opencv (create: False, clean: False)
Check dir C:\Users\student\emsdk\emscripten\1.37.36 (create: False, clean: False)
Traceback (most recent call last):
File "C:\Users\student\opencv\platforms\js\build_js.py", line 215, in <module>
builder = Builder(args)
File "C:\Users\student\opencv\platforms\js\build_js.py", line 84, in __init__
self.emcc_version = determine_emcc_version(self.emscripten_dir)
File "C:\Users\student\opencv\platforms\js\build_js.py", line 62, in determine_emcc_version
ret = subprocess.check_output([os.path.join(emscripten_dir, "emcc"), "--version"])
File "C:\Users\student\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 336, in check_output
**kwargs).stdout
File "C:\Users\student\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 403, in run
with Popen(*popenargs, **kwargs) as process:
File "C:\Users\student\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "C:\Users\student\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 997, in _execute_child
startupinfo)
OSError: [WinError 193] %1 is not a valid Win32 application
I have searched for this problem for almost 2 days but nothing solve it.
I'm using Windows 10 64bit.
回答1:
Open opencv\platforms\js\build_js.py
file, and replace this line:
ret = subprocess.check_output([os.path.join(emscripten_dir, "emcc"), "--version"])
with this:
ret = subprocess.check_output([os.path.join(emscripten_dir, "emcc.bat"), "--version"])
Hope this will be fixed in next opencv version.
来源:https://stackoverflow.com/questions/49748702/oserror-winerror-193-1-is-not-a-valid-win32-application-opencv-js