From the course: Machine Learning in Mobile Applications

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Client tie to Visual Recognition: Converting model

Client tie to Visual Recognition: Converting model - Xamarin Tutorial

From the course: Machine Learning in Mobile Applications

Start my 1-month free trial

Client tie to Visual Recognition: Converting model

- [Instructor] And now we need to fill our Buffer that we're going to send along to our model. So what we're going to do is create a new CIImage, and we'll call it coreImage and that's going to be equal to new CIImage and we'll initialize that with our scaledImage. And then we'll begin an ImageContext. And in the ImageContext we'll specify the size so it will be a new CoreGraphics size and we'll use that 299, 299 again. And then we'll say CIContext, context is equal to CIContext FromContext. And we're going to use UIGraphics, GetCurrentContext, and null. Scroll that up a little bit and then we'll say context Render and we're going to Render our coreImage and put it into the buffer. And then we can end our ImageContext. And now we can get our result. So, var result equals our classifier which is an instance of our model. GetPrediction and we'll pass in our buffer and out is an NSError called error. And finally we'll set a returnValue equal to the result ClassLabel. And that's it. Now…

Contents