OpenCV 3 on Mac with Xcode 6.2

Introduction

OpenCV 演变到v3已经快一年了。对于各类软件新版本的尝试已经没有了兴趣(乐趣?)。直到现在想测试一下TextProposals,发现作者用了OpenCV 3.0才最终决定再尝试一下 — 希望变化不要太大。

Main Problems and Solutions

opencv_contrib

add the following to the cmake command to compile with contrib modules

  • -D CMAKE_INSTALL_PREFIX=/path/to/opencv-3.1.0/build/
Conflicts with OpenCV from MacPorts

Early error message goes with anywhere cv::Mat is used!!

  • /opt/local/include/opencv2/core/mat.hpp:67:8: Incomplete type ‘cv::Mat’ named in nested name specifier

Strange thing is, why the heck the errors ended with an older version of OpenCV (2.4.11) installed from MacPorts?

Simply deactivate the macports version temporarily, or permanently!

  • sudo port deactivate opencv
CMake

Loads errors popped up (201 errors to be precise) when trying to build opencv_videoio module

Some say it need to link to CoreMedia and VideoToolbox Framework.
The trouble is, I could not for the life of me now find how to link framework in Xcode….

Fortunately, it turned out that’s not the real reason anyway.

In $OpenCV3.1.0_Root/cmake/OpenCVFindLibsVideo.cmake, when checking ffmpeg, it is hard-coded to link to static library at the end. So, change .a extension to .dylib solve the errors. Five places in total!

Undefined symbols for architecture x86_64:
  "_CMBlockBufferCreateWithMemoryBlock", referenced from:
      _videotoolbox_common_end_frame in libavcodec.a(videotoolbox.o)
  "_CMSampleBufferCreate", referenced from:
      _videotoolbox_common_end_frame in libavcodec.a(videotoolbox.o)
  "_CMVideoFormatDescriptionCreate", referenced from:
      _av_videotoolbox_default_init2 in libavcodec.a(videotoolbox.o)
  "_ModPlug_GetCurrentOrder", referenced from:
      _modplug_read_packet in libavformat.a(libmodplug.o)
  "_ModPlug_GetCurrentPattern", referenced from:
      _modplug_read_packet in libavformat.a(libmodplug.o)
  "_ModPlug_GetCurrentRow", referenced from:
      _modplug_read_packet in libavformat.a(libmodplug.o)
  "_ModPlug_GetCurrentSpeed", referenced from:
      _modplug_read_packet in libavformat.a(libmodplug.o)
  "_ModPlug_GetCurrentTempo", referenced from:
      _modplug_read_packet in libavformat.a(libmodplug.o)
  "_ModPlug_GetLength", referenced from:
      _modplug_read_header in libavformat.a(libmodplug.o)
  "_ModPlug_GetMessage", referenced from:
      _modplug_read_header in libavformat.a(libmodplug.o)
  "_ModPlug_GetName", referenced from:
      _modplug_read_header in libavformat.a(libmodplug.o)
  "_ModPlug_GetSettings", referenced from:
      _modplug_read_header in libavformat.a(libmodplug.o)
  "_ModPlug_InstrumentName", referenced from:
      _modplug_read_header in libavformat.a(libmodplug.o)
  "_ModPlug_Load", referenced from:
      _modplug_read_header in libavformat.a(libmodplug.o)
  "_ModPlug_NumChannels", referenced from:
      _modplug_read_header in libavformat.a(libmodplug.o)
  "_ModPlug_NumInstruments", referenced from:
      _modplug_read_header in libavformat.a(libmodplug.o)
  "_ModPlug_NumPatterns", referenced from:
      _modplug_read_header in libavformat.a(libmodplug.o)
  "_ModPlug_NumSamples", referenced from:
      _modplug_read_header in libavformat.a(libmodplug.o)
  "_ModPlug_Read", referenced from:
      _modplug_read_packet in libavformat.a(libmodplug.o)
  "_ModPlug_SampleName", referenced from:
      _modplug_read_header in libavformat.a(libmodplug.o)
  "_ModPlug_Seek", referenced from:
      _modplug_read_seek in libavformat.a(libmodplug.o)
  "_ModPlug_SetSettings", referenced from:
      _modplug_read_header in libavformat.a(libmodplug.o)
  "_ModPlug_Unload", referenced from:
      _modplug_read_close in libavformat.a(libmodplug.o)
  "_SSLClose", referenced from:
      _tls_open in libavformat.a(tls_securetransport.o)
      _tls_close in libavformat.a(tls_securetransport.o)
  "_SSLCopyPeerTrust", referenced from:
      _tls_open in libavformat.a(tls_securetransport.o)
  "_SSLCreateContext", referenced from:
      _tls_open in libavformat.a(tls_securetransport.o)
  "_SSLHandshake", referenced from:
      _tls_open in libavformat.a(tls_securetransport.o)
  "_SSLRead", referenced from:
      _tls_read in libavformat.a(tls_securetransport.o)
  "_SSLSetCertificate", referenced from:
      _tls_open in libavformat.a(tls_securetransport.o)
  "_SSLSetConnection", referenced from:
      _tls_open in libavformat.a(tls_securetransport.o)
  "_SSLSetIOFuncs", referenced from:
      _tls_open in libavformat.a(tls_securetransport.o)
  "_SSLSetPeerDomainName", referenced from:
      _tls_open in libavformat.a(tls_securetransport.o)
  "_SSLSetSessionOption", referenced from:
      _tls_open in libavformat.a(tls_securetransport.o)
  "_SSLWrite", referenced from:
      _tls_write in libavformat.a(tls_securetransport.o)
  "_SecIdentityCreate", referenced from:
      _tls_open in libavformat.a(tls_securetransport.o)
  "_SecItemImport", referenced from:
      _import_pem in libavformat.a(tls_securetransport.o)
  "_SecTrustEvaluate", referenced from:
      _tls_open in libavformat.a(tls_securetransport.o)
  "_SecTrustSetAnchorCertificates", referenced from:
      _tls_open in libavformat.a(tls_securetransport.o)
  "_VTDecompressionSessionCreate", referenced from:
      _av_videotoolbox_default_init2 in libavcodec.a(videotoolbox.o)
  "_VTDecompressionSessionDecodeFrame", referenced from:
      _videotoolbox_common_end_frame in libavcodec.a(videotoolbox.o)
  "_VTDecompressionSessionInvalidate", referenced from:
      _av_videotoolbox_default_free in libavcodec.a(videotoolbox.o)
  "_VTDecompressionSessionWaitForAsynchronousFrames", referenced from:
      _videotoolbox_common_end_frame in libavcodec.a(videotoolbox.o)
  "___gmpz_add_ui", referenced from:
      _ff_dh_generate_public_key in libavformat.a(rtmpdh.o)
  "___gmpz_clear", referenced from:
      _ff_dh_free in libavformat.a(rtmpdh.o)
      _ff_dh_generate_public_key in libavformat.a(rtmpdh.o)
      _dh_is_valid_public_key in libavformat.a(rtmpdh.o)
      _ff_dh_compute_shared_secret_key in libavformat.a(rtmpdh.o)
  "___gmpz_cmp", referenced from:
      _dh_is_valid_public_key in libavformat.a(rtmpdh.o)
  "___gmpz_cmp_ui", referenced from:
      _dh_is_valid_public_key in libavformat.a(rtmpdh.o)
  "___gmpz_export", referenced from:
      _ff_dh_write_public_key in libavformat.a(rtmpdh.o)
      _ff_dh_compute_shared_secret_key in libavformat.a(rtmpdh.o)
  "___gmpz_fdiv_r_2exp", referenced from:
      _ff_dh_generate_public_key in libavformat.a(rtmpdh.o)
  "___gmpz_import", referenced from:
      _ff_dh_compute_shared_secret_key in libavformat.a(rtmpdh.o)
  "___gmpz_init2", referenced from:
      _ff_dh_init in libavformat.a(rtmpdh.o)
      _ff_dh_generate_public_key in libavformat.a(rtmpdh.o)
      _dh_is_valid_public_key in libavformat.a(rtmpdh.o)
      _ff_dh_compute_shared_secret_key in libavformat.a(rtmpdh.o)
  "___gmpz_mul_2exp", referenced from:
      _ff_dh_generate_public_key in libavformat.a(rtmpdh.o)
  "___gmpz_powm", referenced from:
      _ff_dh_generate_public_key in libavformat.a(rtmpdh.o)
      _dh_is_valid_public_key in libavformat.a(rtmpdh.o)
      _ff_dh_compute_shared_secret_key in libavformat.a(rtmpdh.o)
  "___gmpz_set", referenced from:
      _dh_is_valid_public_key in libavformat.a(rtmpdh.o)
  "___gmpz_set_str", referenced from:
      _ff_dh_init in libavformat.a(rtmpdh.o)
      _ff_dh_generate_public_key in libavformat.a(rtmpdh.o)
      _ff_dh_compute_shared_secret_key in libavformat.a(rtmpdh.o)
  "___gmpz_set_ui", referenced from:
      _ff_dh_init in libavformat.a(rtmpdh.o)
      _ff_dh_generate_public_key in libavformat.a(rtmpdh.o)
      _dh_is_valid_public_key in libavformat.a(rtmpdh.o)
  "___gmpz_sizeinbase", referenced from:
      _ff_dh_generate_public_key in libavformat.a(rtmpdh.o)
      _ff_dh_write_public_key in libavformat.a(rtmpdh.o)
      _ff_dh_compute_shared_secret_key in libavformat.a(rtmpdh.o)
  "___gmpz_sub_ui", referenced from:
      _dh_is_valid_public_key in libavformat.a(rtmpdh.o)
  "_bd_close", referenced from:
      _bluray_close in libavformat.a(bluray.o)
  "_bd_free_title_info", referenced from:
      _bluray_open in libavformat.a(bluray.o)
  "_bd_get_disc_info", referenced from:
      _bluray_open in libavformat.a(bluray.o)
  "_bd_get_title_info", referenced from:
      _bluray_open in libavformat.a(bluray.o)
  "_bd_get_title_size", referenced from:
      _bluray_seek in libavformat.a(bluray.o)
  "_bd_get_titles", referenced from:
      _bluray_open in libavformat.a(bluray.o)
  "_bd_open", referenced from:
      _bluray_open in libavformat.a(bluray.o)
  "_bd_read", referenced from:
      _bluray_read in libavformat.a(bluray.o)
