kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Simplify shading line calculation by defining distance in mm
rodzic
1a55cc99e4
commit
55000d82ac
|
@ -140,6 +140,9 @@ struct Genesys_Model
|
|||
// Start of white strip in mm
|
||||
float y_offset_calib_white = 0;
|
||||
|
||||
// The size of the scan area that is used to acquire shading data in mm
|
||||
float y_size_calib_mm = 0;
|
||||
|
||||
// Start of black mark in mm
|
||||
float x_offset_calib_black = 0;
|
||||
|
||||
|
@ -164,6 +167,9 @@ struct Genesys_Model
|
|||
// Start of black strip in transparency mode in mm
|
||||
float y_offset_calib_black_ta = 0;
|
||||
|
||||
// The size of the scan area that is used to acquire shading data in transparency mode in mm
|
||||
float y_size_calib_ta_mm = 0;
|
||||
|
||||
// Size of scan area after paper sensor stop sensing document in mm
|
||||
float post_scan = 0;
|
||||
|
||||
|
@ -199,10 +205,6 @@ struct Genesys_Model
|
|||
// Button flags, described existing buttons for the model
|
||||
SANE_Word buttons = 0;
|
||||
|
||||
// how many lines are used for shading calibration
|
||||
SANE_Int shading_lines = 0;
|
||||
// how many lines are used for shading calibration in TA mode
|
||||
SANE_Int shading_ta_lines = 0;
|
||||
// how many lines are used to search start position
|
||||
SANE_Int search_lines = 0;
|
||||
|
||||
|
|
|
@ -1176,28 +1176,23 @@ void CommandSetGl124::init_regs_for_shading(Genesys_Device* dev, const Genesys_S
|
|||
Genesys_Register_Set& regs) const
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
int move, resolution, dpihw, factor;
|
||||
|
||||
unsigned channels = 3;
|
||||
unsigned calib_lines = dev->model->shading_lines;
|
||||
dpihw = sensor.get_register_hwdpi(dev->settings.xres);
|
||||
if(dpihw>=2400)
|
||||
{
|
||||
calib_lines *= 2;
|
||||
}
|
||||
resolution=dpihw;
|
||||
unsigned dpihw = sensor.get_register_hwdpi(dev->settings.xres);
|
||||
unsigned resolution = dpihw;
|
||||
|
||||
unsigned ccd_size_divisor = sensor.get_ccd_size_divisor_for_dpi(dev->settings.xres);
|
||||
|
||||
resolution /= ccd_size_divisor;
|
||||
calib_lines /= ccd_size_divisor; // reducing just because we reduced the resolution
|
||||
unsigned calib_lines =
|
||||
static_cast<unsigned>(dev->model->y_size_calib_mm * resolution / MM_PER_INCH);
|
||||
|
||||
const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, channels,
|
||||
dev->settings.scan_method);
|
||||
factor = calib_sensor.optical_res / resolution;
|
||||
unsigned factor = calib_sensor.optical_res / resolution;
|
||||
|
||||
/* distance to move to reach white target at high resolution */
|
||||
move=0;
|
||||
unsigned move=0;
|
||||
if (dev->settings.yres >= 1200) {
|
||||
move = static_cast<int>(dev->model->y_offset_calib_white);
|
||||
move = static_cast<int>((move * (dev->motor.base_ydpi/4)) / MM_PER_INCH);
|
||||
|
|
|
@ -1695,8 +1695,11 @@ void CommandSetGl646::init_regs_for_shading(Genesys_Device* dev, const Genesys_S
|
|||
settings.tl_y = 0;
|
||||
settings.pixels = (calib_sensor.sensor_pixels * settings.xres) / calib_sensor.optical_res;
|
||||
settings.requested_pixels = settings.pixels;
|
||||
unsigned calib_lines = dev->model->shading_lines;
|
||||
|
||||
unsigned calib_lines =
|
||||
static_cast<unsigned>(dev->model->y_size_calib_mm * settings.yres / MM_PER_INCH);
|
||||
settings.lines = calib_lines;
|
||||
|
||||
settings.depth = 16;
|
||||
settings.color_filter = dev->settings.color_filter;
|
||||
|
||||
|
|
|
@ -2427,13 +2427,15 @@ void CommandSetGl841::init_regs_for_shading(Genesys_Device* dev, const Genesys_S
|
|||
const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, channels,
|
||||
dev->settings.scan_method);
|
||||
|
||||
unsigned calib_lines =
|
||||
static_cast<unsigned>(dev->model->y_size_calib_mm * ydpi / MM_PER_INCH);
|
||||
ScanSession session;
|
||||
session.params.xres = resolution;
|
||||
session.params.yres = ydpi;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = starty;
|
||||
session.params.pixels = calib_sensor.sensor_pixels / factor;
|
||||
session.params.lines = dev->model->shading_lines;
|
||||
session.params.lines = calib_lines;
|
||||
session.params.depth = 16;
|
||||
session.params.channels = channels;
|
||||
session.params.scan_method = dev->settings.scan_method;
|
||||
|
@ -3557,9 +3559,9 @@ void CommandSetGl841::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
|
|||
unsigned dpi = resolution_settings.get_min_resolution_x();
|
||||
channels = 1;
|
||||
|
||||
/* shading calibation is done with dev->motor.base_ydpi */
|
||||
/* lines = (dev->model->shading_lines * dpi) / dev->motor.base_ydpi; */
|
||||
lines = static_cast<unsigned>((10 * dpi) / MM_PER_INCH);
|
||||
// shading calibation is done with dev->motor.base_ydpi
|
||||
lines = 10; // TODO: use dev->model->search_lines
|
||||
lines = static_cast<unsigned>((lines * dpi) / MM_PER_INCH);
|
||||
|
||||
pixels = (sensor.sensor_pixels * dpi) / sensor.optical_res;
|
||||
|
||||
|
|
|
@ -1620,13 +1620,13 @@ void CommandSetGl843::init_regs_for_shading(Genesys_Device* dev, const Genesys_S
|
|||
DBG_HELPER(dbg);
|
||||
int move, resolution, dpihw, factor;
|
||||
|
||||
unsigned calib_lines = 0;
|
||||
float calib_size_mm = 0;
|
||||
if (dev->settings.scan_method == ScanMethod::TRANSPARENCY ||
|
||||
dev->settings.scan_method == ScanMethod::TRANSPARENCY_INFRARED)
|
||||
{
|
||||
calib_lines = dev->model->shading_ta_lines;
|
||||
calib_size_mm = dev->model->y_size_calib_ta_mm;
|
||||
} else {
|
||||
calib_lines = dev->model->shading_lines;
|
||||
calib_size_mm = dev->model->y_size_calib_mm;
|
||||
}
|
||||
|
||||
dpihw = sensor.get_logical_hwdpi(dev->settings.xres);
|
||||
|
@ -1672,6 +1672,7 @@ void CommandSetGl843::init_regs_for_shading(Genesys_Device* dev, const Genesys_S
|
|||
}
|
||||
|
||||
move = static_cast<int>((move * resolution) / MM_PER_INCH);
|
||||
unsigned calib_lines = static_cast<unsigned>(calib_size_mm * resolution / MM_PER_INCH);
|
||||
|
||||
ScanSession session;
|
||||
session.params.xres = resolution;
|
||||
|
@ -2536,7 +2537,7 @@ void CommandSetGl843::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
|
|||
bool forward, bool black) const
|
||||
{
|
||||
DBG_HELPER_ARGS(dbg, "%s %s", black ? "black" : "white", forward ? "forward" : "reverse");
|
||||
unsigned int pixels, lines, channels;
|
||||
unsigned int pixels, channels;
|
||||
Genesys_Register_Set local_reg;
|
||||
int dpi;
|
||||
unsigned int pass, count, found, x, y;
|
||||
|
@ -2554,7 +2555,7 @@ void CommandSetGl843::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
|
|||
/* 10 MM */
|
||||
/* lines = (10 * dpi) / MM_PER_INCH; */
|
||||
/* shading calibation is done with dev->motor.base_ydpi */
|
||||
lines = (dev->model->shading_lines * dpi) / dev->motor.base_ydpi;
|
||||
unsigned lines = static_cast<unsigned>(dev->model->y_size_calib_mm * dpi / MM_PER_INCH);
|
||||
pixels = (calib_sensor.sensor_pixels * dpi) / calib_sensor.optical_res;
|
||||
|
||||
dev->set_head_pos_zero(ScanHeadId::PRIMARY);
|
||||
|
|
|
@ -954,10 +954,9 @@ void CommandSetGl846::init_regs_for_shading(Genesys_Device* dev, const Genesys_S
|
|||
|
||||
const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, channels,
|
||||
dev->settings.scan_method);
|
||||
unsigned calib_lines = dev->model->shading_lines;
|
||||
if (resolution == 4800) {
|
||||
calib_lines *= 2;
|
||||
}
|
||||
|
||||
unsigned calib_lines =
|
||||
static_cast<unsigned>(dev->model->y_size_calib_mm * resolution / MM_PER_INCH);
|
||||
unsigned calib_pixels = (calib_sensor.sensor_pixels * resolution) /
|
||||
calib_sensor.optical_res;
|
||||
|
||||
|
@ -1489,7 +1488,7 @@ void CommandSetGl846::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
|
|||
bool black) const
|
||||
{
|
||||
DBG_HELPER_ARGS(dbg, "%s %s", black ? "black" : "white", forward ? "forward" : "reverse");
|
||||
unsigned int pixels, lines, channels;
|
||||
unsigned int pixels, channels;
|
||||
Genesys_Register_Set local_reg;
|
||||
unsigned int pass, count, found;
|
||||
char title[80];
|
||||
|
@ -1505,8 +1504,8 @@ void CommandSetGl846::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
|
|||
/* 10 MM */
|
||||
/* lines = (10 * dpi) / MM_PER_INCH; */
|
||||
/* shading calibation is done with dev->motor.base_ydpi */
|
||||
lines = (dev->model->shading_lines * dpi) / dev->motor.base_ydpi;
|
||||
pixels = (sensor.sensor_pixels * dpi) / sensor.optical_res;
|
||||
unsigned lines = static_cast<unsigned>(dev->model->y_size_calib_mm * dpi / MM_PER_INCH);
|
||||
pixels = (sensor.sensor_pixels * dpi) / sensor.optical_res;
|
||||
|
||||
dev->set_head_pos_zero(ScanHeadId::PRIMARY);
|
||||
|
||||
|
|
|
@ -961,16 +961,14 @@ void CommandSetGl847::init_regs_for_shading(Genesys_Device* dev, const Genesys_S
|
|||
const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, channels,
|
||||
dev->settings.scan_method);
|
||||
|
||||
unsigned calib_lines = dev->model->shading_lines;
|
||||
if (resolution == 4800) {
|
||||
calib_lines *= 2;
|
||||
}
|
||||
unsigned calib_lines =
|
||||
static_cast<unsigned>(dev->model->y_size_calib_mm * resolution / MM_PER_INCH);
|
||||
unsigned calib_pixels = (calib_sensor.sensor_pixels * resolution) /
|
||||
calib_sensor.optical_res;
|
||||
|
||||
ScanSession session;
|
||||
session.params.xres = resolution;
|
||||
session.params.yres = dev->motor.base_ydpi;
|
||||
session.params.yres = resolution;
|
||||
session.params.startx = 0;
|
||||
session.params.starty = 20;
|
||||
session.params.pixels = calib_pixels;
|
||||
|
@ -1526,7 +1524,7 @@ void CommandSetGl847::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
|
|||
bool black) const
|
||||
{
|
||||
DBG_HELPER_ARGS(dbg, "%s %s", black ? "black" : "white", forward ? "forward" : "reverse");
|
||||
unsigned int pixels, lines;
|
||||
unsigned int pixels;
|
||||
Genesys_Register_Set local_reg;
|
||||
unsigned int pass, count, found;
|
||||
char title[80];
|
||||
|
@ -1538,10 +1536,8 @@ void CommandSetGl847::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
|
|||
const auto& resolution_settings = dev->model->get_resolution_settings(dev->settings.scan_method);
|
||||
unsigned dpi = resolution_settings.get_min_resolution_x();
|
||||
unsigned channels = 1;
|
||||
/* 10 MM */
|
||||
/* lines = (10 * dpi) / MM_PER_INCH; */
|
||||
/* shading calibation is done with dev->motor.base_ydpi */
|
||||
lines = (dev->model->shading_lines * dpi) / dev->motor.base_ydpi;
|
||||
|
||||
unsigned lines = static_cast<unsigned>(dev->model->y_size_calib_mm * dpi / MM_PER_INCH);
|
||||
pixels = (sensor.sensor_pixels * dpi) / sensor.optical_res;
|
||||
dev->set_head_pos_zero(ScanHeadId::PRIMARY);
|
||||
|
||||
|
|
|
@ -456,6 +456,7 @@ void genesys_init_frontend_tables();
|
|||
void genesys_init_gpo_tables();
|
||||
void genesys_init_motor_tables();
|
||||
void genesys_init_usb_device_tables();
|
||||
void verify_usb_device_tables();
|
||||
|
||||
template<class T>
|
||||
void debug_dump(unsigned level, const T& value)
|
||||
|
|
Plik diff jest za duży
Load Diff
|
@ -389,6 +389,7 @@ TestResult perform_single_test(const TestConfig& config, const std::string& chec
|
|||
std::vector<TestConfig> get_all_test_configs()
|
||||
{
|
||||
genesys::genesys_init_usb_device_tables();
|
||||
genesys::verify_usb_device_tables();
|
||||
|
||||
std::vector<TestConfig> configs;
|
||||
std::unordered_set<std::string> model_names;
|
||||
|
|
Ładowanie…
Reference in New Issue