99991 / matting

Python package for alpha matting. This repository has moved:
https://github.com/pymatting/pymatting
Other
47 stars 10 forks source link

'Failed to compile libmatting.' But also can't use vcycle? #5

Closed ghost closed 4 years ago

ghost commented 4 years ago

When running 'python setup.py install', I get the following output:

running install
building libmatting library
ichol.c: In function 'ichol':
ichol.c:48:5: warning: C++ style comments are not allowed in ISO C90
ichol.c:48:5: warning: (this will be reported only once per input file)
ichol.c:62:5: error: 'for' loop initial declarations are only allowed in C99 mode
ichol.c:62:5: note: use option -std=c99 or -std=gnu99 to compile your code
ichol.c:73:5: error: 'for' loop initial declarations are only allowed in C99 mode
ichol.c:76:9: error: 'for' loop initial declarations are only allowed in C99 mode
ichol.c:90:9: warning: ISO C90 forbids mixed declarations and code
ichol.c:98:13: error: 'for' loop initial declarations are only allowed in C99 mode
ichol.c:105:21: warning: ISO C90 forbids mixed declarations and code
ichol.c:123:17: warning: ISO C90 forbids mixed declarations and code
ichol.c:141:18: error: redefinition of 'idx'
ichol.c:76:18: note: previous definition of 'idx' was here
ichol.c:141:9: error: 'for' loop initial declarations are only allowed in C99 mode
ichol.c:152:13: warning: ISO C90 forbids mixed declarations and code
ichol.c:173:18: error: redefinition of 'idx'
ichol.c:141:18: note: previous definition of 'idx' was here
ichol.c:173:9: error: 'for' loop initial declarations are only allowed in C99 mode
ichol.c: In function 'backsub_L_csc_inplace':
ichol.c:229:5: error: 'for' loop initial declarations are only allowed in C99 mode
ichol.c:236:18: error: redefinition of 'k'
ichol.c:230:13: note: previous definition of 'k' was here
ichol.c:236:9: error: 'for' loop initial declarations are only allowed in C99 mode
ichol.c: In function 'backsub_LT_csc_inplace':
ichol.c:252:5: error: 'for' loop initial declarations are only allowed in C99 mode
ichol.c:255:9: error: 'for' loop initial declarations are only allowed in C99 mode
ichol.c:261:13: error: redefinition of 'k'
ichol.c:255:18: note: previous definition of 'k' was here
ichol.c:261:9: warning: ISO C90 forbids mixed declarations and code
ichol.c: In function 'backsub_L_csr_inplace':
ichol.c:275:5: error: 'for' loop initial declarations are only allowed in C99 mode
ichol.c:279:9: error: 'for' loop initial declarations are only allowed in C99 mode
ichol.c:285:13: error: redefinition of 'k'
ichol.c:279:18: note: previous definition of 'k' was here
ichol.c:285:9: warning: ISO C90 forbids mixed declarations and code
In file included from knn.c:2:0:
kdtree.h:12:1: warning: C++ style comments are not allowed in ISO C90
kdtree.h:12:1: warning: (this will be reported only once per input file)
knn.c:6:1: warning: C++ style comments are not allowed in ISO C90
knn.c:6:1: warning: (this will be reported only once per input file)
knn.c: In function 'knn':
knn.c:22:5: warning: ISO C90 forbids mixed declarations and code
knn.c:24:5: error: 'for' loop initial declarations are only allowed in C99 mode
knn.c:24:5: note: use option -std=c99 or -std=gnu99 to compile your code
knn.c:28:5: warning: ISO C90 forbids mixed declarations and code
knn.c:37:14: error: redefinition of 'i'
knn.c:24:14: note: previous definition of 'i' was here
knn.c:37:5: error: 'for' loop initial declarations are only allowed in C99 mode
knn.c:43:9: error: 'for' loop initial declarations are only allowed in C99 mode
In file included from kdtree.c:1:0:
kdtree.h:12:1: warning: C++ style comments are not allowed in ISO C90
kdtree.h:12:1: warning: (this will be reported only once per input file)
kdtree.c: In function 'kdtree_point_distance':
kdtree.c:19:5: error: 'for' loop initial declarations are only allowed in C99 mode
kdtree.c:19:5: note: use option -std=c99 or -std=gnu99 to compile your code
kdtree.c: In function 'kdtree_partition':
kdtree.c:40:9: warning: C++ style comments are not allowed in ISO C90
kdtree.c:40:9: warning: (this will be reported only once per input file)
kdtree.c:45:13: error: 'for' loop initial declarations are only allowed in C99 mode
kdtree.c:51:13: warning: ISO C90 forbids mixed declarations and code
kdtree.c: In function 'kdtree_init':
kdtree.c:70:5: warning: ISO C90 forbids mixed declarations and code
kdtree.c:78:5: error: 'for' loop initial declarations are only allowed in C99 mode
kdtree.c:85:5: error: 'for' loop initial declarations are only allowed in C99 mode
kdtree.c:88:9: error: 'for' loop initial declarations are only allowed in C99 mode
kdtree.c:108:9: error: 'for' loop initial declarations are only allowed in C99 mode
kdtree.c:117:9: warning: ISO C90 forbids mixed declarations and code
kdtree.c:127:9: warning: ISO C90 forbids mixed declarations and code
kdtree.c: In function 'kdtree_cell_distance':
kdtree.c:163:5: error: 'for' loop initial declarations are only allowed in C99 mode
kdtree.c: In function 'kdtree_find_knn':
kdtree.c:178:5: warning: ISO C90 forbids mixed declarations and code
kdtree.c:193:9: error: 'for' loop initial declarations are only allowed in C99 mode
kdtree.c:203:13: error: 'for' loop initial declarations are only allowed in C99 mode
boxfilter.c:5:1: warning: C++ style comments are not allowed in ISO C90
boxfilter.c:5:1: warning: (this will be reported only once per input file)
boxfilter.c: In function 'boxfilter':
boxfilter.c:40:5: warning: ISO C90 forbids mixed declarations and code
boxfilter.c:44:5: error: 'for' loop initial declarations are only allowed in C99 mode
boxfilter.c:44:5: note: use option -std=c99 or -std=gnu99 to compile your code
boxfilter.c:46:9: error: 'for' loop initial declarations are only allowed in C99 mode
boxfilter.c:53:5: warning: ISO C90 forbids mixed declarations and code
boxfilter.c:57:14: error: redefinition of 'i'
boxfilter.c:43:9: note: previous definition of 'i' was here
boxfilter.c:57:5: error: 'for' loop initial declarations are only allowed in C99 mode
boxfilter.c:61:9: error: 'for' loop initial declarations are only allowed in C99 mode
boxfilter.c:76:21: error: 'for' loop initial declarations are only allowed in C99 mode
boxfilter.c:89:18: error: redefinition of 'j'
boxfilter.c:61:18: note: previous definition of 'j' was here
boxfilter.c:89:9: error: 'for' loop initial declarations are only allowed in C99 mode
boxfilter.c:113:18: error: redefinition of 'j'
boxfilter.c:89:18: note: previous definition of 'j' was here
boxfilter.c:113:9: error: 'for' loop initial declarations are only allowed in C99 mode
labelexpand.c: In function 'label_expand':
labelexpand.c:17:5: error: 'for' loop initial declarations are only allowed in C99 mode
labelexpand.c:17:5: note: use option -std=c99 or -std=gnu99 to compile your code
labelexpand.c:25:9: error: 'for' loop initial declarations are only allowed in C99 mode
labelexpand.c:26:13: error: 'for' loop initial declarations are only allowed in C99 mode
ERROR: Failed to compile libmatting. Only vcycle method will be available.
running build
running build_py
creating build
creating build\lib
creating build\lib\matting
copying matting\alpha_matting.py -> build\lib\matting
copying matting\boxfilter.py -> build\lib\matting
copying matting\closed_form_laplacian.py -> build\lib\matting
copying matting\foreground_background.py -> build\lib\matting
copying matting\guided_filter.py -> build\lib\matting
copying matting\ichol.py -> build\lib\matting
copying matting\ifm_matting.py -> build\lib\matting
copying matting\knn.py -> build\lib\matting
copying matting\knn_laplacian.py -> build\lib\matting
copying matting\lkm.py -> build\lib\matting
copying matting\load_libmatting.py -> build\lib\matting
copying matting\util.py -> build\lib\matting
copying matting\vcycle.py -> build\lib\matting
copying matting\__about__.py -> build\lib\matting
copying matting\__init__.py -> build\lib\matting
copying matting\__main__.py -> build\lib\matting
running install_lib
running install_egg_info
running egg_info
creating matting.egg-info
writing matting.egg-info\PKG-INFO
writing dependency_links to matting.egg-info\dependency_links.txt
writing requirements to matting.egg-info\requires.txt
writing top-level names to matting.egg-info\top_level.txt
writing manifest file 'matting.egg-info\SOURCES.txt'
reading manifest file 'matting.egg-info\SOURCES.txt'
writing manifest file 'matting.egg-info\SOURCES.txt'
removing 'C:\Users\usr\AppData\Local\Continuum\anaconda3\Lib\site-packages\matting-0.0.1-py3.7.egg-info' (and everything under it)
Copying matting.egg-info to C:\Users\usr\AppData\Local\Continuum\anaconda3\Lib\site-packages\matting-0.0.1-py3.7.egg-info
running install_scripts
cleanup

