2026-01-26 18:56:53 +09:00

182 lines
6.8 KiB
C#

/*
* Copyright (c) 2025 LG Electronics Inc.
* SPDX-License-Identifier: LicenseRef-LGE-Proprietary
*/
using Aurora;
using System.IO;
namespace VisionCommon {
public class PatternConstants {
public const string DIR_NAME_CONFIG_RECIPE = @"_config_recipe";
public const string DIR_NAME_CONFIG_MODEL = @"_config_model";
public const string DIR_NAME_CONFIG_INGREDIENT = @"_config_ingredient";
public const string DIR_NAME_CONFIG_VISION = @"_config_vision";
public const string DIR_NAME_PATTERN = @"Pattern";
public const string FILE_NAME_PATTERN = "Pattern";
public const string FILE_NAME_PATTERN_INFO = @"PatternInfo.json";
public const int MAIN_PATTERN_INDEX = 0;
public const int FOV_PATTERN_COUNT = 10;
public const int CAM_PATTERN_COUNT = 20;
public const int SUB_PATTERN_COUNT = 5;
public static bool IsMainPattern(PatternIndex patternIndex) {
return patternIndex.PatternSubId == MAIN_PATTERN_INDEX;
}
public static bool IsSubPattern(PatternIndex patternIndex) {
return !IsMainPattern(patternIndex);
}
// recipe#1/Pattern/0/0/0/0
// _vision/Pattern/0/0
public static string GetPatternDirPath(PatternInfo patternInfo) {
var patternIndex = patternInfo.GetPatternIndex();
if (VisionSettingManager.VisionSetting.UseCamPattern) {
return Path.Combine(
GetPatternRootPath(patternInfo),
patternInfo.GetPatternDirectoryPath());
}
else {
return Path.Combine(
GetCurrentRecipePatternRootPath(),
patternInfo.GetPatternDirectoryPath());
}
}
// recipe#1/Pattern/0/0/0/0/0/PatternInfo.json
// _vision/Pattern/0/0/0/PatternInfo.json
public static string GetSubPatternInfoFilePath(PatternInfo patternInfo) {
return Path.Combine(
GetSubPatternDirPath(patternInfo),
FILE_NAME_PATTERN_INFO);
}
// recipe#1/Pattern/0/0/0/0/0
// _vision/Pattern/0/0/0
public static string GetSubPatternDirPath(PatternInfo patternInfo) {
return Path.Combine(
GetPatternRootPath(patternInfo),
patternInfo.GetSubPatternDirectoryPath());
}
public static string GetPatternRootPath(PatternInfo patternInfo) {
var patternIndex = patternInfo.GetPatternIndex();
if (VisionSettingManager.VisionSetting.UseCamPattern) {
return GetCamPatternRootPath();
}
else {
return GetCurrentRecipePatternRootPath();
}
}
public static string GetCurrentRecipePatternRootPath() {
return Path.Combine(
GetCurrentRecipeFilePath(),
DIR_NAME_PATTERN);
}
public static string GetCurrentRecipeFilePath() {
var visionSetting = VisionSettingManager.VisionSetting;
if (visionSetting.RecipeModelType == eRecipeModelType.AuroraModel) {
var modelName = VisionEnv.AuroraEnv.RecipeManager.ActivatedModelName();
return GetModelFilePath(modelName);
}
else if (visionSetting.RecipeModelType == eRecipeModelType.AuroraIngredient) {
return GetIngredientFilePath(VisionKeys.VisionRecipeKey);
}
return GetRecipeFilePath(GetCurrentRecipeName());
}
public static string GetRecipeFilePath(string recipeName) {
// ex) Aurora.exe.config.DataPath\_config_recipe\recipeName
return Path.Combine(
ApplicationExt.DataPath,
DIR_NAME_CONFIG_RECIPE,
recipeName);
}
public static string GetCurrentRecipeName() {
var activatedRecipe = VisionEnv.AuroraEnv.RecipeManager.ActivatedRecipe();
return activatedRecipe.Name;
}
public static string GetModelFilePath(string modelName) {
// ex) Aurora.exe.config.DataPath\_config_model\modelName
return Path.Combine(
ApplicationExt.DataPath,
DIR_NAME_CONFIG_MODEL,
modelName);
}
public static string GetIngredientFilePath(string ingredientName) {
// ex) Aurora.exe.config.DataPath\_config_ingredient\ingredientName
return Path.Combine(
ApplicationExt.DataPath,
DIR_NAME_CONFIG_INGREDIENT,
ingredientName);
}
// _vision/Pattern
public static string GetCamPatternRootPath() {
return Path.Combine(
VisionEnv.VisionRootDataPath,
DIR_NAME_PATTERN);
}
public static bool IsFixturePatternType(ePatternType patternType) {
if (patternType == ePatternType.ImageModelFinder ||
patternType == ePatternType.PatternMatching) {
return true;
}
return false;
}
public static bool IsMultiPatternType(ePatternType patternType) {
if (patternType == ePatternType.MultiLineFinder ||
patternType == ePatternType.MultiOcr) {
return true;
}
return false;
}
public static bool IsSubPatternSupport(ePatternType patternType) {
if (patternType == ePatternType.ImageModelFinder ||
patternType == ePatternType.ShapeModelFinder ||
patternType == ePatternType.PatternMatching ||
patternType == ePatternType.LineFinder ||
patternType == ePatternType.Ocr) {
return true;
}
return false;
}
public static bool IsForceOkSupport(ePatternType patternType) {
if (patternType == ePatternType.ImageModelFinder ||
patternType == ePatternType.ShapeModelFinder ||
patternType == ePatternType.PatternMatching ||
patternType == ePatternType.LineFinder ||
patternType == ePatternType.LineIntersection) {
return true;
}
return false;
}
public static bool IsPatternBlock(ePatternType patternType) {
if (patternType == ePatternType.LineIntersection ||
patternType == ePatternType.LineWidth) {
return true;
}
return false;
}
public static bool IsModelFinder(ePatternType patternType) {
if (patternType == ePatternType.ImageModelFinder ||
patternType == ePatternType.ShapeModelFinder) {
return true;
}
return false;
}
}
}