Building OpenCV as a macOS Universal Intel Binary

0

Posted by Jaime | Posted in Coding | Posted on 02-03-2017

Tags: , , , ,

OpenCV

So, for my project, I needed an Intel Universal build of the OpenCV library.

The copy of the OpenCV source I have on my machine is version 3.0.0 and it has worked well for me, so I’ll start with that.

My build machine is running macOS 10.12 and has Xcode 8 installed on it.

OpenCV uses cmake for its build system, so you have to download and install the CMake app for macOS. I got my copy from https://cmake.org

I referred to the article listed on Wired Watershed to help me get started.

I made the following changes to the project once CMake.app was done processing the source folder.

  • Set CMAKE_OSX_ARCHITECTURES value to $(ARCHS_STANDARD_32_64_BIT)
  • Set CMAKE_OSX_DEPLOYMENT to 10.8, since my project needed it.
  • Unchecked 1394

However, when the 32-bit portion of the project went to build, it reported the following error: cap_qtkit.mm:46:9: fatal error: ‘QTKit/QTKit.h’ file not found.

Apparently, this is a known issue.

So, I thought I could solve this problem by going to version 3.2.0… off to GitHub

I cloned the master branch to my machine and ran CMake again on the new source, but when I build the project with Xcode 8, I saw other problems.

So..

  • I unchecked WITH_LAPACK
  • I had to go into the Xcode project and set the C version to c11, and the C++ version to c++14.

Ok, things are getting better, but… the code doesn’t compile for 32-bit.

Dangit!

This can be fixed by … fixing the code?

Off to GitHub again, where I forked the OpenCV project and fixed the Obj-C++ code so that it will build for 32-bit Intel.

With that done, I create a pull request.

If you would like your own copy of the code I modified, you can clone the forked OpenCV repo.

Xcode plugin for Perforce

0

Posted by Jaime | Posted in Coding | Posted on 18-03-2015

Tags: , ,

perforce-small-logo
I use Perforce as my version control system and Xcode as my IDE.

Unfortunately, Apple removed Perforce support from Xcode a whiles back for reasons unknown.

So, to work around the problem, I started to use of DTerm… but I wanted more.

I created AppleScripts for both Xcode4 and Xcode5 which was better, but… I wanted more.

So, I took the plung and wrote a plugin for Xcode using Swift.

The plugin is hosted on Perforce’s Swarm website, which you can download and build in Xcode. Once you build the project, the plugin is automatically installed for you.

Pay attention to the README.md file: you will need set up files that contain the settings for your workspace, or workspaces, and those settings file are used by the plugin to do it’s work.

A big thanks to Delisa Mason for writing a Xcode plugin template. This template was a huge help in creating the plugin and the template available in the Alcatraz package manager as well as in GitHub: https://github.com/kattrali/Xcode-Plugin-Template

If you don’t know what Alcatraz is, you should check out at http://alcatraz.io

Xcode dylib constructor destructor

0

Posted by Jaime | Posted in Coding | Posted on 26-02-2015

Tags: ,

I meant to post this link a while ago, but here it is anyway:
TP40002013-SW17

So, in a dylib, you can have code execute when the dylib is loaded and execute code when the dylib is being unloaded:

__attribute__((constructor))
static void initializer1() {
    printf("[%s] [%s]\n", __FILE__, __FUNCTION__);
}
 
__attribute__((constructor))
static void initializer2() {
    printf("[%s] [%s]\n", __FILE__, __FUNCTION__);
} 
__attribute__((destructor))
static void finalizer1() {
    printf("[%s] [%s]\n", __FILE__, __FUNCTION__);
}
 
__attribute__((destructor))
static void finalizer2() {
    printf("[%s] [%s]\n", __FILE__, __FUNCTION__);
}

openframeworks plugin for Xcode

0

Posted by Jaime | Posted in Coding | Posted on 23-12-2014

Tags:

