git 版本回復


git clone [remote_address_here] my_repo
cd my_repo
git reset --hard [ENTER HERE THE COMMIT HASH YOU WANT]

經典遊戲登陸ios平台

講到大家小時候玩過的經典遊戲,大家馬上想到的是哪些遊戲?是仙劍、太空戰士、光明與黑暗、還是勇者鬥惡龍呢。隨著智慧型手機還有平板越來越流行,這半年來吹起一股昔日戰神拔劍再戰的風潮,越來越多遊戲移植到ios平台上,考慮到手機平板的效能,移植的還是以2D遊戲為主。究竟現在有哪些遊戲已經出現在ios平台上了呢,讓我們看下去!

ios5 的face detection方法

來源:
http://maniacdev.com/2011/11/tutorial-easy-face-detection-with-core-image-in-ios-5/


要看CIFaceFeature Class Reference
目前只能偵測臉
細部的話可以偵測到左右眼還有嘴吧的位置

跟openCV比起來,ios5內建的方法沒有算到額頭的位置 ....囧
要動態改變height,來猜整個臉的高度
但我想這只是時間的問題,之後一定會改進的

詳細code如下
有用到CoreImage 和QuartzCore


-(void)markFaces:(UIImageView *)facePicture
{
    // draw a CI image with the previously loaded face detection picture
    CIImage* image = [CIImage imageWithCGImage:facePicture.image.CGImage];
    
    // create a face detector - since speed is not an issue we'll use a high accuracy
    // detector
    CIDetector* detector = [CIDetector detectorOfType:CIDetectorTypeFace 
                                              context:nil options:[NSDictionary dictionaryWithObject:CIDetectorAccuracyHigh forKey:CIDetectorAccuracy]];
    
    // create an array containing all the detected faces from the detector    
    NSArray* features = [detector featuresInImage:image];
    
    // we'll iterate through every detected face.  CIFaceFeature provides us
    // with the width for the entire face, and the coordinates of each eye
    // and the mouth if detected.  Also provided are BOOL's for the eye's and
    // mouth so we can check if they already exist.
    for(CIFaceFeature* faceFeature in features)
    {
        // get the width of the face
        CGFloat faceWidth = faceFeature.bounds.size.width;
        CGFloat faceHeight = faceFeature.bounds.size.height;
        
        // create a UIView using the bounds of the face
        UIView* faceView = [[UIView alloc] initWithFrame:faceFeature.bounds];
        
        // add a border around the newly created UIView
        
        faceView.layer.borderWidth = 1;
        faceView.layer.borderColor = [[UIColor redColor] CGColor];
        
        // add the new view to create a box around the face
        [self.window addSubview:faceView];
        
        if(faceFeature.hasLeftEyePosition)
        {
            // create a UIView with a size based on the width of the face
            UIView* leftEyeView = [[UIView alloc] initWithFrame:CGRectMake(faceFeature.leftEyePosition.x-faceWidth*0.15, faceFeature.leftEyePosition.y-faceWidth*0.15, faceWidth*0.3, faceWidth*0.3)];
            // change the background color of the eye view
            [leftEyeView setBackgroundColor:[[UIColor blueColor] colorWithAlphaComponent:0.3]];
            // set the position of the leftEyeView based on the face
            [leftEyeView setCenter:faceFeature.leftEyePosition];
            // round the corners
            leftEyeView.layer.cornerRadius = faceWidth*0.15;
            // add the view to the window
            [self.window addSubview:leftEyeView];
        }
        
        if(faceFeature.hasRightEyePosition)
        {
            // create a UIView with a size based on the width of the face
            UIView* leftEye = [[UIView alloc] initWithFrame:CGRectMake(faceFeature.rightEyePosition.x-faceWidth*0.15, faceFeature.rightEyePosition.y-faceWidth*0.15, faceWidth*0.3, faceWidth*0.3)];
            // change the background color of the eye view
            [leftEye setBackgroundColor:[[UIColor blueColor] colorWithAlphaComponent:0.3]];
            // set the position of the rightEyeView based on the face
            [leftEye setCenter:faceFeature.rightEyePosition];
            // round the corners
            leftEye.layer.cornerRadius = faceWidth*0.15;
            // add the new view to the window
            [self.window addSubview:leftEye];
        }
        
        if(faceFeature.hasMouthPosition)
        {
            // create a UIView with a size based on the width of the face
            UIView* mouth = [[UIView alloc] initWithFrame:CGRectMake(faceFeature.mouthPosition.x-faceWidth*0.2, faceFeature.mouthPosition.y-faceWidth*0.2, faceWidth*0.4, faceWidth*0.4)];
            // change the background color for the mouth to green
            [mouth setBackgroundColor:[[UIColor greenColor] colorWithAlphaComponent:0.3]];
            // set the position of the mouthView based on the face
            [mouth setCenter:faceFeature.mouthPosition];
            // round the corners
            mouth.layer.cornerRadius = faceWidth*0.2;
            // add the new view to the window
            [self.window addSubview:mouth];
        }
        
    }
}

雜雜

想把部落格換到Octopress + GitHub,因為 Octopress 貼code比較漂亮,比較像是在xcode裡面的樣子,這種想法似乎有點幼稚。


我想,每個寫app的人寫到後來自己口袋裡面都繪有一些自己想做的app,要實現一種效果,可能會有3 5 種作法,只是其中的要花的時間跟performance不同罷了,所以也了解了甚麼叫作不可做、做不到、很難做  之間的差別。我的想做的app清單現在已經快長到10隻了。