本文详细介绍了如何利用Python语言结合MySQL数据库开发一个学生管理系统。通过这一过程,读者不仅能够掌握系统设计的基本思路,还能学习到如何使用Python进行数据库操作。该系统涵盖了用户界面设计、数据验证以及数据库的增删改查等多个关键环节。 Python作为一种高级编程语言,以简洁易懂著称,广泛应用于数据分析、机器学习和网络爬虫等领域,同时也非常适合用于快速开发数据库管理应用。MySQL是一个广泛使用的开源关系型数据库管理系统,具有轻量级、高性能、高可靠性和良好的编程语言兼容性等特点,是数据存储的理想选择。在本系统中,通过Python的pymysql库实现了与MySQL数据库的交互。 pymysql是一个Python第三方库,它允许程序通过类似DB-API接口连接MySQL数据库,执行SQL语句并获取结果。在系统中,通过pymysql建立数据库连接,执行SQL语句完成数据的增删改查操作,并对结果进行处理。 系统采用命令行界面供用户操作。程序开始时,提示用户输入学生信息,如学号、姓名和各科成绩,并设计了输入验证逻辑,确保数据符合预期格式,例如学号为1至3位整数,成绩为0至100分的整数。 数据库设计方面,系统使用名为“test”的数据库和“StuSys”表,表中存储学生的学号、姓名、各科成绩及总成绩等信息。通过pymysql的cursor对象执行SQL语句,实现数据的增删改查操作。在构建SQL语句时,采用参数化查询以降低SQL注入风险。 系统在接收用户输入时进行了严格验证,包括正则表达式匹配和数字范围检查等,确保数据的准确性和安全性。同时,提供了错误处理机制,如输入不符合要求时提示用户重新输入,数据库操作出错时给出相应提示。 在数据库操作流程中,用户可以通过命令行添加学生信息或删除记录。添加时会检查学号是否重复以避免数据冲突,删除时需用户确认。通过上述分析,本文展示了从
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值