Saturday, October 12, 2013

Steps to install OpenCV on Mac OS X for XCode

Reference: http://tilomitra.com/opencv-on-mac-osx/

OpenCV installation steps:
1. Install MacPorts
2. Install CMake by "sudo port install cmake"
3. Get OpenCV source, http://opencv.willowgarage.com/wiki/InstallGuide, and untar it
4. Build OpenCV
   Go to the folder where you untar the OpenCV source to.
   Make a separate folder for building
   . make build
   . cd build
   . cmake -G "Unix Makefiles" ..
   Now make OpenCV
   . make -j8
   . sudo make install
   The OpenCV will be installed to /usr/local
5. Done installing the OpenCV on Mac OS X

Create a sample project on XCode with OpenCV
1. Start a new XCode "Command Line Tool" project with Type C++
2. Add all the libopencv*.dylib (or the ones you need) into the project from /usr/local/lib with "Copy items into destination group's folder (if needed)" checked
3. Add "/usr/local/include" into "Header Search Path" in Build Settings of project
4. Add "/usr/local/lib" into "Library Search Path" in Build Settings of project
5. Either 4.1 or 4.2
   4.1 Select "libstdc++ (GNU C++ standard library)" instead of "libc++ (LLVM C++ standard library with C++11 support)" in "Apple LLVM compiler 4.2 - Language" in Build Settings
   4.2 Select "LLVM GCC 4.2" instead of "Default compiler (Apple LLVM compiler 4.2)" in "Compiler for C/C++/Objective-C" in Build Settings
6. Write some codes to test OpenCV

#include
#include
#include "opencv2/core/core.hpp"

using namespace cv ;

int main(int argc, char** argv)
{
#if 0
    //get the image from the directed path
    IplImage* img = cvLoadImage("/Users/Howard/Desktop/Codes/OpenCV/CV/Lena_512.bmp", 1);
    //NSLog(img);
    //create a window to display the image
    cvNamedWindow("picture", 1);
    //show the image in the window
    cvShowImage("picture", img);
    //wait for the user to hit a key
    cvWaitKey(0);
    //delete the image and window
    cvReleaseImage(&img);
    cvDestroyWindow("picture");
#else
    Mat img = imread("/Users/Howard/Desktop/Codes/OpenCV/CV/Lena_512.bmp"    CV_LOAD_IMAGE_UNCHANGED);
    if (img.data == NULL)
    {
        printf("\n Image cannot be loaded") ;
        system("pause");
        return -1;
    }
    namedWindow("OrgImage", CV_WINDOW_AUTOSIZE);
    imshow("OrgImage", img);
    waitKey(0) ;

#endif
}

7. That's all

Thursday, May 9, 2013

Tuesday, November 20, 2012

Install Gitosis on CentOS for multiple developers

Install Gitosis

   [@Server]
   1. Download Gitosis from https://github.com/tv42/gitosis (or git clone git://eagain.net/gitosis )
   2. Install it by
       cd gitosis
       python setup.py install
       If you get errors, try yum install python-setuptools

Generate SSH public/private key (If you don't have one)

   [@Local]
   1. To generate a public/private key, run
       ssh-keygen -t rsa
   2. The newly generated public key will be at $Home/.ssh/ directory and named id_rsa.pub. Private key will be named id_rsa.
   3. Upload your public key to server's /tmp directory
       scp ~/.ssh/id_rsa.pub username@SERVER_IP_ADDRESS:/tmp/YourPublicKey.pub

Configure Gitosis

   [@Server]
   1. Create a user to own the repositories, usually called git
       adduser git
   2. Create the repository and add YourPublicKey into authorized keys
       sudo -H -u git gitosis-init < /tmp/YourPublicKey.pub

Configure the permissions

   [@Local]
   1. To configure who can access to your repositories, clone gitosis-admin first and then edit gitosis.conf in gitosis-admin directory
       git clone git@SERVER_IP_ADDRESS:gitosis-admin.git
       cd gitosis-admin
       vi gitosis.conf
   2. Add a repository, TestProject, and make user Howard has full access to it.
       [New group]
       members = Howard
       writable = TestProject
   3. Get Howard's public key, Howard.pub, from Howard and put it into keydir of gitosis-admin
       cp Howard.pub keydir
   4. Once done, commit it and push to remote server.
       git commit -m "Give Howard full access to TestProject"
       git push

Create the repository TestProject

   [@Local]
   1. User Howard creates the TestProject, initialize it and push it to remote server
       mkdir TestProject
       cd TestProject
       git init
       git remote add originServer git@SERVER_IP_ADDRESS:TestProject.git
       // create files, git add . and commit
       git add .
       git commit -m "Initial commit"
       git push originServer master:refs/heads/master
   2. Now TestProject is created and available on server
   3. To allow user Sibo accessing TestProject, edit gitosis.conf of gitosis-admin and add Sibo to members of [New group] and put Sibo's public key into keydir of gitosis-admin
   4. Commit it and push it remote server and now Sibo will be able to clone TestProject from remote server
       [@Sibo Local]
       git clone git@SERVER_IP_ADDRESS:TestProject.git


Wednesday, November 14, 2012

Git commands

git add . : stages new and modified, without deleted
git add -u : stages modified and deleted, without new
git add -A : stages All

Wednesday, October 31, 2012

application executable is missing a required architecture


The minimum Target supported for XCode 4.5 is iOS 4.3 which means iPhone 3G is no longer supported since the highest iOS version for iPhone 3G is iOS 3.1.3)
So to fix this problem:
. Change iOS Development Target to "iOS 4.3"
. Remove armv6 from the "Architectures" and "Valid Architectures"

Tuesday, September 18, 2012

Compile x264 for Mac OS X (32bits)


./configure --enable-pic --enable-shared --disable-asm --host=i686-apple-darwin11.1.0 --extra-cflags="-arch i386" --extra-ldflags="-arch i386"

Friday, August 17, 2012

Map Box.net storage as a local folder through WebDAV

Steps to map Box.net storage as a local folder
1. Go to Computer
2. Click Map network drive
3. Click "Connect to a web site that you can use to store your documents and pictures"
4. Check "Reconnect at logon"
5. Enter "https://www.box.net/dav" when specifying the location of your website
6. Enter the credentials of your Box.net account
7. That's it.

To unmap the network drive, simply delete it.

Check clients which connect to Mac OS X Wi-Fi Internet Sharing

arp -i bridge100 -a bridge100 may be different on your Mac OSX