genesys: Remove no longer used code related to start position search

merge-requests/340/head
Povilas Kanapickas 2020-02-22 10:28:17 +02:00
rodzic 5f8129b2d0
commit 2cf05553c0
16 zmienionych plików z 3 dodań i 646 usunięć

Wyświetl plik

@ -97,7 +97,6 @@ public:
*/ */
virtual void send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const = 0; virtual void send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const = 0;
virtual void search_start_position(Genesys_Device* dev) const = 0;
virtual void offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, virtual void offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const = 0; Genesys_Register_Set& regs) const = 0;
virtual void coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, virtual void coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor,

Wyświetl plik

@ -445,9 +445,6 @@ enum class ModelFlag : unsigned
// skip lamp warmup (genesys_warmup()) // skip lamp warmup (genesys_warmup())
SKIP_WARMUP = 1 << 4, SKIP_WARMUP = 1 << 4,
// search start point befor scanning
SEARCH_START = 1 << 6,
// repark head and check for lock by moving without scanning // repark head and check for lock by moving without scanning
REPARK = 1 << 7, REPARK = 1 << 7,

Wyświetl plik

@ -529,179 +529,6 @@ void sanei_genesys_init_shading_data(Genesys_Device* dev, const Genesys_Sensor&
pixels_per_line * 4 * channels); pixels_per_line * 4 * channels);
} }
// Find the position of the reference point: takes gray level 8 bits data and find
// first CCD usable pixel and top of scanning area
void sanei_genesys_search_reference_point(Genesys_Device* dev, Genesys_Sensor& sensor,
const uint8_t* src_data, int start_pixel, int dpi,
int width, int height)
{
DBG_HELPER(dbg);
int x, y;
int current, left, top = 0;
int size, count;
int level = 80; /* edge threshold level */
// sanity check
if ((width < 3) || (height < 3)) {
throw SaneException("invalid width or height");
}
/* transformed image data */
size = width * height;
std::vector<uint8_t> image2(size, 0);
std::vector<uint8_t> image(size, 0);
/* laplace filter to denoise picture */
std::memcpy(image2.data(), src_data, size);
std::memcpy(image.data(), src_data, size); // to initialize unprocessed part of the image buffer
for (y = 1; y < height - 1; y++) {
for (x = 1; x < width - 1; x++) {
image[y * width + x] =
(image2[(y - 1) * width + x + 1] + 2 * image2[(y - 1) * width + x] +
image2[(y - 1) * width + x - 1] + 2 * image2[y * width + x + 1] +
4 * image2[y * width + x] + 2 * image2[y * width + x - 1] +
image2[(y + 1) * width + x + 1] + 2 * image2[(y + 1) * width + x] +
image2[(y + 1) * width + x - 1]) / 16;
}
}
image2 = image;
if (DBG_LEVEL >= DBG_data)
sanei_genesys_write_pnm_file("gl_laplace.pnm", image.data(), 8, 1, width, height);
/* apply X direction sobel filter
-1 0 1
-2 0 2
-1 0 1
and finds threshold level
*/
level = 0;
for (y = 2; y < height - 2; y++) {
for (x = 2; x < width - 2; x++) {
current = image2[(y - 1) * width + x + 1] - image2[(y - 1) * width + x - 1] +
2 * image2[y * width + x + 1] - 2 * image2[y * width + x - 1] +
image2[(y + 1) * width + x + 1] - image2[(y + 1) * width + x - 1];
if (current < 0)
current = -current;
if (current > 255)
current = 255;
image[y * width + x] = current;
if (current > level)
level = current;
}
}
if (DBG_LEVEL >= DBG_data)
sanei_genesys_write_pnm_file("gl_xsobel.pnm", image.data(), 8, 1, width, height);
/* set up detection level */
level = level / 3;
/* find left black margin first
todo: search top before left
we average the result of N searches */
left = 0;
count = 0;
for (y = 2; y < 11; y++)
{
x = 8;
while ((x < width / 2) && (image[y * width + x] < level))
{
image[y * width + x] = 255;
x++;
}
count++;
left += x;
}
if (DBG_LEVEL >= DBG_data)
sanei_genesys_write_pnm_file("gl_detected-xsobel.pnm", image.data(), 8, 1, width, height);
left = left / count;
// turn it in CCD pixel at full sensor optical resolution
sensor.ccd_start_xoffset = start_pixel + (left * sensor.optical_res) / dpi;
/* find top edge by detecting black strip */
/* apply Y direction sobel filter
-1 -2 -1
0 0 0
1 2 1
*/
level = 0;
for (y = 2; y < height - 2; y++) {
for (x = 2; x < width - 2; x++) {
current = -image2[(y - 1) * width + x + 1] - 2 * image2[(y - 1) * width + x] -
image2[(y - 1) * width + x - 1] + image2[(y + 1) * width + x + 1] +
2 * image2[(y + 1) * width + x] + image2[(y + 1) * width + x - 1];
if (current < 0)
current = -current;
if (current > 255)
current = 255;
image[y * width + x] = current;
if (current > level)
level = current;
}
}
if (DBG_LEVEL >= DBG_data)
sanei_genesys_write_pnm_file("gl_ysobel.pnm", image.data(), 8, 1, width, height);
/* set up detection level */
level = level / 3;
/* search top of horizontal black stripe : TODO yet another flag */
if (dev->model->sensor_id == SensorId::CCD_5345
&& dev->model->motor_id == MotorId::MD_5345)
{
top = 0;
count = 0;
for (x = width / 2; x < width - 1; x++)
{
y = 2;
while ((y < height) && (image[x + y * width] < level))
{
image[y * width + x] = 255;
y++;
}
count++;
top += y;
}
if (DBG_LEVEL >= DBG_data)
sanei_genesys_write_pnm_file("gl_detected-ysobel.pnm", image.data(), 8, 1, width, height);
top = top / count;
/* bottom of black stripe is of fixed witdh, this hardcoded value
* will be moved into device struct if more such values are needed */
top += 10;
dev->model->y_offset_calib_white = (top * MM_PER_INCH) / dpi;
DBG(DBG_info, "%s: black stripe y_offset = %f mm \n", __func__,
dev->model->y_offset_calib_white);
}
/* find white corner in dark area : TODO yet another flag */
if ((dev->model->sensor_id == SensorId::CCD_HP2300 && dev->model->motor_id == MotorId::HP2300) ||
(dev->model->sensor_id == SensorId::CCD_HP2400 && dev->model->motor_id == MotorId::HP2400) ||
(dev->model->sensor_id == SensorId::CCD_HP3670 && dev->model->motor_id == MotorId::HP3670))
{
top = 0;
count = 0;
for (x = 10; x < 60; x++)
{
y = 2;
while ((y < height) && (image[x + y * width] < level))
y++;
top += y;
count++;
}
top = top / count;
dev->model->y_offset_calib_white = (top * MM_PER_INCH) / dpi;
DBG(DBG_info, "%s: white corner y_offset = %f mm\n", __func__,
dev->model->y_offset_calib_white);
}
DBG(DBG_proc, "%s: ccd_start_xoffset = %d, left = %d, top = %d\n", __func__,
sensor.ccd_start_xoffset, left, top);
}
namespace gl124 { namespace gl124 {
void gl124_setup_scan_gpio(Genesys_Device* dev, int resolution); void gl124_setup_scan_gpio(Genesys_Device* dev, int resolution);
} // namespace gl124 } // namespace gl124
@ -2945,23 +2772,9 @@ static void genesys_start_scan(Genesys_Device* dev, bool lamp_off)
/* set top left x and y values by scanning the internals if flatbed scanners */ /* set top left x and y values by scanning the internals if flatbed scanners */
if (!dev->model->is_sheetfed) { if (!dev->model->is_sheetfed) {
/* do the geometry detection only once */ // TODO: check we can drop this since we cannot have the scanner's head wandering here
if (has_flag(dev->model->flags, ModelFlag::SEARCH_START) && dev->parking = false;
(dev->model->y_offset_calib_white == 0)) dev->cmd_set->move_back_home(dev, true);
{
dev->cmd_set->search_start_position (dev);
dev->parking = false;
dev->cmd_set->move_back_home(dev, true);
}
else
{
/* Go home */
/* TODO: check we can drop this since we cannot have the
scanner's head wandering here */
dev->parking = false;
dev->cmd_set->move_back_home(dev, true);
}
} }
/* move to calibration area for transparency adapter */ /* move to calibration area for transparency adapter */

Wyświetl plik

@ -1064,76 +1064,6 @@ void CommandSetGl124::move_back_home(Genesys_Device* dev, bool wait_until_home)
scanner_move_back_home(*dev, wait_until_home); scanner_move_back_home(*dev, wait_until_home);
} }
// Automatically set top-left edge of the scan area by scanning a 200x200 pixels area at 600 dpi
// from very top of scanner
void CommandSetGl124::search_start_position(Genesys_Device* dev) const
{
DBG_HELPER(dbg);
Genesys_Register_Set local_reg = dev->reg;
int pixels = 600;
int dpi = 300;
/* sets for a 200 lines * 600 pixels */
/* normal scan with no shading */
// FIXME: the current approach of doing search only for one resolution does not work on scanners
// whith employ different sensors with potentially different settings.
const auto& sensor = sanei_genesys_find_sensor(dev, dpi, 1, ScanMethod::FLATBED);
ScanSession session;
session.params.xres = dpi;
session.params.yres = dpi;
session.params.startx = 0;
session.params.starty = 0; /*we should give a small offset here~60 steps */
session.params.pixels = 600;
session.params.lines = dev->model->search_lines;
session.params.depth = 8;
session.params.channels = 1;
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = ScanColorMode::GRAY;
session.params.color_filter = ColorFilter::GREEN;
session.params.flags = ScanFlag::DISABLE_SHADING |
ScanFlag::DISABLE_GAMMA |
ScanFlag::DISABLE_BUFFER_FULL_MOVE;
compute_session(dev, session, sensor);
init_regs_for_scan_session(dev, sensor, &local_reg, session);
// send to scanner
dev->interface->write_registers(local_reg);
begin_scan(dev, sensor, &local_reg, true);
if (is_testing_mode()) {
dev->interface->test_checkpoint("search_start_position");
end_scan(dev, &local_reg, true);
dev->reg = local_reg;
return;
}
wait_until_buffer_non_empty(dev);
// now we're on target, we can read data
auto image = read_unshuffled_image_from_scanner(dev, session, session.output_total_bytes);
if (DBG_LEVEL >= DBG_data) {
sanei_genesys_write_pnm_file("gl124_search_position.pnm", image);
}
end_scan(dev, &local_reg, true);
/* update regs to copy ASIC internal state */
dev->reg = local_reg;
for (auto& sensor_update :
sanei_genesys_find_sensors_all_for_write(dev, dev->model->default_method))
{
sanei_genesys_search_reference_point(dev, sensor_update, image.get_row_ptr(0), 0, dpi, pixels,
dev->model->search_lines);
}
}
// init registers for shading calibration shading calibration is done at dpihw // init registers for shading calibration shading calibration is done at dpihw
void CommandSetGl124::init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor, void CommandSetGl124::init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const Genesys_Register_Set& regs) const

Wyświetl plik

@ -146,8 +146,6 @@ public:
void send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const override; void send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const override;
void search_start_position(Genesys_Device* dev) const override;
void offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, void offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const override; Genesys_Register_Set& regs) const override;

Wyświetl plik

@ -1574,76 +1574,6 @@ void CommandSetGl646::move_back_home(Genesys_Device* dev, bool wait_until_home)
DBG(DBG_info, "%s: scanhead is still moving\n", __func__); DBG(DBG_info, "%s: scanhead is still moving\n", __func__);
} }
/**
* Automatically set top-left edge of the scan area by scanning an
* area at 300 dpi from very top of scanner
* @param dev device stucture describing the scanner
*/
void CommandSetGl646::search_start_position(Genesys_Device* dev) const
{
DBG_HELPER(dbg);
Genesys_Settings settings;
unsigned int resolution, x, y;
/* we scan at 300 dpi */
resolution = get_closest_resolution(dev->model->sensor_id, 300, 1);
// FIXME: the current approach of doing search only for one resolution does not work on scanners
// whith employ different sensors with potentially different settings.
const auto& sensor = sanei_genesys_find_sensor(dev, resolution, 1,
dev->model->default_method);
/* fill settings for a gray level scan */
settings.scan_method = dev->model->default_method;
settings.scan_mode = ScanColorMode::GRAY;
settings.xres = resolution;
settings.yres = resolution;
settings.tl_x = 0;
settings.tl_y = 0;
settings.pixels = 600;
settings.requested_pixels = settings.pixels;
settings.lines = dev->model->search_lines;
settings.depth = 8;
settings.color_filter = ColorFilter::RED;
settings.disable_interpolation = 0;
settings.threshold = 0;
// scan the desired area
std::vector<uint8_t> data;
simple_scan(dev, sensor, settings, true, true, false, data, "search_start_position");
// handle stagger case : reorder gray data and thus loose some lines
auto staggered_lines = dev->session.num_staggered_lines;
if (staggered_lines > 0) {
DBG(DBG_proc, "%s: 'un-staggering'\n", __func__);
for (y = 0; y < settings.lines - staggered_lines; y++) {
/* one point out of 2 is 'unaligned' */
for (x = 0; x < settings.pixels; x += 2)
{
data[y * settings.pixels + x] = data[(y + staggered_lines) * settings.pixels + x];
}
}
/* correct line number */
settings.lines -= staggered_lines;
}
if (DBG_LEVEL >= DBG_data)
{
sanei_genesys_write_pnm_file("gl646_search_position.pnm", data.data(), settings.depth, 1,
settings.pixels, settings.lines);
}
// now search reference points on the data
for (auto& sensor_update :
sanei_genesys_find_sensors_all_for_write(dev, dev->model->default_method))
{
sanei_genesys_search_reference_point(dev, sensor_update, data.data(), 0,
resolution, settings.pixels, settings.lines);
}
}
/** /**
* init registers for shading calibration * init registers for shading calibration
* we assume that scanner's head is on an area suiting shading calibration. * we assume that scanner's head is on an area suiting shading calibration.

Wyświetl plik

@ -470,8 +470,6 @@ public:
void send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const override; void send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const override;
void search_start_position(Genesys_Device* dev) const override;
void offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, void offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const override; Genesys_Register_Set& regs) const override;

Wyświetl plik

@ -2216,78 +2216,6 @@ void CommandSetGl841::move_back_home(Genesys_Device* dev, bool wait_until_home)
DBG(DBG_info, "%s: scanhead is still moving\n", __func__); DBG(DBG_info, "%s: scanhead is still moving\n", __func__);
} }
// Automatically set top-left edge of the scan area by scanning a 200x200 pixels area at 600 dpi
// from very top of scanner
void CommandSetGl841::search_start_position(Genesys_Device* dev) const
{
DBG_HELPER(dbg);
Genesys_Register_Set local_reg;
int pixels = 600;
int dpi = 300;
local_reg = dev->reg;
/* sets for a 200 lines * 600 pixels */
/* normal scan with no shading */
// FIXME: the current approach of doing search only for one resolution does not work on scanners
// whith employ different sensors with potentially different settings.
const auto& sensor = sanei_genesys_find_sensor(dev, dpi, 1, dev->model->default_method);
ScanSession session;
session.params.xres = dpi;
session.params.yres = dpi;
session.params.startx = 0;
session.params.starty = 0; /*we should give a small offset here~60 steps*/
session.params.pixels = 600;
session.params.lines = dev->model->search_lines;
session.params.depth = 8;
session.params.channels = 1;
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = ScanColorMode::GRAY;
session.params.color_filter = ColorFilter::GREEN;
session.params.flags = ScanFlag::DISABLE_SHADING |
ScanFlag::DISABLE_GAMMA |
ScanFlag::DISABLE_BUFFER_FULL_MOVE;
compute_session(dev, session, sensor);
init_regs_for_scan_session(dev, sensor, &local_reg, session);
// send to scanner
dev->interface->write_registers(local_reg);
dev->cmd_set->begin_scan(dev, sensor, &local_reg, true);
if (is_testing_mode()) {
dev->interface->test_checkpoint("search_start_position");
dev->cmd_set->end_scan(dev, &local_reg, true);
dev->reg = local_reg;
return;
}
wait_until_buffer_non_empty(dev);
// now we're on target, we can read data
auto image = read_unshuffled_image_from_scanner(dev, session, session.output_total_bytes);
if (DBG_LEVEL >= DBG_data) {
sanei_genesys_write_pnm_file("gl841_search_position.pnm", image);
}
dev->cmd_set->end_scan(dev, &local_reg, true);
/* update regs to copy ASIC internal state */
dev->reg = local_reg;
for (auto& sensor_update :
sanei_genesys_find_sensors_all_for_write(dev, dev->model->default_method))
{
sanei_genesys_search_reference_point(dev, sensor_update, image.get_row_ptr(0), 0, dpi,
pixels, dev->model->search_lines);
}
}
// init registers for shading calibration // init registers for shading calibration
void CommandSetGl841::init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor, void CommandSetGl841::init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const Genesys_Register_Set& regs) const
@ -2683,8 +2611,6 @@ static void ad_fe_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
/* this function does the offset calibration by scanning one line of the calibration /* this function does the offset calibration by scanning one line of the calibration
area below scanner's top. There is a black margin and the remaining is white. area below scanner's top. There is a black margin and the remaining is white.
sanei_genesys_search_start() must have been called so that the offsets and margins
are allready known.
this function expects the slider to be where? this function expects the slider to be where?
*/ */

