I am trying to pass a reference of a cameras texture into xcode so that I can then use it for face detection. Most methods I have tried have left me stumped, but I think I am close with what I currently have.
In unity I get the texture id and pass this through a plugin:
[DllImport("__Internal")]
public static extern void SendBackground(int id, int width, int height);
//in Update
Texture bg_Img = GetComponentInChildren<VideoTextureBehaviour>().GetTexture(); //this is from Vuforia
int texture_Id = bg_Img.GetNativeTextureID();
SendBackground(texture_Id, bg_Img.width, bg_Img.height);
xcode receives the texture ID fine, I then try to access it from OpenGL and get it to a CIImage
- (void) DetectFaces:(int)tex_id :(int)width :(int)height
{
glGenTextures(1, (GLuint)&tex_id);
glBindTexture(GL_TEXTURE_2D, (GLuint)tex_id);
CIImage *image = [[CIImage alloc] initWithTexture:(GLuint)tex_id size:CGSizeMake(width, height) flipped:YES colorSpace: (CGColorSpaceRef) kCGColorSpaceModelRGB];
}
Currently that last line results in a bad access exception at run time. Any help is greatly appreciated.