Common method in Swift


1. Check for any field empty in NSDictionary class func checkforEmptyValueinDictioanty(dic:NSDictionary)-> Bool{ for (keyVal, dataVal) in dic {   if (dataVal.length()==0){                 println("\(keyVal): \(dataVal.length())")                 return false             }                 ... Continue Reading →

Advertisements

Use different font text in a Label in swift


let secondLabel=UILabel(frame: CGRectMake(0, 16, _screenWidth-2, 20))         secondLabel.textColor=UIColor.whiteColor()         secondLabel.textAlignment=NSTextAlignment.Center         secondLabel.font=UIFont(name: "Arial", size: 12)         bottomView.addSubview(secondLabel)                  let attrSting=NSMutableAttributedString(string: "I agree to the Terms of Service and Privacy Policy.")             ... Continue Reading →

Open Setting from your iOS application


Step 1.  Add a method in AppDelegate private func setSettings() {         let userDefaults = NSUserDefaults.standardUserDefaults()         let defaults = [ "AppTitle" : "SettingLinker" ]         userDefaults.registerDefaults(defaults)         userDefaults.synchronize()         println(userDefaults.dictionaryRepresentation())     } Step 2. Call this function from... Continue Reading →

Basic HTTP Authentication in iOS while calling webservice


- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {    if ([challenge previousFailureCount] == 0) {        NSLog(@"received authentication challenge");        NSURLCredential *newCredential = [NSURLCredentialcredentialWithUser:@"tylerhorne"                                                           ... Continue Reading →

Post Json data to server in iOS


-(void)webservice{ NSString *url= SERVER_URL; NSLog(@"url is %@",url);   NSMutableURLRequest *_request = [NSMutableURLRequestrequestWithURL:[NSURLURLWithString:url] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:30.0];   NSMutableDictionary *post=[[NSMutableDictionaryalloc] init]; [post setObject:_emailText.text forKey:@"username"]; [post setObject:_passText.text forKey:@"password"];   NSError *error; NSData *data=[NSJSONSerializationdataWithJSONObject: post options:kNilOptionserror:&error]; NSString *jsonString = [[NSStringalloc] initWithData:data encoding:NSUTF8StringEncoding]; NSString *post = [NSString stringWithFormat:@"json=%@", jsonString]; NSData*postData = [post dataUsingEncoding:NSASCIIStringEncodingallowLossyConversion:NO];   NSLog(@"string is %@",post); [_request setHTTPMethod:@"POST"]; [_request setValue:@"application/x-www-form-urlencoded"forHTTPHeaderField:@"content-type"];... Continue Reading →

Live Video Face Masking on iOS


A great post to live video processing

Chris Cavanagh's Blog

Face detection has been possible for some time on iOS thanks to libraries like OpenCV. The CIDetector class introduced in iOS 5 made it a standard feature. Since iOS 7 it can also detect smiles and eye blinks Smile

With iOS 6, AV Foundation gained AVCaptureMetadataOutput, allowing face detection to be included in the capture pipeline (in iOS 7 it also supports barcode scanning).

Here’s how you could use that to perform face masking on live video:

Blockhead

First thing to do is get the capture session set up:

 AVCaptureSession *captureSession = [AVCaptureSession new]; [captureSession beginConfiguration]; NSError *error; // Input device AVCaptureDevice *captureDevice = [self frontOrDefaultCamera]; AVCaptureDeviceInput *deviceInput = [AVCaptureDeviceInput deviceInputWithDevice:captureDevice error:&error]; if ( [captureSession canAddInput:deviceInput] ) { [captureSession addInput:deviceInput]; } if ( [captureSession canSetSessionPreset:AVCaptureSessionPresetHigh] ) { captureSession.sessionPreset = AVCaptureSessionPresetHigh; } // Video data output AVCaptureVideoDataOutput *videoDataOutput = [self createVideoDataOutput]; if ( [captureSession canAddOutput:videoDataOutput] ) { [captureSession addOutput:videoDataOutput]; AVCaptureConnection *connection…

View original post 511 more words

Create a free website or blog at WordPress.com.

Up ↑

%d bloggers like this: