Qian's Blog

March 5, 2010

Using OpenCV on Mac OS X

Filed under: 未分类 — Tags: , , — Qian He @ 5:18 pm

昨天checkout了OpenCV最新的代码,发现make_framework.sh这个用于在Mac OS平台上编译OpenCV的脚本已经被移除了,具体开始移除的版本是r2528,而最后一个能成功使用该脚本编译的版本是r2492。阅读了一下OpenCV的wiki,发现这个条目在2010-02-28更新过。说明了make_framework.sh这个脚本已经被从trunk中移除的原因,理由是以后要全面使用CMake来做cross-platform build。

但是有意思的是,作者在讲解如何使用CMake在Mac OS上build的章节题目叫做:

2. Building from source using the new CMake build system (currently unstable and difficult)

The GNU autotools methods (make && make install) are being outdated. Volunteers to edit this section?

灰常不理解OpenCV的开发团队为什么要在B方案都还不稳定的情况下裁撤A方案。

于是,我在Mac OS X 10.6.2 + Xcode 3.2.1的环境下编译了OpenCV r2492这个版本,并且打包了一个放在:Dropbox,嫌麻烦的朋友可以直接下载这个Universal的Private Framework。另外,还有一个别人编译了的OpenCV 2.0 Gold Release的版本。这个版本有一个问题,在挂在.dmg文件后,它给出的目的文件目录是“/System/Library/Frameworks”。而根据Apple的说明

Third-party frameworks should never be installed in the /System/Library/Frameworks directory. Access to this directory is restricted and is reserved for Apple-provided frameworks only.

Most public frameworks should be installed at the local level in /Library/Frameworks.

If your framework should only be used by a single user, you can install it in the ~/Library/Frameworks subdirectory of the current user; however, this option should be avoided if possible.

If they are to be used across a local area network, they can be installed in /Network/Library/Frameworks; however, this option should be avoided if possible.

该目录应该是“Apple-provided frameworks only”的。实践也证明,将OpenCV.framework放在“/System/Library/Frameworks”目录下,项目可以add这个framework,但是无法正确找到头文件。正确的放置目录应该是“/Library/Frameworks”。

用OpenCV提供的sample: FaceTracker测试一下吧~(记得检查一下framework和haarcascade在项目里面配置的文件位置)

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress