diff --git a/cpp/OcvDnnDetection/OcvDnnDetection.cpp b/cpp/OcvDnnDetection/OcvDnnDetection.cpp index 2b621952..c43bba85 100644 --- a/cpp/OcvDnnDetection/OcvDnnDetection.cpp +++ b/cpp/OcvDnnDetection/OcvDnnDetection.cpp @@ -126,29 +126,29 @@ std::string getFeedForwardExcludeBehavior(const MPFJob &job, const Properties &f if (feed_forward_props_iter != feed_forward_props.end()) { const std::string &class_name = feed_forward_props_iter->second; - std::string feed_forward_whitelist_file = - DetectionComponentUtils::GetProperty(job.job_properties, "FEED_FORWARD_WHITELIST_FILE", ""); + std::string feed_forward_allow_list_file = + DetectionComponentUtils::GetProperty(job.job_properties, "FEED_FORWARD_ALLOW_LIST_FILE", ""); - if (!feed_forward_whitelist_file.empty()) { + if (!feed_forward_allow_list_file.empty()) { std::string expanded_file_path; - std::string error = Utils::expandFileName(feed_forward_whitelist_file, expanded_file_path); + std::string error = Utils::expandFileName(feed_forward_allow_list_file, expanded_file_path); if (!error.empty()) { throw MPFInvalidPropertyException( - "FEED_FORWARD_WHITELIST_FILE", - "The value, \"" + feed_forward_whitelist_file + "\", could not be expanded due to: " + error); + "FEED_FORWARD_ALLOW_LIST_FILE", + "The value, \"" + feed_forward_allow_list_file + "\", could not be expanded due to: " + error); } - std::ifstream whitelist_file(expanded_file_path); - if (!whitelist_file.good()) { + std::ifstream allow_list_file(expanded_file_path); + if (!allow_list_file.good()) { throw MPFDetectionException( MPF_COULD_NOT_OPEN_DATAFILE, - "Failed to load feed-forward class whitelist that was supposed to be located at \"" + "Failed to load feed-forward class allow list that was supposed to be located at \"" + expanded_file_path + "\"."); } std::string line; - while (std::getline(whitelist_file, line)) { + while (std::getline(allow_list_file, line)) { Utils::trim(line); if (boost::iequals(line, class_name)) { return ""; diff --git a/cpp/OcvDnnDetection/plugin-files/descriptor/descriptor.json b/cpp/OcvDnnDetection/plugin-files/descriptor/descriptor.json index 0b8f2529..4426f842 100644 --- a/cpp/OcvDnnDetection/plugin-files/descriptor/descriptor.json +++ b/cpp/OcvDnnDetection/plugin-files/descriptor/descriptor.json @@ -122,14 +122,14 @@ "defaultValue": "CLASSIFICATION" }, { - "name": "FEED_FORWARD_WHITELIST_FILE", + "name": "FEED_FORWARD_ALLOW_LIST_FILE", "description": "When FEED_FORWARD_TYPE is provided and not set to NONE, only feed-forward detections with class names contained in the specified file will be processed. If no file is specified, all of the detections will be processed.", "type": "STRING", "defaultValue": "" }, { "name": "FEED_FORWARD_EXCLUDE_BEHAVIOR", - "description": "When FEED_FORWARD_TYPE is provided and not set to NONE, and FEED_FORWARD_WHITELIST_FILE is provided, this value determines what to do with feed-forward detections with class names not contained in the FEED_FORWARD_WHITELIST_FILE. Acceptable values are PASS_THROUGH and DROP.", + "description": "When FEED_FORWARD_TYPE is provided and not set to NONE, and FEED_FORWARD_ALLOW_LIST_FILE is provided, this value determines what to do with feed-forward detections with class names not contained in the FEED_FORWARD_ALLOW_LIST_FILE. Acceptable values are PASS_THROUGH and DROP.", "type": "STRING", "defaultValue": "PASS_THROUGH" }, diff --git a/cpp/OcvDnnDetection/test/CMakeLists.txt b/cpp/OcvDnnDetection/test/CMakeLists.txt index ab236e4c..fb94f530 100644 --- a/cpp/OcvDnnDetection/test/CMakeLists.txt +++ b/cpp/OcvDnnDetection/test/CMakeLists.txt @@ -45,5 +45,5 @@ if (${GTEST_FOUND}) # Install test images, videos, and other files file(GLOB OCVDNN_TEST_FILES data/*) file(COPY ${OCVDNN_TEST_FILES} DESTINATION data) - file(COPY vehicle-whitelist.txt DESTINATION .) + file(COPY vehicle-allow-list.txt DESTINATION .) endif() diff --git a/cpp/OcvDnnDetection/test/test_ocv_dnn_detection.cpp b/cpp/OcvDnnDetection/test/test_ocv_dnn_detection.cpp index 03604bfb..79827b1f 100644 --- a/cpp/OcvDnnDetection/test/test_ocv_dnn_detection.cpp +++ b/cpp/OcvDnnDetection/test/test_ocv_dnn_detection.cpp @@ -238,7 +238,7 @@ TEST(OCVDNN, FeedForwardImageTest) { Properties props = getVehicleColorProperties(); props["CLASSIFICATION_TYPE"] = classification_type; props["FEED_FORWARD_TYPE"] = "FRAME"; - props["FEED_FORWARD_WHITELIST_FILE"] = "vehicle-whitelist.txt"; + props["FEED_FORWARD_ALLOW_LIST_FILE"] = "vehicle-allow-list.txt"; // Test feed-forward person pass-through @@ -311,7 +311,7 @@ TEST(OCVDNN, FeedForwardVideoTest) { Properties props = getVehicleColorProperties(); props["CLASSIFICATION_TYPE"] = classification_type; props["FEED_FORWARD_TYPE"] = "FRAME"; - props["FEED_FORWARD_WHITELIST_FILE"] = "vehicle-whitelist.txt"; + props["FEED_FORWARD_ALLOW_LIST_FILE"] = "vehicle-allow-list.txt"; // Test feed-forward vehicle processing diff --git a/cpp/OcvDnnDetection/test/vehicle-whitelist.txt b/cpp/OcvDnnDetection/test/vehicle-allow-list.txt similarity index 100% rename from cpp/OcvDnnDetection/test/vehicle-whitelist.txt rename to cpp/OcvDnnDetection/test/vehicle-allow-list.txt diff --git a/cpp/OcvYoloDetection/WhitelistFilter.cpp b/cpp/OcvYoloDetection/AllowListFilter.cpp similarity index 69% rename from cpp/OcvYoloDetection/WhitelistFilter.cpp rename to cpp/OcvYoloDetection/AllowListFilter.cpp index 72fad515..fa9a3b88 100644 --- a/cpp/OcvYoloDetection/WhitelistFilter.cpp +++ b/cpp/OcvYoloDetection/AllowListFilter.cpp @@ -24,7 +24,7 @@ * limitations under the License. * ******************************************************************************/ -#include "WhitelistFilter.h" +#include "AllowListFilter.h" #include @@ -37,65 +37,65 @@ using namespace MPF::COMPONENT; namespace { - std::unordered_set LoadWhitelist( - const std::string &whiteListPath, const std::vector &names) { + std::unordered_set LoadAllowlist( + const std::string &allowListPath, const std::vector &names) { std::string expandedFilePath; - std::string error = Utils::expandFileName(whiteListPath, expandedFilePath); + std::string error = Utils::expandFileName(allowListPath, expandedFilePath); if (!error.empty()) { throw MPFInvalidPropertyException( - "CLASS_WHITELIST_FILE", - "The value, \"" + whiteListPath + "\", could not be expanded due to: " + "CLASS_ALLOW_LIST_FILE", + "The value, \"" + allowListPath + "\", could not be expanded due to: " + error); } - std::ifstream whitelistFile(expandedFilePath); - if (!whitelistFile.good()) { + std::ifstream allowListFile(expandedFilePath); + if (!allowListFile.good()) { throw MPFDetectionException( MPF_COULD_NOT_OPEN_DATAFILE, - "Failed to load class whitelist that was supposed to be located at \"" + "Failed to load class allow list that was supposed to be located at \"" + expandedFilePath + "\"."); } - std::unordered_set tempWhitelist; + std::unordered_set tempAllowList; std::string line; - while (std::getline(whitelistFile, line)) { + while (std::getline(allowListFile, line)) { Utils::trim(line); if (!line.empty()) { - tempWhitelist.insert(std::move(line)); + tempAllowList.insert(std::move(line)); line = ""; } } - if (tempWhitelist.empty()) { + if (tempAllowList.empty()) { throw MPFDetectionException( MPF_COULD_NOT_READ_DATAFILE, - "The class whitelist file located at \"" + expandedFilePath + "\" was empty."); + "The class allow list file located at \"" + expandedFilePath + "\" was empty."); } - std::unordered_set whitelist; + std::unordered_set allowList; for (const std::string &name: names) { - if (tempWhitelist.count(name) > 0) { - whitelist.insert(name); + if (tempAllowList.count(name) > 0) { + allowList.insert(name); } } - if (whitelist.empty()) { + if (allowList.empty()) { throw MPFDetectionException( MPF_COULD_NOT_READ_DATAFILE, - "None of the class names specified in the whitelist file located at \"" + "None of the class names specified in the allow list file located at \"" + expandedFilePath + "\" were found in the names file."); } - return whitelist; + return allowList; } } -WhitelistFilter::WhitelistFilter(const std::string &whiteListPath, +AllowListFilter::AllowListFilter(const std::string &allowListPath, const std::vector &names) - : whitelist_(LoadWhitelist(whiteListPath, names)) { + : allowList_(LoadAllowlist(allowListPath, names)) { } -bool WhitelistFilter::operator()(const std::string &className) { - return whitelist_.count(className) > 0; +bool AllowListFilter::operator()(const std::string &className) const { + return allowList_.count(className) > 0; } diff --git a/cpp/OcvYoloDetection/WhitelistFilter.h b/cpp/OcvYoloDetection/AllowListFilter.h similarity index 86% rename from cpp/OcvYoloDetection/WhitelistFilter.h rename to cpp/OcvYoloDetection/AllowListFilter.h index da74010f..63aa2ad8 100644 --- a/cpp/OcvYoloDetection/WhitelistFilter.h +++ b/cpp/OcvYoloDetection/AllowListFilter.h @@ -24,23 +24,23 @@ * limitations under the License. * ******************************************************************************/ -#ifndef OPENMPF_COMPONENTS_WHITELISTFILTER_H -#define OPENMPF_COMPONENTS_WHITELISTFILTER_H +#ifndef OPENMPF_COMPONENTS_ALLOWLISTFILTER_H +#define OPENMPF_COMPONENTS_ALLOWLISTFILTER_H #include #include #include -class WhitelistFilter { +class AllowListFilter { public: - WhitelistFilter(const std::string &whiteListPath, const std::vector &names); + AllowListFilter(const std::string &allowListPath, const std::vector &names); - bool operator()(const std::string &className); + bool operator()(const std::string &className) const; private: - std::unordered_set whitelist_; + std::unordered_set allowList_; }; -#endif //OPENMPF_COMPONENTS_WHITELISTFILTER_H +#endif //OPENMPF_COMPONENTS_ALLOWLISTFILTER_H diff --git a/cpp/OcvYoloDetection/CMakeLists.txt b/cpp/OcvYoloDetection/CMakeLists.txt index dac74e4f..24c97047 100644 --- a/cpp/OcvYoloDetection/CMakeLists.txt +++ b/cpp/OcvYoloDetection/CMakeLists.txt @@ -77,7 +77,7 @@ set(COMMON_OCV_YOLO_DETECTION_SOURCE_FILES KFTracker.cpp KFTracker.h OcvYoloDetection.cpp OcvYoloDetection.h ocv_phasecorr.cpp ocv_phasecorr.h - WhitelistFilter.cpp WhitelistFilter.h + AllowListFilter.cpp AllowListFilter.h yolo_network/BaseYoloNetworkImpl.cpp yolo_network/BaseYoloNetworkImpl.h) set(LOCAL_OCV_YOLO_DETECTION_SOURCE_FILES diff --git a/cpp/OcvYoloDetection/Config.cpp b/cpp/OcvYoloDetection/Config.cpp index d282207c..c4807b2a 100644 --- a/cpp/OcvYoloDetection/Config.cpp +++ b/cpp/OcvYoloDetection/Config.cpp @@ -76,7 +76,7 @@ Config::Config(const Properties &jobProps) GetProperty(jobProps, "KF_QN", "[ 1000.0, 1000.0, 1000.0, 1000.0 ]"))) , fallback2CpuWhenGpuProblem(GetProperty(jobProps, "FALLBACK_TO_CPU_WHEN_GPU_PROBLEM", false)) , cudaDeviceId(GetProperty(jobProps, "CUDA_DEVICE_ID", -1)) - , classWhiteListPath(GetProperty(jobProps, "CLASS_WHITELIST_FILE", "")) + , classAllowListPath(GetProperty(jobProps, "CLASS_ALLOW_LIST_FILE", "")) , enableDebug(GetProperty(jobProps, "ENABLE_DEBUG", false)) , tritonEnabled(GetProperty(jobProps, "ENABLE_TRITON", false)) , tritonServer(GetProperty(jobProps, "TRITON_SERVER", "ocv-yolo-detection-server:8001")) @@ -116,7 +116,7 @@ std::ostream &operator<<(std::ostream &out, const Config &cfg) { << "\"mosseTrackerDisabled\":" << (cfg.mosseTrackerDisabled ? "1" : "0") << "," << "\"fallback2CpuWhenGpuProblem\":" << (cfg.fallback2CpuWhenGpuProblem ? "1" : "0") << "," << "\"cudaDeviceId\":" << cfg.cudaDeviceId << "," - << "\"classWhiteListPath\":" << cfg.classWhiteListPath << "," + << "\"classAllowListPath\":" << cfg.classAllowListPath << "," << "\"enabledDebug\":" << cfg.enableDebug << "," << "\"tritonServer\":" << cfg.tritonModelVersion << "," << "\"tritonModelName\":" << cfg.tritonModelName << "," diff --git a/cpp/OcvYoloDetection/Config.h b/cpp/OcvYoloDetection/Config.h index 5e110b49..d7268bf1 100644 --- a/cpp/OcvYoloDetection/Config.h +++ b/cpp/OcvYoloDetection/Config.h @@ -116,7 +116,7 @@ class Config { /// gpu device id to use for cuda int cudaDeviceId; - std::string classWhiteListPath; + std::string classAllowListPath; bool enableDebug; diff --git a/cpp/OcvYoloDetection/plugin-files/descriptor/descriptor.json b/cpp/OcvYoloDetection/plugin-files/descriptor/descriptor.json index e3798d57..489c3945 100644 --- a/cpp/OcvYoloDetection/plugin-files/descriptor/descriptor.json +++ b/cpp/OcvYoloDetection/plugin-files/descriptor/descriptor.json @@ -153,7 +153,7 @@ "defaultValue": "5" }, { - "name": "CLASS_WHITELIST_FILE", + "name": "CLASS_ALLOW_LIST_FILE", "description": "When provided, only class names contained in the specified file will be reported.", "type": "STRING", "defaultValue": "" @@ -269,8 +269,8 @@ "value": "416" }, { - "name": "CLASS_WHITELIST_FILE", - "value": "$MPF_HOME/plugins/OcvYoloDetection/models/vehicle-whitelist.txt" + "name": "CLASS_ALLOW_LIST_FILE", + "value": "$MPF_HOME/plugins/OcvYoloDetection/models/vehicle-allow-list.txt" } ] }, @@ -303,8 +303,8 @@ "value": "608" }, { - "name": "CLASS_WHITELIST_FILE", - "value": "$MPF_HOME/plugins/OcvYoloDetection/models/vehicle-whitelist.txt" + "name": "CLASS_ALLOW_LIST_FILE", + "value": "$MPF_HOME/plugins/OcvYoloDetection/models/vehicle-allow-list.txt" } ] }, @@ -341,8 +341,8 @@ "value": "608" }, { - "name": "CLASS_WHITELIST_FILE", - "value": "$MPF_HOME/plugins/OcvYoloDetection/models/vehicle-whitelist.txt" + "name": "CLASS_ALLOW_LIST_FILE", + "value": "$MPF_HOME/plugins/OcvYoloDetection/models/vehicle-allow-list.txt" }, { "name": "ENABLE_TRITON", diff --git a/cpp/OcvYoloDetection/plugin-files/models/vehicle-whitelist.txt b/cpp/OcvYoloDetection/plugin-files/models/vehicle-allow-list.txt similarity index 100% rename from cpp/OcvYoloDetection/plugin-files/models/vehicle-whitelist.txt rename to cpp/OcvYoloDetection/plugin-files/models/vehicle-allow-list.txt diff --git a/cpp/OcvYoloDetection/test/data/test-whitelist.txt b/cpp/OcvYoloDetection/test/data/test-allow-list.txt similarity index 100% rename from cpp/OcvYoloDetection/test/data/test-whitelist.txt rename to cpp/OcvYoloDetection/test/data/test-allow-list.txt diff --git a/cpp/OcvYoloDetection/test/test_ocv_local_yolo_detection.cpp b/cpp/OcvYoloDetection/test/test_ocv_local_yolo_detection.cpp index d53ddc4e..9c16b8ac 100644 --- a/cpp/OcvYoloDetection/test/test_ocv_local_yolo_detection.cpp +++ b/cpp/OcvYoloDetection/test/test_ocv_local_yolo_detection.cpp @@ -258,12 +258,12 @@ TEST_F(OcvLocalYoloDetectionTestFixture, TestInvalidModel) { } -TEST_F(OcvLocalYoloDetectionTestFixture, TestWhitelist) { +TEST_F(OcvLocalYoloDetectionTestFixture, TestAllowList) { Properties jobProps = getTinyYoloConfig(); auto component = initComponent(); { - jobProps["CLASS_WHITELIST_FILE"] = "data/test-whitelist.txt"; + jobProps["CLASS_ALLOW_LIST_FILE"] = "data/test-allow-list.txt"; MPFImageJob job("Test", "data/dog.jpg", jobProps, {}); std::vector results = component.GetDetections(job); @@ -274,8 +274,8 @@ TEST_F(OcvLocalYoloDetectionTestFixture, TestWhitelist) { { int end_frame = 2; setenv("TEST_ENV_VAR", "data", true); - setenv("TEST_ENV_VAR2", "whitelist", true); - jobProps["CLASS_WHITELIST_FILE"] = "$TEST_ENV_VAR/test-${TEST_ENV_VAR2}.txt"; + setenv("TEST_ENV_VAR2", "allow-list", true); + jobProps["CLASS_ALLOW_LIST_FILE"] = "$TEST_ENV_VAR/test-${TEST_ENV_VAR2}.txt"; MPFVideoJob job("Test", "data/lp-ferrari-texas-shortened.mp4", 0, end_frame, jobProps, {}); diff --git a/cpp/OcvYoloDetection/yolo_network/BaseYoloNetworkImpl.cpp b/cpp/OcvYoloDetection/yolo_network/BaseYoloNetworkImpl.cpp index 05b8612a..43d2bd10 100644 --- a/cpp/OcvYoloDetection/yolo_network/BaseYoloNetworkImpl.cpp +++ b/cpp/OcvYoloDetection/yolo_network/BaseYoloNetworkImpl.cpp @@ -35,7 +35,7 @@ #include "../Config.h" #include "../Frame.h" #include "YoloNetwork.h" -#include "../WhitelistFilter.h" +#include "../AllowListFilter.h" #include "BaseYoloNetworkImpl.h" @@ -215,11 +215,11 @@ namespace { std::function GetClassFilter( - const std::string &whiteListPath, const std::vector &names) { - if (whiteListPath.empty()) { + const std::string &allowListPath, const std::vector &names) { + if (allowListPath.empty()) { return [](const std::string &) { return true; }; } else { - return WhitelistFilter(whiteListPath, names); + return AllowListFilter(allowListPath, names); } } @@ -278,8 +278,8 @@ BaseYoloNetworkImpl::BaseYoloNetworkImpl(ModelSettings model_settings, const Con net_(config.tritonEnabled ? cv::dnn::Net() : LoadNetwork(modelSettings_, cudaDeviceId_, log_)), names_(LoadNames(net_, modelSettings_, config)), confusionMatrix_(LoadConfusionMatrix(modelSettings_.confusionMatrixFile, names_.size())), - classWhiteListPath_(config.classWhiteListPath), - classFilter_(GetClassFilter(classWhiteListPath_, names_)) {} + classAllowListPath_(config.classAllowListPath), + classFilter_(GetClassFilter(classAllowListPath_, names_)) {} BaseYoloNetworkImpl::~BaseYoloNetworkImpl() = default; @@ -297,7 +297,7 @@ bool BaseYoloNetworkImpl::IsCompatible(const ModelSettings &modelSettings, const && modelSettings_.namesFile == modelSettings.namesFile && modelSettings_.confusionMatrixFile == modelSettings.confusionMatrixFile && config.cudaDeviceId == cudaDeviceId_ - && config.classWhiteListPath == classWhiteListPath_; + && config.classAllowListPath == classAllowListPath_; } void BaseYoloNetworkImpl::Finish() {} diff --git a/cpp/OcvYoloDetection/yolo_network/BaseYoloNetworkImpl.h b/cpp/OcvYoloDetection/yolo_network/BaseYoloNetworkImpl.h index 157121bf..5c259117 100644 --- a/cpp/OcvYoloDetection/yolo_network/BaseYoloNetworkImpl.h +++ b/cpp/OcvYoloDetection/yolo_network/BaseYoloNetworkImpl.h @@ -72,7 +72,7 @@ class BaseYoloNetworkImpl { std::vector names_; cv::Mat1f confusionMatrix_; - std::string classWhiteListPath_; + std::string classAllowListPath_; std::function classFilter_; std::vector> GetDetectionsCvdnn( diff --git a/cpp/OcvYoloDetection/yolo_network/TritonYoloNetworkImpl.cpp b/cpp/OcvYoloDetection/yolo_network/TritonYoloNetworkImpl.cpp index 718d0d9a..8118db72 100644 --- a/cpp/OcvYoloDetection/yolo_network/TritonYoloNetworkImpl.cpp +++ b/cpp/OcvYoloDetection/yolo_network/TritonYoloNetworkImpl.cpp @@ -80,7 +80,7 @@ class YoloNetwork::YoloNetworkImpl : public BaseYoloNetworkImpl { // common settings with local yolo network && modelSettings_.namesFile == modelSettings.namesFile && modelSettings_.confusionMatrixFile == modelSettings.confusionMatrixFile - && config.classWhiteListPath == classWhiteListPath_; + && config.classAllowListPath == classAllowListPath_; } else { return !tritonInferencer_ && modelSettings_.ocvDnnNetworkConfigFile == modelSettings.ocvDnnNetworkConfigFile @@ -88,7 +88,7 @@ class YoloNetwork::YoloNetworkImpl : public BaseYoloNetworkImpl { && modelSettings_.namesFile == modelSettings.namesFile && modelSettings_.confusionMatrixFile == modelSettings.confusionMatrixFile && config.cudaDeviceId == cudaDeviceId_ - && config.classWhiteListPath == classWhiteListPath_; + && config.classAllowListPath == classAllowListPath_; } }