Opened 8 years ago

Closed 7 years ago

#53562 closed defect (fixed)

opencv @3.2.0: fatal error: 'AVFoundation/AVFoundation.h' file not found

Reported by: fmw42 (Fred Weinhaus) Owned by: stromnov (Andrey Stromnov)
Priority: Normal Milestone:
Component: ports Version: 2.4.0
Keywords: snowleopard Cc: ballapete (Peter "Pete" Dyballa), MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)
Port: opencv

Description

I recently installed some python support tools (py35-pip), which caused MacPorts to upgrade other ports including, I believe, python35 and opencv.

Recently I tried to run one of my script and got an error message.

python3.5 match_image_subsections.py /Users/fred/Desktop/ALIVE_sub_compare_test2 
Traceback (most recent call last):
  File "match_image_subsections.py", line 31, in <module>
    import cv2
ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/cv2.cpython-35m-darwin.so, 2): Library not loaded: /opt/local/lib/libwebp.6.dylib
  Referenced from: /opt/local/lib/libopencv_imgcodecs.3.1.dylib
  Reason: image not found

So I just tried to launch python and import cv2, which failed as below:

python3.5
Python 3.5.3 (default, Feb 10 2017, 16:04:07) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/cv2.cpython-35m-darwin.so, 2): Library not loaded: /opt/local/lib/libwebp.6.dylib
  Referenced from: /opt/local/lib/libopencv_imgcodecs.3.1.dylib
  Reason: image not found
>>> quit()

So I tried cleaning python35 and opencv and install again, but I am now getting the following message:

--->  Building opencv
Error: Failed to build opencv: command execution failed
Error: See /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_graphics_opencv/opencv/main.log for details.
Error: rev-upgrade failed: Error rebuilding opencv
Error: Follow https://guide.macports.org/#project.tickets to report a bug.

This appears to be a bug. But perhaps I am doing something wrong.

Please confirm if a bug and have it fixed. Or if I am doing something wrong, I would appreciate any help if getting this working. I am no longer able to run my python/opencv scripts.

See attachments for my MacPorts session and the installation attempts and bug reports.

I may have made a mistake trying to use version numbers, but at the end of my session, I tried without the version numbers after cleaning python and opencv, but still no success.

Thanks

Attachments (5)

macports_errors.txt (110.1 KB) - added by fmw42 (Fred Weinhaus) 8 years ago.
session log
macports_error2.txt (580.1 KB) - added by fmw42 (Fred Weinhaus) 8 years ago.
log file reporting error
macports_errors3.txt (10.8 KB) - added by fmw42 (Fred Weinhaus) 8 years ago.
session log
macports_errors4.txt (304.7 KB) - added by fmw42 (Fred Weinhaus) 8 years ago.
log file reporting error
libopenraw_error_c++_compiler.txt (3.1 KB) - added by fmw42 (Fred Weinhaus) 8 years ago.
session log

Download all attachments as: .zip

Change History (25)

Changed 8 years ago by fmw42 (Fred Weinhaus)

Attachment: macports_errors.txt added

session log

comment:1 Changed 8 years ago by fmw42 (Fred Weinhaus)

P.S. I do not see any older ports for opencv, such as 3.1.0 which was what I had been using.

Changed 8 years ago by fmw42 (Fred Weinhaus)

Attachment: macports_error2.txt added

log file reporting error

comment:2 Changed 8 years ago by mf2k (Frank Schima)

Keywords: python opencv removed
Owner: set to stromnov
Port: python removed
Status: newassigned

In the future, please only fill in the Port field with the port that actually fails to build and Cc that port's maintainers (port info --maintainers opencv), if any.

comment:3 Changed 8 years ago by mf2k (Frank Schima)

Summary: Probem Installing Opencv 3.2.0 with Python 3.5Probem Installing Opencv 3.2.0

comment:4 Changed 8 years ago by ryandesign (Ryan Carsten Schmidt)

Summary: Probem Installing Opencv 3.2.0opencv @3.2.0: fatal error: 'AVFoundation/AVFoundation.h' file not found

comment:5 Changed 8 years ago by fmw42 (Fred Weinhaus)

Is there any chance that Opencv 3.1.0 can be returned to the available ports, so I can reinstall it until 3.2.0 is properly available.

comment:6 Changed 8 years ago by ryandesign (Ryan Carsten Schmidt)

