Skip to content

Metadata.h

Go to the source code of this file.

Example of Metadata data collection feature of SAIGE VISION Enterprise Operation.

SAIGE VISION Enterprise provides a data collection feature for AI model operation. The data collection feature is a function that stores new data that performs real-time inspection in the system. For data collection, it is not necessary to change the program for transmission separately from the inspection program, and the data is automatically collected according to the conditions specified in the system settings.

However, in the dataset function, you can operate with Metadata as additional information that each image has. In the Runtime SDK, you can set the Metadata value in advance when collecting data in a real-time inspection environment so that additional information of the collected data is also automatically stored.

The ExampleClsRuntimeWithMetadata.cpp example is an example of collecting data by specifying Metadata.

Types and Setting Methods of Metadata

Metadata has the following types.

Handle Metadata

Metadata specified in the inspection handle in advance. Once specified, it is applied uniformly to the images inspected with that handle. In the example below, the value of the "Manufacturing Line" item is set to "test" and is continuously applied to subsequent inspections.

See also: SaigeSetHandleMetadata

198
199
200
201
202
203
// ExampleClsRuntimeWithMetadata.cpp:200

retval = SaigeSetHandleMetadata(handle, "Manufacturing Line", "test");
if (retval < 0) {
    std::cerr << "SaigeSetHandleMetadata() failed - " << SaigeStrError(retval) << std::endl;
}

Inference Metadata

Metadata set immediately before each inspection. Since it is initialized each time it is inspected, if it is not specified each time, the value will be empty. Here, if there is a number 1 in the image path, the "Test" item is set to "test1".

See also: SaigeSetInferenceMetadata

230
231
232
233
234
// ExampleClsRuntimeWithMetadata.cpp:232

if (img.find("1") > 0) {
   retval = SaigeSetInferenceMetadata(result, "Test", "test1");
} 

Result Metadata

Metadata that can be set after interpreting each inspection result. It can be set after interpreting the inspection result before reusing or destroying the result handle. Here, the value of the Metadata item named "Result Class" is set to the classification result class value.

See also: SaigeSetResultMetadata

285
286
287
288
289
290
291
292
293
294
// ExampleClsRuntimeWithMetadata.cpp:287

retval = SaigeSetResultMetadata(result, "Result Class", modelInfo->classNames[classId]);
if (retval < 0) {
    std::cerr << "SaigeSetResultMetadata() failed - " << SaigeStrError(retval)
              << std::endl;
    SaigeDestroyInferenceHandle(handle);
    SaigeDestroyInferenceResult(result);
    return retval;
}

Predefined Metadata

There are items that are predefined by the system among the Metadata used in the dataset.

  • Product ID: Product identifier. It is specified as _product_id.
  • File Path: Image file path. It is used when collecting without transferring files and is specified as _file_path.
236
237
238
239
240
241
242
243
244
245
// ExampleClsRuntimeWithMetadata.cpp:238

std::string file_name = img.substr(img.find_last_of("/")+1);
std::string pid = file_name.substr(0, file_name.find_last_of("."));
SaigeSetInferenceMetadata(result, "_product_id",
                          file_name.substr(0, file_name.find(".")).c_str());
std::string file_path = "V:\\image\\runtime_example\\images\\test\\" + file_name;
if (file_name.find("01.png") != std::string::npos) {
   SaigeSetInferenceMetadata(result, "_file_path", file_path.c_str());
}