Accessing the ‘glasses’ asset catalog#

You can access the catalog of glasses assets using the datagen.api.catalog.glasses class. It contains two important functions:

!pip install datagen-tech -q

get()#

The datagen.api.catalog.glasses.get() function gets one or more glasses assets from the asset catalog. These assets come in the form of objects of the datagen.api.assets.Glasses class.

To get the full set of glasses assets:

from datagen.api import catalog

catalog.glasses.get()

<AssetInstancesList(9)>

To get a specific glasses asset using its id:

from datagen.api import catalog

catalog.glasses.get(id="3d81b060-ace3-48d5-b17d-6446335043af")

Glasses(

id=’3d81b060-ace3-48d5-b17d-6446335043af’,

frame_color=FrameColor.BLACK,

frame_metalness=0.0,

lens_color=LensColor.BLACK,

lens_reflectivity=0.0,

lens_transparency=0.0,

position=GlassesPosition.ON_NOSE,

attributes=GlassesAttributes(

supported_position=[AccessoryPosition.ON_NOSE],

gender=[Gender.MALE, Gender.FEMALE],

style=GlassesStyle.OVAL

)

)

To cap the number of returned glasses assets using the limit parameter:

from datagen.api import catalog

catalog.glasses.get(limit=4)

<AssetInstancesList(4)>

To get a single glasses asset using the limit parameter:

from datagen.api import catalog

catalog.glasses.get(limit=1)

Glasses(

id=’03e5ffc9-7670-46d9-a27f-c06a4c821b3a’,

frame_color=FrameColor.BLACK,

frame_metalness=0.0,

lens_color=LensColor.BLACK,

lens_reflectivity=0.0,

lens_transparency=0.0,

position=GlassesPosition.ON_NOSE,

attributes=GlassesAttributes(

supported_position=[AccessoryPosition.ON_NOSE],

gender=[Gender.MALE, Gender.FEMALE],

style=GlassesStyle.READING_FULL_FRAME

)

)

To filter the glasses assets using the attributes parameter (see below for the list of valid glasses attributes):

from datagen.api import catalog
from datagen.api.catalog import attributes

catalog.glasses.get(style=attributes.GlassesStyle.AVIATOR)

<AssetInstancesList(10)>

count()#

The datagen.api.catalog.glasses.count() function tells you how many glasses assets match your query. You can count how many glasses assets there are in total, or filter the catalog using glasses attributes.

To count the full set of glasses assets:

from datagen.api import catalog

catalog.glasses.count()

9

To count the number of glasses assets that match certain attributes (see below for the list of valid glasses attributes):

from datagen.api import catalog
from datagen.api.catalog import attributes

catalog.glasses.count(style=attributes.GlassesStyle.ROUND)

1

Glasses attributes#

The datagen.api.catalog.attributes.GlassesAttributes class defines which attributes can be used to filter the catalog of glasses assets:

class datagen.api.catalog.attributes.GlassesAttributes

Each glasses asset contains the following read-only attributes.

When you call the datagen.api.catalog.glasses.get() or datagen.api.catalog.glasses.count() functions, you can use this attribute to filter the catalog.

gender: List[Enum]

Matches the requested accessory(s) with a desired gender. Uses the Gender enum.

An accessory may match with either or both genders.

NOTE: Gender matches are recommendations only and are not mandatory.

style: Enum

The general shape and style of the pair of glasses. Uses the GlassesStyle enum.

supported_position: List[Enum]

The list of positions on the body where this accessory can be worn. Uses the AccessoryPosition enum.

Sample usage:

from datagen.api import catalog
from datagen.api.catalog import attributes

catalog.glasses.get(gender=attributes.Gender.MALE, style=attributes.GlassesStyle.AVIATOR, supported_position=attributes.AccessoryPosition.ON_NOSE)

<AssetInstancesList(1)>

Here is the complete list of valid values for these attributes:

class datagen.api.catalog.attributes.GlassesStyle

The list of valid glasses styles.

This enum is valid for use in the following attributes:

Values:

AVIATOR = 'aviator'
BROWLINE = 'browline'
CAT_EYE = 'cat_eye'
GEOMETRIC = 'geometric'
OVAL = 'oval'
OVERSIZED = 'oversized'
READING_FULL_FRAME = 'reading_full_frame'
READING_RIMLESS = 'reading_rimless'
ROUND = 'round'
class datagen.api.catalog.attributes.Gender

The list of available genders.

This enum is valid for use in the following attributes:

Values:

FEMALE = 'female'
MALE = 'male'
class datagen.api.catalog.attributes.AccessoryPosition

The list of available positions where an accessory can be worn.

This enum is valid for use in the following attributes:

Values:

ON_CHIN = 'chin'
ON_MOUTH = 'mouth'
ON_NOSE = 'nose'

Properties of glasses objects#

When you get a glasses object from the catalog, you can edit that object in certain ways. These are the editable properties of glasses objects:

id

string

