Merge branch 'genesys-host-side-calibration' into 'master'

genesys: Fix host side calibration

See merge request sane-project/backends!334
merge-requests/340/head
Povilas Kanapickas 2020-02-14 18:16:23 +00:00
commit d72e07c671
4 zmienionych plików z 17 dodań i 9 usunięć

Wyświetl plik

@ -666,16 +666,21 @@ bool ImagePipelineNodeExtract::get_next_row_data(std::uint8_t* out_data)
ImagePipelineNodeCalibrate::ImagePipelineNodeCalibrate(ImagePipelineNode& source, ImagePipelineNodeCalibrate::ImagePipelineNodeCalibrate(ImagePipelineNode& source,
const std::vector<std::uint16_t>& bottom, const std::vector<std::uint16_t>& bottom,
const std::vector<std::uint16_t>& top) : const std::vector<std::uint16_t>& top,
std::size_t x_start) :
source_{source} source_{source}
{ {
auto size = std::min(bottom.size(), top.size()); std::size_t size = 0;
if (bottom.size() >= x_start && top.size() >= x_start) {
size = std::min(bottom.size() - x_start, top.size() - x_start);
}
offset_.reserve(size); offset_.reserve(size);
multiplier_.reserve(size); multiplier_.reserve(size);
for (std::size_t i = 0; i < size; ++i) { for (std::size_t i = 0; i < size; ++i) {
offset_.push_back(bottom[i] / 65535.0f); offset_.push_back(bottom[i + x_start] / 65535.0f);
multiplier_.push_back(65535.0f / (top[i] - bottom[i])); multiplier_.push_back(65535.0f / (top[i + x_start] - bottom[i + x_start]));
} }
} }

Wyświetl plik

@ -476,7 +476,7 @@ class ImagePipelineNodeCalibrate : public ImagePipelineNode
public: public:
ImagePipelineNodeCalibrate(ImagePipelineNode& source, const std::vector<std::uint16_t>& bottom, ImagePipelineNodeCalibrate(ImagePipelineNode& source, const std::vector<std::uint16_t>& bottom,
const std::vector<std::uint16_t>& top); const std::vector<std::uint16_t>& top, std::size_t x_start);
std::size_t get_width() const override { return source_.get_width(); } std::size_t get_width() const override { return source_.get_width(); }
std::size_t get_height() const override { return source_.get_height(); } std::size_t get_height() const override { return source_.get_height(); }

Wyświetl plik

@ -1350,10 +1350,13 @@ void build_image_pipeline(Genesys_Device* dev, const ScanSession& session)
} }
if (has_flag(dev->model->flags, ModelFlag::CALIBRATION_HOST_SIDE) && if (has_flag(dev->model->flags, ModelFlag::CALIBRATION_HOST_SIDE) &&
!has_flag(dev->model->flags, ModelFlag::NO_CALIBRATION)) !has_flag(dev->model->flags, ModelFlag::NO_CALIBRATION) &&
!has_flag(session.params.flags, ScanFlag::DISABLE_SHADING))
{ {
dev->pipeline.push_node<ImagePipelineNodeCalibrate>(dev->dark_average_data, dev->pipeline.push_node<ImagePipelineNodeCalibrate>(dev->dark_average_data,
dev->white_average_data); dev->white_average_data,
dev->calib_session.params.startx *
dev->calib_session.params.channels);
if (DBG_LEVEL >= DBG_io2) { if (DBG_LEVEL >= DBG_io2) {
dev->pipeline.push_node<ImagePipelineNodeDebug>("gl_pipeline_" + dev->pipeline.push_node<ImagePipelineNodeDebug>("gl_pipeline_" +

Wyświetl plik

@ -445,7 +445,7 @@ void test_node_calibrate_8bit()
ImagePipelineStack stack; ImagePipelineStack stack;
stack.push_first_node<ImagePipelineNodeArraySource>(1, 1, PixelFormat::RGB888, stack.push_first_node<ImagePipelineNodeArraySource>(1, 1, PixelFormat::RGB888,
std::move(in_data)); std::move(in_data));
stack.push_node<ImagePipelineNodeCalibrate>(bottom, top); stack.push_node<ImagePipelineNodeCalibrate>(bottom, top, 0);
ASSERT_EQ(stack.get_output_width(), 1u); ASSERT_EQ(stack.get_output_width(), 1u);
ASSERT_EQ(stack.get_output_height(), 1u); ASSERT_EQ(stack.get_output_height(), 1u);
@ -481,7 +481,7 @@ void test_node_calibrate_16bit()
ImagePipelineStack stack; ImagePipelineStack stack;
stack.push_first_node<ImagePipelineNodeArraySource>(1, 1, PixelFormat::RGB161616, stack.push_first_node<ImagePipelineNodeArraySource>(1, 1, PixelFormat::RGB161616,
std::move(in_data)); std::move(in_data));
stack.push_node<ImagePipelineNodeCalibrate>(bottom, top); stack.push_node<ImagePipelineNodeCalibrate>(bottom, top, 0);
ASSERT_EQ(stack.get_output_width(), 1u); ASSERT_EQ(stack.get_output_width(), 1u);
ASSERT_EQ(stack.get_output_height(), 1u); ASSERT_EQ(stack.get_output_height(), 1u);