diff --git a/stimBuffApis/livoxGen1/pcloudAmbienceStimulusBuffer.h b/stimBuffApis/livoxGen1/pcloudAmbienceStimulusBuffer.h index 5ab8ea8..ba21f94 100644 --- a/stimBuffApis/livoxGen1/pcloudAmbienceStimulusBuffer.h +++ b/stimBuffApis/livoxGen1/pcloudAmbienceStimulusBuffer.h @@ -40,36 +40,21 @@ public: callbacks, flags), nStencils(nStencils_) { - // Parse postrinInterestThreshold from qualeIfaceApiParams + // Parse postrinInterestPercentage (interpreted as percentage 0-100) const std::vector postrinInterestThresholdParamNames = { "postrin-interest-threshold", "postrin-interest" }; - /** EXPLANATION: - * The default postrin threshold is determined as follows: - * We want 90% of the scanned points to have intensity under the - * lowVal to consider the ambience criterion met. - * - * If nDgramsPerFrame_ (the number of datagrams per frame) is less - * than 10, we require that all frames (100%) be under the lowVal. - * This is because, for such small sample sizes, calculating 90% - * does not yield a meaningful integer; for example, 90% of 7 is - * 6.3, but we must count whole frames that meet the threshold. By - * using nDgramsPerFrame_ as the threshold in this case, we ensure - * logical, all-or-nothing evaluation at low sample counts while - * maintaining an approximate 90% requirement for larger frame - * sizes. - */ - uint32_t defaultPostrinThreshold = (nDgramsPerFrame_ < 10) - ? static_cast(nDgramsPerFrame_) - : static_cast(nDgramsPerFrame_ * 9 / 10); - - postrinInterestThreshold = static_cast( + postrinInterestPercentage = static_cast( device::DeviceAttachmentSpec::parseOptionalParamAsIntWithSynonyms( deviceAttachmentSpec->qualeIfaceApiParams, postrinInterestThresholdParamNames, - defaultPostrinThreshold)); + 90)); + + // Convert percentage to absolute frame count + postrinInterestThreshold = static_cast( + (nDgramsPerFrame_ * postrinInterestPercentage) / 100); // Parse ambienceIntensityLowVal from qualeIfaceApiParams const std::vector ambienceIntensityLowValParamNames = { "ambience-intensity-low-val" @@ -94,6 +79,7 @@ public: PcloudAmbienceStimulusBuffer& operator=(PcloudAmbienceStimulusBuffer&&) = default; public: + uint32_t postrinInterestPercentage; uint32_t postrinInterestThreshold; uint32_t ambienceIntensityLowVal; size_t nStencils;