Wyświetl plik

@ -84,8 +84,6 @@ public:
void send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const override; void send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const override;
void search_start_position(Genesys_Device* dev) const override;
void offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, void offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const override; Genesys_Register_Set& regs) const override;

Wyświetl plik

@ -1481,80 +1481,6 @@ void CommandSetGl843::move_back_home(Genesys_Device* dev, bool wait_until_home)
scanner_move_back_home(*dev, wait_until_home); scanner_move_back_home(*dev, wait_until_home);
} }
// Automatically set top-left edge of the scan area by scanning a 200x200 pixels area at 600 dpi
// from very top of scanner
void CommandSetGl843::search_start_position(Genesys_Device* dev) const
{
DBG_HELPER(dbg);
Genesys_Register_Set local_reg;
int pixels = 600;
int dpi = 300;
local_reg = dev->reg;
/* sets for a 200 lines * 600 pixels */
/* normal scan with no shading */
// FIXME: the current approach of doing search only for one resolution does not work on scanners
// whith employ different sensors with potentially different settings.
const auto& sensor = sanei_genesys_find_sensor(dev, dpi, 1, dev->model->default_method);
ScanSession session;
session.params.xres = dpi;
session.params.yres = dpi;
session.params.startx = 0;
session.params.starty = 0; // we should give a small offset here - ~60 steps
session.params.pixels = 600;
session.params.lines = dev->model->search_lines;
session.params.depth = 8;
session.params.channels = 1;
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = ScanColorMode::GRAY;
session.params.color_filter = ColorFilter::GREEN;
session.params.flags = ScanFlag::DISABLE_SHADING |
ScanFlag::DISABLE_GAMMA |
ScanFlag::DISABLE_BUFFER_FULL_MOVE;
compute_session(dev, session, sensor);
init_regs_for_scan_session(dev, sensor, &local_reg, session);
// send to scanner
dev->interface->write_registers(local_reg);
dev->cmd_set->begin_scan(dev, sensor, &local_reg, true);
if (is_testing_mode()) {
dev->interface->test_checkpoint("search_start_position");
end_scan(dev, &local_reg, true);
dev->reg = local_reg;
return;
}
wait_until_buffer_non_empty(dev);
// now we're on target, we can read data
Image image = read_unshuffled_image_from_scanner(dev, session, session.output_total_bytes_raw);
scanner_stop_action_no_move(*dev, local_reg);
if (DBG_LEVEL >= DBG_data) {
sanei_genesys_write_pnm_file("gl843_search_position.pnm", image);
}
dev->cmd_set->end_scan(dev, &local_reg, true);
/* update regs to copy ASIC internal state */
dev->reg = local_reg;
for (auto& sensor_update :
sanei_genesys_find_sensors_all_for_write(dev, dev->model->default_method))
{
sanei_genesys_search_reference_point(dev, sensor_update, image.get_row_ptr(0), 0, dpi,
pixels, dev->model->search_lines);
}
}
static bool should_calibrate_only_active_area(const Genesys_Device& dev, static bool should_calibrate_only_active_area(const Genesys_Device& dev,
const Genesys_Settings& settings) const Genesys_Settings& settings)
{ {

Wyświetl plik

@ -84,8 +84,6 @@ public:
void send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const override; void send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const override;
void search_start_position(Genesys_Device* dev) const override;
void offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, void offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const override; Genesys_Register_Set& regs) const override;

Wyświetl plik

@ -834,81 +834,6 @@ void CommandSetGl846::move_back_home(Genesys_Device* dev, bool wait_until_home)
scanner_move_back_home(*dev, wait_until_home); scanner_move_back_home(*dev, wait_until_home);
} }
// Automatically set top-left edge of the scan area by scanning a 200x200 pixels area at 600 dpi
// from very top of scanner
void CommandSetGl846::search_start_position(Genesys_Device* dev) const
{
DBG_HELPER(dbg);
Genesys_Register_Set local_reg;
int pixels = 600;
int dpi = 300;
local_reg = dev->reg;
/* sets for a 200 lines * 600 pixels */
/* normal scan with no shading */
// FIXME: the current approach of doing search only for one resolution does not work on scanners
// whith employ different sensors with potentially different settings.
const auto& sensor = sanei_genesys_find_sensor(dev, dpi, 1, dev->model->default_method);
ScanSession session;
session.params.xres = dpi;
session.params.yres = dpi;
session.params.startx = 0;
session.params.starty = 0; /*we should give a small offset here~60 steps */
session.params.pixels = 600;
session.params.lines = dev->model->search_lines;
session.params.depth = 8;
session.params.channels = 1;
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = ScanColorMode::GRAY;
session.params.color_filter = ColorFilter::GREEN;
session.params.flags = ScanFlag::DISABLE_SHADING |
ScanFlag::DISABLE_GAMMA |
ScanFlag::IGNORE_STAGGER_OFFSET |
ScanFlag::IGNORE_COLOR_OFFSET;
compute_session(dev, session, sensor);
init_regs_for_scan_session(dev, sensor, &local_reg, session);
// send to scanner
dev->interface->write_registers(local_reg);
begin_scan(dev, sensor, &local_reg, true);
if (is_testing_mode()) {
dev->interface->test_checkpoint("search_start_position");
end_scan(dev, &local_reg, true);
dev->reg = local_reg;
return;
}
wait_until_buffer_non_empty(dev);
// now we're on target, we can read data
auto image = read_unshuffled_image_from_scanner(dev, session, session.output_total_bytes);
if (DBG_LEVEL >= DBG_data) {
sanei_genesys_write_pnm_file("gl846_search_position.pnm", image);
}
end_scan(dev, &local_reg, true);
/* update regs to copy ASIC internal state */
dev->reg = local_reg;
// TODO: find out where sanei_genesys_search_reference_point stores information,
// and use that correctly
for (auto& sensor_update :
sanei_genesys_find_sensors_all_for_write(dev, dev->model->default_method))
{
sanei_genesys_search_reference_point(dev, sensor_update, image.get_row_ptr(0), 0, dpi,
pixels, dev->model->search_lines);
}
}
// init registers for shading calibration // init registers for shading calibration
void CommandSetGl846::init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor, void CommandSetGl846::init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const Genesys_Register_Set& regs) const

