2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

OpenCV + iOS (Swift) + CvVideoCamera: サンプル

Posted at

はじめに

OpenCV を Swfit で書いたアプリに組み込んで、カメラで撮影した画像をリアルタイムに画像処理して表示するサンプルアプリを作ってみました。

背景

OpenCV を iOS で使うには、 OpenCV から公式配布されている opencv2.framework をプロジェクトに組み込めば容易に使えます。

しかし、 OpenCV は C++ のライブラリなので、 iOS で使うには Objective-C++ を書かなければいけません!

もっぱら最近の iOS アプリは、 Swift で書かれていると思います。
Swift から Objective-C++ を使うにはブリッジファイルを用意する必要があります。

ソースコード

GitHub で公開しています。
https://github.com/kulikala/ios-opencv-skeleton

ローカルにクローンして使ってください。

git clone git@github.com:kulikala/ios-opencv-skeleton.git
cd ios-opencv-skeleton

CocoaPods

OpenCV のフレームワークを Xcode プロジェクトに取り込む方法として、 Carthage や SwiftPM などがありますが、オールドクラシックに Podfile を使う方法にしています。

pod install

開くときには、 CocoaPods が作成する OpenCVSkeleton.xcworkspace を開いてください。

open OpenCVSkeleton.xcworkspace
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?