8

I have followed this http://www.pyimagesearch.com/2015/06/15/install-opencv-3-0-and-python-2-7-on-osx/ to install OpenCV on my mac. When I do this step : $ make -j4 a problem happened:

fatal error: 
      'QTKit/QTKit.h' file not found
#import <QTKit/QTKit.h>
        ^ 1 error generated. make[2]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_qtkit.mm.o]
Error 1 make[1]: ***
[modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2 make: ***
[all] Error 2
halfelf
  • 9,737
  • 13
  • 54
  • 63
潘思源
  • 81
  • 1
  • 2
  • I suggest you use Anaconda, have a look at [this tutorial](https://rivercitylabs.org/up-and-running-with-opencv3-and-python-3-anaconda-edition/) – AlvaroP Sep 20 '16 at 18:25
  • You are not alone with QTKit and Xcode8 problem: https://github.com/Homebrew/homebrew-science/issues/4303 – k06a Sep 22 '16 at 15:46

6 Answers6

4

Try building it like this instead:

cmake -DWITH_QUICKTIME=OFF -DWITH_GSTREAMER=OFF -DWITH_FFMPEG=OFF -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DCMAKE_BUILD_TYPE=Release .. ; make -j4
Ohad Kravchick
  • 1,154
  • 11
  • 15
  • Worked for me to resolve the QTKit error - lead me to this error - http://stackoverflow.com/questions/29724408/build-opencv-2-4-10-on-mac-10-10-3-failed – mrwaim Sep 28 '16 at 06:52
4

Here is a workaround solution to fix the issue:

  1. Download MACOSX SDK here.
  2. extract head files from MacOSX10.11.sdk/MacOSX10.11.sdk/System/Library/Frameworks/QTKit.framework/Headers/
  3. Create a folder under opencv source file folder: opencv-3.2.0/modules/highgui/src/QTKit, and copy all header files into the folder.
  4. Follow the regular opencv build steps. When you run make -j8, you don't need set "-DWITH_QUICKTIME=OFF -DWITH_GSTREAMER=OFF -DWITH_FFMPEG=OFF"

This works for opencv2.x and 3.x

noufalcep
  • 3,446
  • 15
  • 33
  • 51
feiyun
  • 131
  • 1
  • 5
2

Can you try to install opencv on mac using brew?

brew reinstall opencv3 --HEAD --with-python3 --with-ffmpeg --with-tbb --with-contrib

Worked for me on MAC OS SIERRA.

nikoo28
  • 2,961
  • 1
  • 29
  • 39
0

This error is because of QuickTime Kit was deprecated in OS X v10.9,and Apple suggest to use AVFoundation framework instead Apple API Reference.

OpenCV (version 3.1.0) is relaying on QuickTime Kit. So, when you trying to install OpenCV (before version 3.1.0) on OSX Sierra, It will raise error when you make.

Try install the master version of opencv will be OK !

OpenCV had AVFoundation Framework supported in https://github.com/opencv/opencv/pull/7159

yorelog
  • 373
  • 1
  • 2
  • 6
0

use --with-quicktime or -DWITH_QUICKTIME=TRUE. It will use QUITCKTIME Instead of QTKit for Video I/O

FelixSFD
  • 6,052
  • 10
  • 43
  • 117
  • QuickTime is depracated too in Sierra `fatal error: 'QuickTime/QuickTime.h' file not found #include ` – ldg Mar 22 '18 at 18:59
0

Thanks to @feiyun Here is a workaround solution to fix my issue:

  1. Download MACOSX SDK here.
  2. Extract head files from MacOSX10.11.sdk/MacOSX10.11.sdk/System/Library/Frameworks/QTKit.framework/Headers/
  3. Copy all Headers and Modules files into your corresponding folder.
cd /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks
cd QTKit.framework
cd Versions
cd Current
sudo cp -r /Users/mac/Desktop/MacOSX-SDKs-MacOSX10.11.sdk/MacOSX10.11.sdk/System/Library/Frameworks/QTKit.framework/Versions/Current/Headers .
sudo cp -r /Users/mac/Desktop/MacOSX-SDKs-MacOSX10.11.sdk/MacOSX10.11.sdk/System/Library/Frameworks/QTKit.framework/Versions/Current/Modules .
cd ..
cd ..
sudo ln -s Versions/Current/Headers Headers
sudo ln -s Versions/Current/Modules Modules
(tf20) mac@Macbook:/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/QTKit.framework$ ls -l
total 0
lrwxr-xr-x  1 root  wheel   24 Jan  4 10:09 Headers -> Versions/Current/Headers
lrwxr-xr-x  1 root  wheel   24 Jan  4 10:10 Modules -> Versions/Current/Modules
lrwxr-xr-x  1 root  wheel   26 Dec 17 16:33 QTKit.tbd -> Versions/Current/QTKit.tbd
drwxr-xr-x  4 root  wheel  128 Dec 17 16:33 Versions
  1. Follow the regular opencv build steps. When you run make -j8, you don't need set "-DWITH_QUICKTIME=OFF -DWITH_GSTREAMER=OFF -DWITH_FFMPEG=OFF"

This works for opencv2.x and 3.x

Flair
  • 2,609
  • 1
  • 29
  • 41
Jack Huang
  • 31
  • 4