Skip to content

GCP.Vision reference

Source: src/GCP/Vision/Product.ts

A Cloud Vision Product Search product. Products hold reference images and can be added to one or more product sets.

Products have no labels field (productLabels are search filters), so ownership rests on the deterministic product id: a product found without prior state is reported as unowned and only taken over with --adopt. Location, product id, and productCategory are identity — changing any of them replaces the product. Display name, description, and labels update in place.

Generated id

const product = yield* GCP.Vision.Product("Shoe", {
displayName: "Trail runner",
productCategory: "apparel-v2",
});

Explicit id and labels

const product = yield* GCP.Vision.Product("Shoe", {
location: "us-west1",
productId: "trail-runner",
displayName: "Trail runner",
productCategory: "apparel-v2",
productLabels: [{ key: "color", value: "blue" }],
});
// Same logical id as before; only the changed props differ.
const product = yield* GCP.Vision.Product("Shoe", {
location: "us-west1",
productId: "trail-runner",
displayName: "Trail runner v2",
productCategory: "apparel-v2",
productLabels: [{ key: "color", value: "green" }],
});

Source: src/GCP/Vision/ProductSet.ts

A Cloud Vision Product Search product set.

Product sets have no labels field, so ownership rests on the deterministic product set id: a set found without prior state is reported as unowned and only taken over with --adopt. Location and product set id are identity — changing either replaces the set. Display name and product membership update in place.

Generated id

const set = yield* GCP.Vision.ProductSet("Catalog", {
displayName: "Summer",
});

Explicit id and location

const set = yield* GCP.Vision.ProductSet("Catalog", {
location: "us-west1",
productSetId: "summer-catalog",
displayName: "Summer",
});
// Same logical id as before; only the changed props differ.
const set = yield* GCP.Vision.ProductSet("Catalog", {
location: "us-west1",
productSetId: "summer-catalog",
displayName: "Fall",
products: [shoe.name],
});

Source: src/GCP/Vision/ProductsReferenceImage.ts

A Cloud Vision Product Search reference image attached to a product.

Reference images have no labels or description, so ownership rests on the deterministic image id: an image found without prior state is reported as unowned and only taken over with --adopt. Parent, image id, URI, and bounding polygons are identity — there is no update API, so changing any of them replaces the image.

ProductsReferenceImage: Creating a Reference Image

Section titled “ProductsReferenceImage: Creating a Reference Image”

Image on a product

const product = yield* GCP.Vision.Product("Shoe", {
displayName: "Trail runner",
productCategory: "apparel-v2",
});
const image = yield* GCP.Vision.ProductsReferenceImage("Hero", {
parent: product.name,
uri: "gs://my-bucket/shoe.png",
});

Explicit id and bounding box

const image = yield* GCP.Vision.ProductsReferenceImage("Hero", {
parent: product.name,
referenceImageId: "hero-front",
uri: "gs://my-bucket/shoe.png",
boundingPolys: [
{
vertices: [
{ x: 0, y: 0 },
{ x: 320, y: 0 },
{ x: 320, y: 320 },
{ x: 0, y: 320 },
],
},
],
});