introduced a common base interface for input converters
@@ -409,38 +409,48 @@ private:
//----------------------------------------------------------------------
-class InCopy {
+class IinputConverter {
+public:
+ virtual ~IinputConverter() {}
+ virtual void convert(const ImageData* source, void* target) = 0;
+};
+
+//----------------------------------------------------------------------
+
+class InCopy : public IinputConverter {
public:
InCopy(const BenchmarkSettings* s) {}
- void convert(const ImageData* source, void* target) const {
- std::copy(source->data(), source->data() + source->size(), reinterpret_cast<uint8_t*>(target));
+ void convert(const ImageData* source, void* target) {
+ uint8_t *uint8_target = static_cast<uint8_t *>(target);
+ std::copy(source->data(), source->data() + source->size(), uint8_target);
}
};
//----------------------------------------------------------------------
-class InNormalize {
+class InNormalize : public IinputConverter {
public:
InNormalize(const BenchmarkSettings* s):
_normalize_img(s->normalize_img), _subtract_mean(s->subtract_mean) {
}
- void convert(const ImageData* source, float* target) const {
+ void convert(const ImageData* source, void* target) {
// Copy image data to target
+ float *float_target = static_cast<float *>(target);
float sum = 0;
for (int i = 0; i < source->size(); i++) {
float px = source->data()[i];
if (_normalize_img)
px = (px / 255.0 - 0.5) * 2.0;
sum += px;
- target[i] = px;
+ float_target[i] = px;
}
// Subtract mean value if required
if (_subtract_mean) {
float mean = sum / static_cast<float>(source->size());
for (int i = 0; i < source->size(); i++)
- target[i] -= mean;
+ float_target[i] -= mean;
}
}
