Updating face texture doesn't update preview
Hi,
I'm trying to update my face texture with multiple assets, one at a time. When I set faceTexProvider.inputTexture it puts the texture and the preview image instead of croping the face. In other words, the Face Texture only works once on the initial inputTexture. Updating the inputTexture more than once doesn't detect faces.
var delayedEvent1 = script.createEvent("DelayedCallbackEvent");
delayedEvent1.bind(function(eventData)
{
startUpdating()
});
startUpdating();
function startUpdating()
{
var faceTexProvider = script.faceTexture.control;
faceTexProvider.inputTexture=script.faces[0]
delayedEvent1.reset(10)
}
thanks
Hi Marco,
FaceTextureProvider is meant for cropping faces from the live camera feed at runtime. The cropped area will always be relative to faces found on the device camera texture, not the "inputTexture" being passed in.
Usually the reason to set inputTexture is to control which Render Target or Device Camera Texture is being used for rendering, to choose which effects should be rendered over the face. For example, you could use Device Camera Texture as input to render the face with no effects, or you could use your main Render Target as input to render the face with whatever effects have already been applied to it that frame.
So unfortunately, there's no way to detect a face on an arbitrary input texture, except maybe by using MLComponent and training a model to do this. Or, if you are using the image picker specifically, you can use a Face Image Picker texture.
I'm not sure what your use case is, but maybe you could crop the faces out ahead of time, if they aren't dynamic? If you want, I can try pointing you in the right direction if you give a little more context
Thanks,
Jacob
Thanks but in my case the user will be uploading pictures that have a face on the camera roll and I need to extract the face and run through my snapML model. I don't want to add another face detection model since it's heavy and snap already has one builtin.
It sounds like you could use a Face Image Picker texture, then call copyFrame() on it every time a selection is made. Store these copies in your array and you can use them directly as textures. As long as "Crop to Face" is enabled on the Face Image Picker texture asset, they'll already be cropped to the user's face.
Then later you can just use the stored textures directly like:
Hope this works for you. Let me know if you need any more help!
Jacob