Sweet! Now you can add open frameworks add ons to your project from a Xcode plugin: https://github.com/admsyn/OFPlugin

Of course, if you have Alcatraz, you won’t need to go to the github site to download the plugin, just get it from “Package Manager” within Xcode

You can run Swift code from the command line?

0

Posted by Jaime | Posted in Coding | Posted on 23-12-2014

Tags: , , ,

WAT? Now this is something else! practicalswift.com

A package manager for Xcode named Alcatraz

0

Posted by Jaime | Posted in Coding, Tools | Posted on 25-09-2014

Tags: , ,

I learned about a package manager for Xcode named Alcatraz when I attended CocoaConf in San Jose earlier this year.

Extending the functionality of Xcode through plugins has been something I’ve been looking into for a while and the only plugins I knew about in the wild could only be found through Google searches or on NSHipster.com

alcatraz_xcode_packagemanager

The tool makes it much easier to find plugins for Xcode. Buuuut, it actually also serves up themes, templates and more, all from a menu available within Xcode.

Installation is also simple. Type in a single Terminal command and hooorah, it’s installed: curl -fsSL https://raw.github.com/supermarin/Alcatraz/master/Scripts/install.sh | sh

Oh, and if you are looking to attend an Apple developer conference, you should definitely consider CocoaConf: the attendee group is primarily developers, attendees and speakers are easy to approach and exchange ideas with, and as they had advertised on CocoaConf’s site, the food is good.

And now, another language

0

Posted by Jaime | Posted in Coding | Posted on 05-06-2014

Tags: , , , , , , ,

swift-hero_2x

You know, I was getting quite comfortable with Obj-C, C++11, and everything else I had learned over the years… now Apple has to go and introduce another language: Swift

I don’t know what to make of it. How much better can it be than Obj-C? I guess I’ll find out over the course of the year.

I do have to say though, that “let” and “var” are pretty cool, in the same way that “auto” is pretty cool in C++11.

Oh, and if you haven’t already read Herb Sutter’s article on why you should use “auto” in your code, check it out here: AAA

Perforce and Xcode5

3

Posted by Jaime | Posted in Tools | Posted on 06-11-2013

Tags: , , ,

In a previous post, Perforce and Xcode4, I created applescripts to work with Xcode4 and Perforce.

I updated the AppleScripts to work with Xcode5 only and added a couple of new scripts.

One, called p4_file_renamed.scpt, is used to update the renamed file Perforce when you are using Xcodes rename functionality, either directly or through the refactor functionality.

The other two scripts get the filename of the currently selected file or the full path of the file which is useful for when you want to find a file by path in P4V.

You can download the file here: xcode5_p4_applescripts

Perforce and Xcode4

12

Posted by Jaime | Posted in Coding | Posted on 14-08-2013

Tags: , , , , , ,

I created some AppleScripts that allow you to control some basic Perforce functionality in Xcode4, which was lost when Apple released the latest version of their IDE.

Perforce actually published a way of checking out files using the Behaviors functionality in Xcode (Xcode and P4), but I wanted a little more.

Note, these scripts are a work in progress. If you happen to make improvements, let me know so that those changes can be shared with the community.

You can download the AppleScripts here: xcode_p4_applescripts

Update
The AppleScript files are also being hosted on the public Perforce swarm forum, located here: Perforce Public Swarm Server

Update 2013-11-06
I updated the AppleScripts to work with Xcode5 only and added a couple of new scripts.

The new applescript files are referenced in post Perforce and Xcode5

A note about performance

1

Posted by Jaime | Posted in Coding | Posted on 02-08-2013

Tags: , , , ,

On a multi-core Mac, running 10.8, I ran a test to compare the speed differences of incrementing or decrementing a value with no-locks, atomics and finally, a mutex lock.

The no-lock is the baseline, and here is the difference in speed with the later 2 items:
Atomics: 3X slower on the same thread
Mutex: 7X slower on the same thread

Hmmm…