13 #define SENSOR_GAUSS_NORMALIZATION_RANGE 2 21 class Sensor :
public std::enable_shared_from_this<Sensor> {
49 virtual std::vector<float>
getMValue(
int x,
int y)
const {
77 #define _USE_MINMAX_NORMALIZATION_ 78 #ifdef _USE_MINMAX_NORMALIZATION_ 80 if(range==0)
return 0.f;
84 if(range==0) range = 1;
86 return value > 1.f ? 1.f : value;
92 if(range==0) range = 1;
96 void setCWeights(
const std::vector<float>& weights);
109 {
return (
toupdate & (mask & updateMask)) != 0; }
125 bool isValid(
int x,
int y)
const;
135 virtual std::ostream&
print(std::ostream &os)
const;
141 virtual float calcValue(
int x,
int y)
const = 0;
161 template <
typename Derived>
164 return std::static_pointer_cast<Derived>(shared_from_this());
185 std::set<sensor_ptr> superSensors;
188 template<
typename SensorType,
typename FirstArgType,
typename... Args>
191 std::shared_ptr<SensorType> s = std::make_shared<SensorType>(args...);
192 s->changeSource(source);
196 template<
typename SensorType>
199 return std::make_shared<SensorType>();
218 std::ostream&
print(std::ostream &os)
const 233 virtual float getValue(
int x,
int y)
const;
247 virtual void calcAllValues();
248 virtual void calcAllGradients();
253 bool performFullUpdate();
269 int index = (int)values.getBoundedIndex(x,y);
270 if(index==-1)
return 0;
272 if(std::isnan((v = values[index]))) {
275 const_cast<PPSensor*
>(
this)->performFullUpdate();
276 return values[index];
278 return (const_cast<PPSensor*>(
this)->values[index] =
calcValue(x,y));
287 int index = gradients.getBoundedIndex(x,y);
288 if(index<0)
return Point();
289 if(std::isnan(gradients[index].x)) {
296 return (const_cast<PPSensor*>(
this)->gradients[index]
298 }
else return gradients[index];
bool assignRef(sensor_cptr rhs)
bool isModified(dword mask=UPD_ALL) const
virtual std::ostream & hprint(std::ostream &os, SensorCollection *sc) const
void disableUpdate(dword udMask)
float minval
overall minimum and maximum
Image< float > values
caching sheet for sensed values
virtual void changeSource(sensor_cptr _source)
void replaceBy(sensor_ptr target)
std::ostream & print(std::ostream &os) const
void changeSource(sensor_cptr source)
virtual int getDim3Size() const
virtual Point2D getGradient(int x, int y) const
get gradient at discrete position
virtual Point getGradient(int x, int y) const
void setID(const std::string &id)
virtual float calcValue(int x, int y) const =0
bool isValid(int x, int y) const
virtual int getNChannels() const
std::vector< float > cweights
multi-channel weights ('color')
float getMinMaxRange() const
virtual Point calcGradient(int x, int y) const
std::shared_ptr< Sensor > sensor_ptr
virtual bool performUpdate()
virtual float getValue(int x, int y) const
virtual std::vector< float > getMValue(int x, int y) const
get multi-channel value
#define SENSOR_GAUSS_NORMALIZATION_RANGE
const std::vector< float > & getCWeights() const
float getWeightedValue(int x, int y) const
std::shared_ptr< Derived > shared_from_base()
void setScale(float _scale)
Point dir
direction parameter
virtual int getSkip() const
float getWeightedValue(int x, int y) const
get max normalized value at discrete position range [0,1]
void unrefSuperSensor(sensor_ptr super)
bool isUpdate(dword udMask) const
Point2D getGradient(const Point2D &p) const
get gradient at position p using nearest neighbor interpolation
virtual int getDim1Size() const
void enableUpdate(dword udMask)
float calcValue(int x, int y) const
Computes a zero.
virtual void calcMinMax()
dword toupdate
bitflag for updates
std::shared_ptr< SensorType > makeSensor(FirstArgType source, Args...args)
Point2D getWeightedGradient(int x, int y) const
sensor_ptr getZeroSensor()
Image< Point > gradients
caching sheet for gradients
void refSuperSensor(sensor_ptr super)
virtual float getValue(int x, int y) const
get value at discrete position
const Point & getDirection() const
Point2D getWeightedGradient(int x, int y) const
get range weighted gradient at discrete position
virtual std::vector< float > calcMValue(int x, int y) const
std::shared_ptr< const Sensor > sensor_cptr
void togglePP(enum PPState state=PP_DO)
static dword getStringNumber(const char *sid)
void setCWeights(const std::vector< float > &weights)
const std::string & getID() const
dword updateMask
bitflag to mask unimportant updates
Point calcGradient(int x, int y) const
virtual Sensor & assign(const Sensor &rhs)
void setDirection(const Point &dir)
dword doPP
do preprocessing?
float stdev
overall mean and stdev
float getValue(const Point &p) const
get value at position p using nearest neighbour interpolation
virtual Image< float > createSensorImage() const
virtual int getDim2Size() const
void setModified(dword mask=UPD_ALL)
void unsetModified(dword mask=UPD_ALL)
static void getNumberString(char sid[5], dword id)
virtual std::ostream & print(std::ostream &os) const