Wyświetl plik

@ -159,8 +159,6 @@ public:
void send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const override; void send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const override;
void search_start_position(Genesys_Device* dev) const override;
void offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, void offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const override; Genesys_Register_Set& regs) const override;

Wyświetl plik

@ -842,79 +842,6 @@ void CommandSetGl847::move_back_home(Genesys_Device* dev, bool wait_until_home)
scanner_move_back_home(*dev, wait_until_home); scanner_move_back_home(*dev, wait_until_home);
} }
// Automatically set top-left edge of the scan area by scanning a 200x200 pixels area at 600 dpi
// from very top of scanner
void CommandSetGl847::search_start_position(Genesys_Device* dev) const
{
DBG_HELPER(dbg);
Genesys_Register_Set local_reg;
int pixels = 600;
int dpi = 300;
local_reg = dev->reg;
/* sets for a 200 lines * 600 pixels */
/* normal scan with no shading */
// FIXME: the current approach of doing search only for one resolution does not work on scanners
// whith employ different sensors with potentially different settings.
const auto& sensor = sanei_genesys_find_sensor(dev, dpi, 1, dev->model->default_method);
ScanSession session;
session.params.xres = dpi;
session.params.yres = dpi;
session.params.startx = 0;
session.params.starty = 0; /*we should give a small offset here~60 steps */
session.params.pixels = 600;
session.params.lines = dev->model->search_lines;
session.params.depth = 8;
session.params.channels = 1;
session.params.scan_method = dev->settings.scan_method;
session.params.scan_mode = ScanColorMode::GRAY;
session.params.color_filter = ColorFilter::GREEN;
session.params.flags = ScanFlag::DISABLE_SHADING |
ScanFlag::DISABLE_GAMMA;
compute_session(dev, session, sensor);
init_regs_for_scan_session(dev, sensor, &local_reg, session);
// send to scanner
dev->interface->write_registers(local_reg);
begin_scan(dev, sensor, &local_reg, true);
if (is_testing_mode()) {
dev->interface->test_checkpoint("search_start_position");
end_scan(dev, &local_reg, true);
dev->reg = local_reg;
return;
}
wait_until_buffer_non_empty(dev);
// now we're on target, we can read data
auto image = read_unshuffled_image_from_scanner(dev, session, session.output_total_bytes);
if (DBG_LEVEL >= DBG_data) {
sanei_genesys_write_pnm_file("gl847_search_position.pnm", image);
}
end_scan(dev, &local_reg, true);
/* update regs to copy ASIC internal state */
dev->reg = local_reg;
// TODO: find out where sanei_genesys_search_reference_point stores information,
// and use that correctly
for (auto& sensor_update :
sanei_genesys_find_sensors_all_for_write(dev, dev->model->default_method))
{
sanei_genesys_search_reference_point(dev, sensor_update, image.get_row_ptr(0), 0, dpi,
pixels, dev->model->search_lines);
}
}
// init registers for shading calibration // init registers for shading calibration
void CommandSetGl847::init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor, void CommandSetGl847::init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const Genesys_Register_Set& regs) const

Wyświetl plik

@ -147,8 +147,6 @@ public:
void send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const override; void send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const override;
void search_start_position(Genesys_Device* dev) const override;
void offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, void offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor,
Genesys_Register_Set& regs) const override; Genesys_Register_Set& regs) const override;

Wyświetl plik

@ -286,10 +286,6 @@ void sanei_genesys_send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& s
extern void sanei_genesys_stop_motor(Genesys_Device* dev); extern void sanei_genesys_stop_motor(Genesys_Device* dev);
extern void sanei_genesys_search_reference_point(Genesys_Device* dev, Genesys_Sensor& sensor,
const uint8_t* src_data, int start_pixel, int dpi,
int width, int height);
// moves the scan head by the specified steps at the motor base dpi // moves the scan head by the specified steps at the motor base dpi
void scanner_move(Genesys_Device& dev, ScanMethod scan_method, unsigned steps, Direction direction); void scanner_move(Genesys_Device& dev, ScanMethod scan_method, unsigned steps, Direction direction);