基於樣本的識別,通過一些圖片作爲樣本訓練之後在識別相同物體,每張圖片是一種物體
1.獲取樣本圖片
p_do_apply_sample_identifier_wine_bottle分析獲取ImageFileNames圖片,通過正則表達式獲取圖片名稱
ObjectIDs:爲所有ImageFileNames下對應的圖片的名稱索引(相同名稱的索引相同,沒有去重)
TrainingObjectNames:訓練樣本物體的名稱集合(去掉重複圖片後的數據),該名稱會應用到set_sample_identifier_object_info算子中設置圖片樣本名稱
TrainingObjectIDs:爲訓練樣本的名稱索引集合(去重後存儲的圖片名稱的索引)
TrainingImageFileNames:訓練樣本的文件路徑集合(去掉相同名稱後的路徑)
2.創建樣本、添加樣本、設置樣本名稱、刪除準備數據、訓練樣本
根據獲取到的參數TrainingImageFileNames、TrainingObjectIDs、TrainingObjectNames進行樣本處理
3.樣本識別
RandomIndices:生成所有圖片Num長度的隨機數組,根據該隨機數組選擇需要識別的圖片
1.create_sample_identifier( : : GenParamName, GenParamValue : SampleIdentifier):創建一個新的示例標示符
參數:
GenParamName:參數名稱('add_color_info':設置標示符會否使用顏色信息,如果使用需要將該參數設置爲'true','image_resize_method':設置圖像內部調整到給定的大小或給定的因子,爲了使識別過程加快,如果值爲'none'則不會調整,'image_resize_value':比例因子,是根據'image_resize_method'參數的值決定該參數的含義,當'image_resize_method'的值爲'image_area'時'image_resize_value'的值定義以像素單位擴大或縮小圖像的區域)
GenParamValue :參數值
SampleIdentifier:示例標示符句柄
2.add_sample_identifier_preparation_data(SampleImage : : SampleIdentifier, ObjectIdx, GenParamName, GenParamValue : ObjectSampleIdx):添加數據到樣本中
參數:
SampleImage :樣本圖像
SampleIdentifier:示例樣本句柄
ObjectIdx:樣本圖像中可見對象的索引
GenParamName:通用參數名稱
GenParamValue :通用參數值
ObjectSampleIdx:樣本對象索引
3.set_sample_identifier_object_info( : : SampleIdentifier, ObjectIdx, InfoName, InfoValue : ):爲示例樣本定義名稱或說明
4.prepare_sample_identifier( : : SampleIdentifier, RemovePreparationData, GenParamName, GenParamValue : ):使樣本標示符的內部數據結果與要標示的對象相適應
參數:
SampleIdentifier:樣本標示對象句柄
RemovePreparationData:決定是否刪除準備數據
GenParamName:通用參數名稱
GenParamValue :通用參數值
5.train_sample_identifier( : : SampleIdentifier, GenParamName, GenParamValue : ):訓練樣本
參數:
SampleIdentifier:示例標示符句柄
GenParamName:通用參數名稱
GenParamValue :通用參數值
6.apply_sample_identifier(Image : : SampleIdentifier, NumResults, RatingThreshold, GenParamName, GenParamValue : ObjectIdx, Rating):使用標示符標示對象
參數:
Image :輸入圖像
SampleIdentifier:示例標示符對象句柄
NumResults:返回的假定值得個數
RatingThreshold:額定閾值(所以返回的結果的Rating必須在該值以上)
GenParamName:通用參數
GenParamValue :通用參數值
ObjectIdx:已標示的對象的索引(是根據add_sample_identifier_preparation_data添加的ObjectIdx返回的結果)
Rating:標定對象的額定值
7.get_sample_identifier_object_info( : : SampleIdentifier, ObjectIdx, InfoName : InfoValue):查找有關示例標示符的對象的信息
參數:
SampleIdentifier:示例標示符對象句柄
ObjectIdx:標識對象的索引(根據匹配到的樣本的標識對象索引)
InfoName :檢索標識對象的哪種信息(根據樣本添加時設置的樣本名稱或聲明)
InfoValue:查找到的信息