modules/objc/doc/LandingPage_osx.md
This is the documentation for the macOS OpenCV framework.
Follow the steps below to get a simple "Hello World" app running on macOS
Framework.framework but depending on how you built it or from where you obtained it your framework may have extension .xcframework)ViewController.swift fileimport for the OpenCV framework below the existing import for Cocoaimport opencv2
viewDidLoad function with the following codeoverride func viewDidLoad() {
super.viewDidLoad()
let white = Scalar(255, 255, 255, 255)
let black = Scalar(0, 0, 0, 255)
let m = Mat(rows: 400, cols: Int32(view.frame.width), type: CvType.CV_8UC4, scalar: white)
Imgproc.putText(img: m, text: "Hello World", org: Point(x: 10, y: 250), fontFace: HersheyFonts.FONT_HERSHEY_DUPLEX, fontScale: 2, color: black)
let image = m.toNSImage()
let imageView = NSImageView(frame: NSRect(x: 0, y: 0, width: Int(m.cols()), height: Int(m.rows())))
imageView.image = image
self.view.addSubview(imageView)
}
ViewController.swift file should now look like thisIf that has all worked well then congratulations. If not then feel free to reach out to the OpenCV community for help. Also feel free to contribute fixes and improvements.