72 lines
2.9 KiB
C++
72 lines
2.9 KiB
C++
#pragma once
|
|
|
|
// Cloud Vision v1: image and file annotation (sync and async start),
|
|
// product search resources (product sets, products, reference images).
|
|
// Annotation is paid per image and feature.
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "google/cloudai/cloudai_service.h"
|
|
|
|
namespace molo::google::cloudai {
|
|
|
|
struct VisionImage {
|
|
std::string content_base64; // inline bytes, base64 (at most 10 MiB decoded)
|
|
std::string uri; // gs:// or https:// instead of content
|
|
};
|
|
|
|
struct VisionFeature {
|
|
std::string type; // Feature.type enum, e.g. LABEL_DETECTION
|
|
int max_results = 0; // 0: Google default; at most 100
|
|
};
|
|
|
|
struct FileAnnotation {
|
|
std::string gcs_uri; // gs:// PDF / TIFF / GIF
|
|
std::string content_base64; // alternative to gcs_uri
|
|
std::string mime_type; // application/pdf, image/tiff, image/gif
|
|
std::vector<int> pages; // at most 5, 1-based
|
|
};
|
|
|
|
class Vision : public CloudAiService {
|
|
public:
|
|
using CloudAiService::CloudAiService;
|
|
|
|
static bool valid_feature(const std::string& type);
|
|
|
|
clients::body::Json annotate_body(const std::vector<VisionImage>& images,
|
|
const std::vector<VisionFeature>& features) const;
|
|
// images:annotate (global endpoint). Returns the raw "responses" reply.
|
|
clients::body::Json annotate(const std::vector<VisionImage>& images,
|
|
const std::vector<VisionFeature>& features) const;
|
|
|
|
clients::body::Json annotate_file_body(const FileAnnotation& file,
|
|
const std::vector<VisionFeature>& features) const;
|
|
clients::body::Json annotate_file(const FileAnnotation& file,
|
|
const std::vector<VisionFeature>& features) const;
|
|
|
|
// Product search reads.
|
|
clients::body::Json list_product_sets() const;
|
|
clients::body::Json get_product_set(const std::string& id) const;
|
|
clients::body::Json list_products() const;
|
|
clients::body::Json get_product(const std::string& id) const;
|
|
clients::body::Json list_reference_images(const std::string& product_id) const;
|
|
|
|
// Product search writes: explicit, no defaults.
|
|
clients::body::Json create_product_set(const std::string& id, const std::string& display_name) const;
|
|
clients::body::Json delete_product_set(const std::string& id) const;
|
|
clients::body::Json create_product(const std::string& id, const std::string& display_name,
|
|
const std::string& category) const;
|
|
clients::body::Json delete_product(const std::string& id) const;
|
|
|
|
Operation get_operation(const std::string& name) const;
|
|
|
|
clients::body::Json call(Call c, const std::string& name, const clients::body::Json* body = nullptr,
|
|
const Query& query = {}) const;
|
|
|
|
std::string product_set_name(const std::string& id) const;
|
|
std::string product_name(const std::string& id) const;
|
|
};
|
|
|
|
} // namespace molo::google::cloudai
|