Core Image Tutorial: Getting Started

Discussion of the official tutorials published on raywenderlich.com. Please only discuss the official tutorials here - for general questions, use the General Discussion forum instead.

Core Image Tutorial: Getting Started

Postby rwenderlich » Wed Aug 13, 2014 9:00 am

This is the official thread to discuss the following blog post: Core Image Tutorial: Getting Started
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ray Wenderlich
Blog: http://www.raywenderlich.com
Twitter: http://twitter.com/rwenderlich
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
User avatar
rwenderlich
Site Admin
 
Posts: 2512
Joined: Thu Dec 23, 2010 4:14 pm
Has thanked: 36 times
Been thanked: 479 times

Postby reidnez » Wed Aug 13, 2014 10:01 pm

I believe I found a typo.

This line:
Code: Select all
let newImage = UIImage(CIImage:outputImage)


should read like this:
Code: Select all
let newImage = UIImage(CIImage: filter.outputImage)


Same thing in the next code block. Later on you define a constant called outputImage, but in the first two code examples it's not-yet defined and would not build. :)
User avatar
reidnez
Forum Subject Matter Expert
 
Posts: 991
Joined: Fri Oct 12, 2012 8:47 pm
Has thanked: 12 times
Been thanked: 264 times

Postby russellm » Sat Aug 16, 2014 9:18 am

Great tutorial, and just what I was looking for!

I have a project where I'm trying to draw small images within a larger output. It looks like I should be using drawImage, but I'm struggling with the CIcontext, and how to create it with contextWithEAGLContext - any pointers?

Russell
russellm
Baby Hacker
 
Posts: 7
Joined: Fri Jul 19, 2013 7:50 am
Has thanked: 0 time
Been thanked: 0 time

Postby peek » Fri Aug 22, 2014 11:31 am

Or maybe just before adding
Code: Select all
var outputImage = filter.outputIMage
peek
n00b
 
Posts: 3
Joined: Fri Aug 22, 2014 11:26 am
Has thanked: 0 time
Been thanked: 0 time

Postby macinsmith3 » Wed Sep 03, 2014 6:16 pm

Nice tutorial. I decided to modify the code to detect if it was running on the simulator so that savePhoto would work (though unsafely). I couldn't find how to detect this in Swift using the conditional statements, so I wrote an objective C class that provides a method to determine at runtime if the simulator is in use. That, of course, required me to bridge Objective C and Swift. It worked fine.

Here's the code I added to save photo

if CheckForSimulator().runningInSimulator() {
softwareContext = context
} else {
softwareContext = CIContext(options: [kCIContextUseSoftwareRenderer: true])
}

and here is the objective C class

CheckForSimulator.h
@interface CheckForSimulator : NSObject
-(bool) runningInSimulator;
@end
CheckForSimulator.m
#import "CheckForSimulator.h"
#import "TargetConditionals.h"

@implementation CheckForSimulator
-(bool) runningInSimulator {
#if (TARGET_IPHONE_SIMULATOR)
NSLog(@"running on simulator");
return YES;
#else
NSLog(@"NOT running on simulator");
return NO;
#endif
}
@end

It also requires adding to CoreImageFun-Bridging-Header.h
#import "CheckForSimulator.h"
macinsmith3
Baby Hacker
 
Posts: 7
Joined: Thu Sep 26, 2013 3:24 am
Has thanked: 0 time
Been thanked: 0 time

Postby macinsmith3 » Wed Sep 03, 2014 6:20 pm

Of course I had to change softwareContext using

var softwareContext: CIContext!
macinsmith3
Baby Hacker
 
Posts: 7
Joined: Thu Sep 26, 2013 3:24 am
Has thanked: 0 time
Been thanked: 0 time

Re: Beginning Core Image in Swift

Postby Couto » Mon Oct 06, 2014 3:39 pm

Hi,

I’ve seen your tutorial on working with the core Image in Swift. There you say that it is possible to extract the GPS locations from the imagens, but you do not present any example. Could you please give me some more information about how to get the gps position from a photo, using swift?

Thanks for this fantastic tutorial,

Isabel
Couto
n00b
 
Posts: 1
Joined: Mon Oct 06, 2014 3:23 pm
Has thanked: 0 time
Been thanked: 0 time

Postby mcarrara3 » Fri Oct 24, 2014 9:48 pm

Great tutorial! I have a question related to core image data: how can you track a feature in a video? I know you can track faces quite easily, but what if I want to track a different shape? Thanks in advance!
mcarrara3
n00b
 
Posts: 1
Joined: Fri Oct 24, 2014 9:46 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Beginning Core Image in Swift

Postby johno2110 » Fri Oct 31, 2014 10:53 pm

Hello,

I don't know if this is an issue i'm only facing though when I import my own photo from the photo library the slider seems very laggy. Though this isnt the case with the default image
johno2110
n00b
 
Posts: 1
Joined: Fri Oct 31, 2014 10:52 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Beginning Core Image in Swift

Postby nicklockwood » Thu Nov 20, 2014 5:24 pm

johno2110 wrote:I don't know if this is an issue i'm only facing though when I import my own photo from the photo library the slider seems very laggy. Though this isnt the case with the default image


Photos taken with a digital camera, such as the iPhone's rear-facing camera are typically very large (8 megapixels), which may explain why applying effects to them is laggy.

If the photo you are importing is significantly larger than the display, you may wish to downscale it to a reasonable size by drawing it into a smaller image context before applying CI effects.
User avatar
nicklockwood
Baby Hacker
 
Posts: 5
Joined: Wed Jul 23, 2014 9:55 pm
Has thanked: 0 time
Been thanked: 0 time

Next

Return to Official Tutorials

Who is online

Users browsing this forum: No registered users and 2 guests