opencv 3.2.0 built successfully on our automated builders on Mavericks and later. I guess this is a problem on earlier OS versions.

To go back to the previous version temporarily until this is fixed, see wiki:howto/InstallingOlderPort.

comment:7 Changed 8 years ago by fmw42 (Fred Weinhaus)

Thanks for the quick reply. I am on Mac OSX SnowLeopard.

Unfortunately, according to the link you supplied for installing older versions, Opencv 3.1.0 is no longer listed as an available port on Macports.com. The more detailed instructions are over my head. I guess I will have to wait for this to be resolved. Do you have any idea how hard this will be and how long before it is fixed?

Thanks again. I appreciate any help you can give.

My list of ports shows:

  opencv @2.4.2_1
  opencv @2.4.6.1_0
  opencv @2.4.9_0
  opencv @3.1.0_3
  opencv @3.1.0_3+contrib+python35 (active)

Is there no simple way for me to make this active port opencv @3.1.0_3+contrib+python35 work or must I download the files again from svn? Is that because I did a port clean on opencv?

If I might ask a dumb question -- many tools on MacPorts have multiple port versions available. Is there some particular reason you do not keep Opencv 3.1.0 available along with Opencv 3.2.0?

Last edited 8 years ago by fmw42 (Fred Weinhaus) (previous) (diff)

comment:8 Changed 8 years ago by fmw42 (Fred Weinhaus)

I tried again today. I found that I could not import cv2 into python and got the following error:

python3.5
Python 3.5.3 (default, Feb 10 2017, 16:04:07) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/cv2.cpython-35m-darwin.so, 2): Library not loaded: /opt/local/lib/libwebp.6.dylib
  Referenced from: /opt/local/lib/libopencv_imgcodecs.3.1.dylib
  Reason: image not found

which made me think that I needed to reinstall webp. So I tried that but got further errors.

Error: Requested variants "+contrib+python35" do not match those the build was started with: "".
Error: Please use the same variants again, or run 'port clean opencv' first to remove the existing partially completed build.
Error: rev-upgrade failed: Error rebuilding opencv

which seems to have trouble with adding +contrib+python35 to opencv.

So I tried:

sudo port clean opencv

and then

sudo port install opencv +contrib+python35

But it failed at a different spot this time.

I am attaching my session log and the listing from /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_graphics_opencv/opencv/main.log for details.

Changed 8 years ago by fmw42 (Fred Weinhaus)

Attachment: macports_errors3.txt added

session log

Changed 8 years ago by fmw42 (Fred Weinhaus)

Attachment: macports_errors4.txt added

log file reporting error

comment:9 Changed 8 years ago by fmw42 (Fred Weinhaus)

I tried upgrading all my outdated ports, but am still having trouble now with both opencv and libopenraw.

The latter seems to be an issue with the c++ compiler.

1) Shall I report this separately 2) What is my best option here for either or both issues? The instructions are quite complex other than upgrading my Mac OSX. Is that my best option? It seems like MacPorts is no longer using a compatible compiler for my SnowLeopard.

I am attaching my session log.

Thanks again for any help and sorry I am not expert enough to understand all the ramifications.

Changed 8 years ago by fmw42 (Fred Weinhaus)

session log

comment:10 Changed 8 years ago by mf2k (Frank Schima)

Keywords: snowleopard added

comment:11 Changed 7 years ago by ballapete (Peter "Pete" Dyballa)

Cc: ballapete added

comment:12 Changed 7 years ago by ballapete (Peter "Pete" Dyballa)

I ran into the same failure on SnowLeopard, Mac OS X 10.6.8. On my Mac AVFoundation/AVFoundation.h does not exist, actually no AVFoundation related C header file exists here. And it's a Private Framework called AVFoundationCF.framework here…

comment:13 Changed 7 years ago by ballapete (Peter "Pete" Dyballa)

opencv-3.2.0/3rdparty/ffmpeg/readme.txt contains this paragraph:

  If you want to play very safe and do not want to use FFMPEG at all, regardless of whether it's installed on
  your system or not, configure and build OpenCV using CMake with WITH_FFMPEG=OFF flag. OpenCV will then use
  AVFoundation (OSX), GStreamer (Linux) or other available backends supported by opencv_videoio module.

And so Portfile has on line #

 77 configure.args-append \
…
 85                     -DWITH_FFMPEG=ON \

When compilation fails with version 3.2.0 then the reason is certainly: pre-Lion. Although it claims to support PowerPC…

comment:14 Changed 7 years ago by kencu (Ken)

opencv 3.2.0_1 is installable on SnowLeopard:

$ port -v installed opencv
The following ports are currently installed:
  opencv @3.2.0_1 (active) platform='darwin 10' archs='x86_64' date='2017-10-22T20:39:20-0700'

with one adjustment in the portfile:

platform darwin 10 {
    configure.args-append -DWITH_AVFOUNDATION=OFF
}

I'm not sure if this configuration is optimal; there is some QuickTime stuff in the software that might be useful on SnowLeopard. I tried turning that on, but it didn't immediately build right off.

/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_graphics_opencv/opencv/work/opencv-3.2.0/modules/videoio/src/cap_qt.cpp:75:5: error: unknown type name 'Movie'
    Movie      myMovie;            // movie handle
    ^
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_graphics_opencv/opencv/work/opencv-3.2.0/modules/videoio/src/cap_qt.cpp:103:9: error: use of undeclared identifier 'EnterMovies'
        EnterMovies();
        ^
etc....

I presume the QuickTime framework needs to be included to fix these errors.

Is this useful enough to you to fix it up for the Portfile? Is it usable like this?

It looks like it needs to be applied to Darwin 12 and less, as Darwin 13+ build on the buildbots.

comment:15 in reply to:  14 ; Changed 7 years ago by ballapete (Peter "Pete" Dyballa)

Replying to kencu:

opencv 3.2.0_1 is installable on SnowLeopard:

$ port -v installed opencv
The following ports are currently installed:
  opencv @3.2.0_1 (active) platform='darwin 10' archs='x86_64' date='2017-10-22T20:39:20-0700'

with one adjustment in the portfile:

platform darwin 10 {
    configure.args-append -DWITH_AVFOUNDATION=OFF
}

This works for me too.

I'm not sure if this configuration is optimal; there is some QuickTime stuff in the software that might be useful on SnowLeopard. I tried turning that on, but it didn't immediately build right off.

/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_graphics_opencv/opencv/work/opencv-3.2.0/modules/videoio/src/cap_qt.cpp:75:5: error: unknown type name 'Movie'
    Movie      myMovie;            // movie handle
    ^
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_graphics_opencv/opencv/work/opencv-3.2.0/modules/videoio/src/cap_qt.cpp:103:9: error: use of undeclared identifier 'EnterMovies'
        EnterMovies();
        ^
etc....

I presume the QuickTime framework needs to be included to fix these errors.

I hope you do not refer to the qt4 and qt5 variants. These refer to the Trolltech cross-platform UI framework…

comment:16 in reply to:  15 Changed 7 years ago by kencu (Ken)

Replying to ballapete:

I hope you do not refer to the qt4 and qt5 variants. These refer to the Trolltech cross-platform UI framework…

Nope, qt4 & qt5 has nothing specific to do with QuickTime.

I don't use opencv for anything. Although I know it builds on 10.6.8, in the present configuration, is it usable?

comment:17 Changed 7 years ago by ballapete (Peter "Pete" Dyballa)

I don't know yet. It wasn't working… I was looking for a more up-to-date command line tool to convert video and audio formats. Some day I'll look into it!

comment:18 Changed 7 years ago by kencu (Ken)

Here's the current block I add to the Portfile to build opencv 3.4.0 on older systems:

# older systems compatability fixes
if {${os.platform} eq "darwin" && ${os.major} < 11} {
    # all default compilers fail so force a reasonable compiler choice
    PortGroup cxx11 1.1

    # disable AVFoundation which exists on 10.7+
    configure.args-append -DWITH_AVFOUNDATION=OFF

    # tweak thread-local-storage needs on older systems
    # https://github.com/google/protobuf/blob/master/src/google/protobuf/stubs/platform_macros.h
    if {[string match *clang* ${configure.cxx}]} {
        configure.cppflags-append  -DGOOGLE_PROTOBUF_NO_THREADLOCAL
    }
}

comment:19 Changed 7 years ago by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)

Cc: MarcusCalhoun-Lopez added

comment:20 Changed 7 years ago by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)

Resolution: fixed
Status: assignedclosed

In 63e2fa243f81911c233249374562c099e3993b54/macports-ports (master):

opencv: update version 3.3.1->3.4.1

Fixes #53543
Fixes #53562

Note: See TracTickets for help on using tickets.