Skip to main content
Version: 4.55.1

Crop Texture

Depending on the data used to train a model you might need to feed a specific region of the input texture to your model.

For example, you might want to only pass in a texture which is a center cut of a screen, an area around the human’s face, or a rectangle around the hand.

Crop Textures

There are two types of crop textures that you can use: Screen Crop and Face Crop.

Screen Crop Texture

Allows you to get a crop a rectangle from the input texture.
You can create Screen Crop Texture via clicking “+” Button on the Resources panel and selecting Screen Crop Texture.

Click on the newly created texture on Resources panel to see it’s properties:

  • Input Texture: The original texture to crop from. By default it is initialized with Device Camera Texture.

The region to crop is represented by :

  • Cropping Left, Right, Top, Bottom: Anchors of a crop rectangle in the input Texture local space. (Where rect with anchors (-1, 1, -1, 1 ) means that whole input texture is taken)
  • Rotation: The rotation of a crop rectangle

You can modify these parameters via script, see RectCropTextureProvider in API documentation.

Face Crop Texture

Allows you to get a crop of a texture around the face.

You can create FaceCropTexture via clicking “+” Button on the Resources panel and selecting Face Crop Texture

Click on the newly created texture on Resources panel to see it’s properties:

  • Input Texture: the original texture to crop from. By default initialized with Device Camera Texture.
  • Scale: the UV Scale of the face texture. You can decrease these values to zoom in on the face and increase these values to zoom out.
  • Face Index: Which face should this FaceCropTexture use for a crop. The first face in the scene is 0; the second face in the scene is 1.
  • Face Center Mouth Weight: If equal to 0 - mouth is placed to default position, if equals 1 - mouth will be in the center of the cropped texture.

For more information see FaceCropProvider in the Lens Studio API documentation.

Rectangle setter

Rectangle setter is a component that can control a ScreenTransform Component of the object based on the crop rectangle of a Crop Texture.

To create a Rectangle Setter Component select Screen Image on the Object panel and in the Inspector panel, click Add Component -> Rectangle Setter. Then set CropTexture property to the CropTexture you want to take crop from

Was this page helpful?
Yes
No