2

I am currently writing an application where I am doing image processing (w/Core Image) on a 2D image that includes the face (and the saved instance of ARSCNFaceGeometry). I am having trouble and determined I am calculating the x,y point value to use in core image for the points that would corespond with those in ARFaceGeometry.verticies.

I am capturing the 2D image by calling ARSCNView.snapshot() and storing and doing processing on it as a CIImage.

I am currently using that texture coordinates to try to calculate the x,y position on the CIImage, but I havent had a ton of experience in using Core Image and couldnt figure out if this is the atribute I should be using.

Here is what I currently have to calculate the coordinates of a point in CIImage x,y space. I'm trying to produce the CIVector of the point. What am I doing wrong?

let imgAsCIImage = /* The CIImage of the ARSCNView Snapshot */
let faceDotPos = /* The index I am calculating point for */
let pointTexCoord = faceGeometry.textureCoordinates[faceDotPos]
let imageFrame = imgAsCIImage.extent
let xPoint = (CGFloat(pointTexCoord.x) * imageFrame.width)
let yPoint = (CGFloat(pointTexCoord.y) * imageFrame.height)

return CIVector(x: xPoint,y: yPoint)
John
  • 51
  • 7
  • Two things. First, I get what your "expected" result is, but you really haven't indicated what the "actual" result is. Maybe you could include that in your question? Second, since you say you haven't had a ton of experience with CI, are you taking into account that the Y-axis is flipped? (It's a common mistake of CI newbies.) Where the origin - CGPoint(0,0) - is in the upper left for UIKit, the origin - CIVector(0,0) is in the lower left for CoreImage. Any chance that's your issue? –  Nov 29 '18 at 18:50
  • I'm only using the CIVector in my image processing right now, so if I understand you correctly, it should be the correct points. Its hard to say exactly what is wrong with the points, but I am using a CIPerspectiveTransform to project sections of the image onto small like 50x50 sections of another, but most are currently taking up the entire image. – John Nov 30 '18 at 01:51
  • Did you ever figure this out? – user3015221 Dec 16 '20 at 23:20

0 Answers0