Files
salmanoff/stimBuffApis/livoxGen1/pcloudAmbienceStimulusBuffer.h
T
hayodea 280b6f7d1c OClCollMeshEngn: Produce ambience count; set postrin threshold
We modify the semantics/meaning of the ambience stim feature.
It now represents the number of frames whose average intensity
is below the ambienceLowVal.

We can now implement the postrin as the event wherein the number
of frames whose intensity <= ambienceLowVal exceeds
postrin-interest-threshold.
2025-11-28 02:55:24 -04:00

107 lines
3.6 KiB
C++

#ifndef _LIVOX_GEN1_PCLOUD_AMBIENCE_STIMULUS_BUFFER_H
#define _LIVOX_GEN1_PCLOUD_AMBIENCE_STIMULUS_BUFFER_H
#include <memory>
#include <cstdint>
#include <list>
#include <cstddef>
#include <vector>
#include <string>
#include <user/stimulusBuffer.h>
#include <user/stagingBuffer.h>
#include <user/deviceAttachmentSpec.h>
#include "lg1PcloudAmbienceStencil.h"
namespace smo {
namespace stim_buff {
// Forward declaration
class StimulusProducer;
/**
* PcloudAmbienceStimulusBuffer is a specialized StimulusBuffer for ambience point cloud data.
*/
class PcloudAmbienceStimulusBuffer
: public StimulusBuffer
{
public:
explicit PcloudAmbienceStimulusBuffer(
StimulusProducer& parent,
const std::shared_ptr<device::DeviceAttachmentSpec>& deviceAttachmentSpec,
int histbuffMs,
const StagingBuffer::IOEngineConstraints& inputEngineConstraints,
const StagingBuffer::IOEngineConstraints& outputEngineConstraints,
const SmoCallbacks& callbacks,
cl_mem_flags flags,
size_t nStencils_, size_t nDgramsPerFrame_)
: StimulusBuffer(
parent, deviceAttachmentSpec, histbuffMs,
inputEngineConstraints, outputEngineConstraints,
callbacks, flags),
nStencils(nStencils_)
{
// Parse postrinInterestThreshold from qualeIfaceApiParams
const std::vector<std::string> 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<uint32_t>(nDgramsPerFrame_)
: static_cast<uint32_t>(nDgramsPerFrame_ * 9 / 10);
postrinInterestThreshold = static_cast<uint32_t>(
device::DeviceAttachmentSpec::parseOptionalParamAsIntWithSynonyms(
deviceAttachmentSpec->qualeIfaceApiParams,
postrinInterestThresholdParamNames,
defaultPostrinThreshold));
// Parse ambienceIntensityLowVal from qualeIfaceApiParams
const std::vector<std::string> ambienceIntensityLowValParamNames = {
"ambience-intensity-low-val"
};
ambienceIntensityLowVal = static_cast<uint32_t>(
device::DeviceAttachmentSpec::parseOptionalParamAsIntWithSynonyms(
deviceAttachmentSpec->qualeIfaceApiParams,
ambienceIntensityLowValParamNames, 8));
// Construct stencils and add to list (FIFO behavior)
for (size_t i = 0; i < nStencils; ++i) {
stencils.emplace_back(nDgramsPerFrame_);
}
}
~PcloudAmbienceStimulusBuffer() = default;
// Non-copyable, movable
PcloudAmbienceStimulusBuffer(const PcloudAmbienceStimulusBuffer&) = delete;
PcloudAmbienceStimulusBuffer& operator=(const PcloudAmbienceStimulusBuffer&) = delete;
PcloudAmbienceStimulusBuffer(PcloudAmbienceStimulusBuffer&&) = default;
PcloudAmbienceStimulusBuffer& operator=(PcloudAmbienceStimulusBuffer&&) = default;
public:
uint32_t postrinInterestThreshold;
uint32_t ambienceIntensityLowVal;
size_t nStencils;
std::list<LG1PcloudAmbienceStencil> stencils;
};
} // namespace stim_buff
} // namespace smo
#endif // _LIVOX_GEN1_PCLOUD_AMBIENCE_STIMULUS_BUFFER_H