Showing posts with label XCode. Show all posts
Showing posts with label XCode. Show all posts

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

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"

Wednesday, February 22, 2012

XCode breakpoint not working

Sometimes the XCode breakpoint becomes not working somehow. To solve this problem, simply restart the iOS device.

Thursday, November 24, 2011

Friday, November 11, 2011

Xcode build setting variables


For all the build setting variables, refers to http://developer.apple.com/library/mac/#documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html

To reference a build setting value in a build setting specification, use the name of the build setting surrounded by parentheses and prefixed by the dollar-sign character ($). For example, the specification of a build setting that refers to the value of the Product Name build setting could be similar to The name of this target's product is $(PRODUCT_NAME).

Thursday, October 13, 2011

How to convert p12 files to pem files for Push Notification

Example: Development certificate
1. Download the certificate from iOS Provisioning Portal. Double click to install it.
2. Once installed, it should get listed in Certificates of Keychain Access.
3. Locate "Apple Development IOS Push Services:" and right click on it, select "Export xxx" and name it  dev-cert.p12 (leave the password blank for exporting)
4. Expand "Apple Development IOS Push Services:" to find the private key. Right click on it, select "Export xxx" and name it dev-key.p12 (leave the password blank for exporting)
5. Convert certificate to pem file format
   openssl pkcs12 -clcerts -nokeys -out dev-cert.pem -in dev-cert.p12
6. Convert private key to pem file format (password cannot be left blank, so key in 1234 and we will remove it in next step)
   openssl pkcs12 -nocerts -out dev-key-password.pem -in dev-key.p12
7.  To remove the password of dev-key-password.pem, run following command. (password will be asked, enter 1234 as we set in step 6)
  openssl rsa -in dev-key-password.pem -out dev-key.pem
8. Now we have both the certificate and private key (no password) converted in pem format.
9. That's it!

Monday, August 22, 2011

My favorite XCode 3 keyboard shortcuts

Keyboard:
. Shift + Option + Command + Left/Rigth arrow key: Move to Previous/Next file
. Command Left/Right arrow key: Go to beginning/end of the line
. Command + [ or ] : Indent selection leftward/rightward
. Command + R : Build and Run (Breakpoints off)
. Command + Y : Build and Debug (Breakpoints on)
. Option + Command + R : Run (Breakpoints off)

. Option + Command + Y : Debug (Breakpoints on)
. Shift + Command + E : Zoom editor out
. Shift + Command + W : Close file


Touchpad:
. 3 fingers swipe up : Switch between .m and .h files
. 3 fingers swipe Left/Right : Go Back/Forward

Thursday, June 9, 2011

ldr 12-bit displacement out of range

Somehow I get this error message while compiling my iPhone app.
The way to fix it is...
Go to Project info -> Build tab-> GCC 4.2 - Code Generation section, uncheck "Compile for Thumb".
That's 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