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

208
209
210
211
212
213
// ExampleClsRuntimeWithMetadata.cpp:210

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

240
241
242
243
244
// ExampleClsRuntimeWithMetadata.cpp:242

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

295
296
297
298
299
300
301
302
303
304
// ExampleClsRuntimeWithMetadata.cpp:297

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.
246
247
248
249
250
251
252
253
254
255
// ExampleClsRuntimeWithMetadata.cpp:248

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());
}