Yesterday I took this gift… Ok as a new joined SCS Members, everyone can choose a gift from either selfie stick or luggage still. Finally I found a free slot to get it from them.
Today I watched this movie in GV Suntec City, The Imitation Game. The real story about Alan Turing, who known as the pioneer or creator of computer science, how we invented a machine that beats another machine – Enigma, A German Machine that can encode important military message.
Can’t control my tears when watched until the last part of the movie.
No many people know who is him, why he is so important. Without his works, there is no new mathematical fields exist – Computer Science. Without him, we don’t have Computer, Mac, iPhone, or maybe only exist 100 years later. Without him, the world war II may take longer to end, ten million more people be killed.
This is my first time, the hello world to book a movie ticket, through online, watched a movie in cinema. In my previous life, I only went to cinema once, when I am young, brought by my uncle. Then I joined two times with company events. Today, the fourth, but the first, happened. And this is the first time I walked through inner building from City Hall MRT how to find where the tower 4 level 3 is.
1) to download prebuilt opencv2.framework, the fine working version is 2.4.9.
2) to create new XCode Project, target iOS8.0 if you are under XCode 6.0.1 as this version not yet support iOS8.1
3) link opencv2.framework to XCode Project. Go to project build phase, and link following frameworks:
opencv2.framework
AssetsLibrary.framework
AVFoundation.framework
CoreGraphics.framework
CoreImage.framework
CoreMedia.framework
CoreVideo.framework
Foundation.framework
UIKit.framework
Accelerate.framework
4) Create <NameOfProject>-Prefix.pch, with following snippets of code add between ifdef / endif block.
5) in ViewController.h, add the following to header
#import <opencv2/highgui/cap_ios.h>
#include <opencv2/opencv.hpp>
Note, the most important line is #include <opencv2/opencv.hpp>, this is important to make the stuffs works. I spent few hours and found this solve my problems, which unable to recognize cvtColor function, OK, will introduce in next steps.
6) To do some testing, by adding a video camera, reading 30 frames per second, process the images by inverting the color…
7) Rename ViewController.m to ViewController.mm as we are going to put C PlusPlus Code. Extension mm allows coexist of Objective C and C PlusPlus.
8) In ViewController.h, add following line
@property (nonatomic, retain) CvVideoCamera* videoCamera;
9) In ViewController.mm, we initialize videoCamera and starts it.
10) In ViewController.h, add CvVideoCameraDelegate
Like this
@interface ViewController : UIViewController
11) In ViewController.mm, add following snippets of code before @end.
#pragma mark – Protocol CvVideoCameraDelegate
#ifdef __cplusplus
– (void)processImage:(Mat&)image;
{
// Do some OpenCV stuff with the image
Mat image_copy;
cvtColor(image, image_copy, CV_BGRA2BGR);
bitwise_not(image_copy, image_copy);
cvtColor(image_copy, image, CV_BGR2BGRA);
}
#endif
CMake, the cross-platform, open-source build system. CMake is a family of tools designed to build, test and package software. CMake is used to control the software compilation process using simple platform and compiler independent configuration files. CMake generates native makefiles and workspaces that can be used in the compiler environment of your choice.
To install CMake on Mac, you can download the precompiled binaries here. Under platforms Mac OSX 10.6 or later, I chose cmake-3.1.0-Darwin64.dmg at the time of writing.
Once downloaded, run open cmake-3.1.0-Darvin64.dmg on terminal.
A finder view shown. Drag cmake-3.1.0-Darvin64.dmg to Applications shortcut, it will copy the binary to Applications folder.
Open the applications by sudo.
Do sudo /Applications/CMake.app/Contents/MacOS/CMake
Click on menu Tools, Install for Command line use.
GCDWebServer is a former Objective-C project that embeds a web server in iOS / OSX application. This tutorial explains how to add GCDWebServer into Swift based iOS project.
Go into GCDWebServer directory, you will see there are GCDWebServer, GCDWebDAVServer, GCDWebUploader…. In this case, we just need GCDWebServer to build a simple HTTP Server. Copy this folder to your application root folder. Looks like this.
Step 3:
Add a bridging header if it is not exist.
Right click your project navigator, add a new “header file” under iOS source tab. Name it as <YourApplicationName>-Bridging-Header.h.
Go to your project navigator, build settings, Swift compiler – Code Generation, Objective-C Bridging Header, enter the path to the <YourApplicationName>-Bridging-Header.h
Step 5:
Go to your project navigator, build phases, under Link Binary with Libraries, click to add “libz.dylib”.
Step 6:
At the time of writing, the current GCDWebServer not working properly and have to change something make it to work.
Find GCDWebServer.h and locate addDefaultHandlerForMethod, set the second one as addDefaultAsyncHandlerForMethod.
Find GCDWebServer.m and locate addDefaultHandlerForMethod, set the second one as addDefaultAsyncHandlerForMethod. Under first addDefaultHandlerForMethod, change the second line of the occurrence to addDefaultAsyncHandlerForMethod instead.
Step 7:
Put following test code and run.
// http server
let webServer = GCDWebServer()
webServer.addDefaultHandlerForMethod(“GET”, requestClass: GCDWebServerRequest.self) { request in