The id property defines the specific pair of glasses that the actor should wear, chosen from Datagen’s asset library. This property defines the shape of the glasses - not its color, reflectivity, or other attributes.

../../_images/Glasses_Var_Aviator1.png

id="484f76b7-9ca0-476f-9c03-578b3ba0ecb6"#

../../_images/Glasses_Var_Cat_eye1.png

id="518467ba-b067-4aae-ad73-107acd0c3583"#

../../_images/Glasses_Var_Geometric1.png

id="aefa9fa1-01be-48fd-b6ac-00f4649efd5d"#

../../_images/Glasses_Var_Oval1.png

id="3d81b060-ace3-48d5-b17d-6446335043af"#

../../_images/Glasses_Var_Oversize1.png

id="a1a2faf7-b1c7-4d92-82a2-a6bccc074ffd"#

../../_images/Glasses_Var_Reading_Rimless1.png

id="bfbc06fe-f72e-44ed-8ed4-3f715d849aff"#

Tip

To download a CSV with a complete list of UUIDs that identify individual glasses shapes, click here

frame_color

Enum

The frame_color property defines the base color of the frame of the actor’s glasses. This color will be further affected by the value of the frame_metalness property property.

Valid values are as follows:

../../_images/Glasses_Color_Black1.png

frame_color=assets.FrameColor.BLACK#

../../_images/Glasses_Color_Blue1.png

frame_color=assets.FrameColor.BLUE#

../../_images/Glasses_Color_Gold1.png

frame_color=assets.FrameColor.GOLD#

../../_images/Glasses_Color_Gray1.png

frame_color=assets.FrameColor.GRAY#

../../_images/Glasses_Color_Green1.png

frame_color=assets.FrameColor.GREEN#

../../_images/Glasses_Color_Red1.png

frame_color=assets.FrameColor.RED#

../../_images/Glasses_Color_Silver1.png

frame_color=assets.FrameColor.SILVER#

../../_images/Glasses_Color_White1.png

frame_color=assets.FrameColor.WHITE#

This code takes a glasses asset from the catalog and changes the default frame color:

from datagen.api import catalog
from datagen.api import assets

glasses=catalog.glasses.get(limit=1)
glasses.frame_color=assets.FrameColor.GOLD

frame_metalness

64-bit float

The frame_metalness property defines the reflectivity of the frames of the actor’s glasses, which can grant the frames a more plastic or more metallic character. This property accepts floating-point values from 0 to 1.

../../_images/Frame_Metalness_01.png

frame_metalness=0#

../../_images/Frame_Metalness_0.251.png

frame_metalness=0.25#

../../_images/Frame_Metalness_0.51.png

frame_metalness=0.5#

../../_images/Frame_Metalness_0.751.png

frame_metalness=0.75#

../../_images/Frame_Metalness_11.png

frame_metalness=1#

This code takes a glasses asset from the catalog and changes the default frame metalness:

from datagen.api import catalog
from datagen.api import assets

glasses=catalog.glasses.get(limit=1)
glasses.frame_metalness=0.7

lens_color

Enum

The lens_color property determines the base color of the lenses of the actor’s glasses. This base color will be further affected by the values of the lens transparency and reflectivity properties.

Valid values are:

../../_images/lenses_black1.png

lens_color=assets.LensColor.BLACK#

../../_images/lenses_blue1.png

lens_color=assets.LensColor.BLUE#

../../_images/lenses_green1.png

lens_color=assets.LensColor.GREEN#

../../_images/lenses_red1.png

lens_color=assets.LensColor.RED#

../../_images/lenses_yellow1.png

lens_color=assets.LensColor.YELLOW#

This code takes a glasses asset from the catalog and changes the default lens color:

from datagen.api import catalog
from datagen.api import assets

glasses=catalog.glasses.get(limit=1)
glasses.lens_color=assets.LensColor.RED

lens_reflectivity and lens_transparency

64-bit floats

The lens_reflectivity and lens_transparency properties define how light behaves as it hits the glasses lens.

lens_reflectivity defines how much light is reflected off of the lens. The higher the reflectivity, the more you will see the actor’s surroundings in the glasses lens. lens_reflectivity accepts floating-point values from 0 to 1.

lens_transparency defines how much light is able to pass directly through the lens. The higher the transparency, the more you can see of the actor’s eyes. lens_transparency accepts floating-point values from 0 to 1.

This code takes a glasses asset from the catalog and changes the default lens reflectivity and transparency:

from datagen.api import catalog
from datagen.api import assets

glasses=catalog.glasses.get(limit=1)
glasses.lens_reflectivity=0.9
glasses.lens_transparency=0.6

position

Enum

The position property defines where the actor is wearing his or her glasses. Currently we support glasses being worn only in the default position, on the nose.

This code takes a glasses asset from the catalog and resets the default position:

from datagen.api import catalog
from datagen.api import assets

glasses=catalog.glasses.get(limit=1)
glasses.position=assets.GlassesPosition.ON_NOSE