I saw elsewhere you mentioned that vcycle should still work without the libmatting library, but when I run 'from matting import vcycle' I get the following error:

from matting import vcycle
Traceback (most recent call last):

  File "<ipython-input-2-c1031d670d07>", line 1, in <module>
    from matting import vcycle

  File "C:\Users\usr\Desktop\matting\matting\__init__.py", line 2, in <module>
    from .alpha_matting import alpha_matting, METHODS, PRECONDITIONERS

  File "C:\Users\usr\Desktop\matting\matting\alpha_matting.py", line 3, in <module>
    from .knn_laplacian import knn_laplacian

  File "C:\Users\usr\Desktop\matting\matting\knn_laplacian.py", line 383, in <module>
    from .knn import knn

  File "C:\Users\usr\Desktop\matting\matting\knn.py", line 5, in <module>
    library = load_libmatting()

  File "C:\Users\usr\Desktop\matting\matting\load_libmatting.py", line 24, in load_libmatting
    raise Exception("Failed to find libmatting library. Checked paths:\n%s", "\n".join(paths))

Any advice?

Thanks!

99991 commented 4 years ago

For the first problem, it seems like the C-compiler is more strict than it needs to be. I currently don't have access to a Windows machine to test this on, so I can't test the fix just yet, but it's probably just that -std=c99 has to be added to the compile flags in setup.py: https://github.com/99991/matting/blob/master/setup.py#L27

flags = "-O3 -Wall -Wextra -pedantic -shared -std=c99"

For the second problem, the exception should probably just be a warning instead.

I'll see if I can get it fixed next weekend, but until then, you can try the successor library instead which has been released a few minutes ago.

ghost commented 4 years ago

The successor library works incredibly well! What great timing haha. Thank you so much.

The only thing is that in the 'run_tests.py' I had to change line 38 to simply

command = "python " + filename

otherwise I was getting some errors that the file path was invalid. Let me know if you want me to open an issue on that repo.

Also, tests 9 and 10 failed, but I think that is because I do not have a gpu, and the resulting matting does not seem affected.

Thanks again!!

99991 commented 4 years ago

Thank you for those kind words, that's great to hear!

The GPU foreground estimation tests will indeed fail if no GPU support is available. But maybe we should make the error message indicate that this is as expected.

Also thank you for your tip with line 38, will be fixed soon.