kopia lustrzana https://gitlab.com/sane-project/backends
- improved sanei_genesys_search_reference_point to fix origin detection
for HP2300 and a left margin detection bug with MD6345 - some HP2400 support tidbitsmerge-requests/1/head
rodzic
67ae886d9c
commit
7ec4d9b567
|
@ -1,3 +1,9 @@
|
||||||
|
2006-08-09 Stephane Voltz <stefdev@modulonet.fr>
|
||||||
|
|
||||||
|
* backend/genesys_gl646.c backend/genesys.c backend/genesys_devices.c:
|
||||||
|
improved sanei_genesys_search_reference_point to get more reliable
|
||||||
|
detection for HP2300 and MD6345. Slight tune up for HP2400 model.
|
||||||
|
|
||||||
2006-08-09 Gerhard Jaeger <gerhard@gjaeger.de>
|
2006-08-09 Gerhard Jaeger <gerhard@gjaeger.de>
|
||||||
|
|
||||||
* doc/plustek/Plustek-PARPORT.changes doc/plustek/Plustek-USB.changes
|
* doc/plustek/Plustek-PARPORT.changes doc/plustek/Plustek-USB.changes
|
||||||
|
|
|
@ -1439,17 +1439,12 @@ sanei_genesys_search_reference_point (Genesys_Device * dev, u_int8_t * data,
|
||||||
int x, y;
|
int x, y;
|
||||||
int current, left, top = 0, bottom = 0;
|
int current, left, top = 0, bottom = 0;
|
||||||
u_int8_t *image;
|
u_int8_t *image;
|
||||||
int size;
|
int size, count;
|
||||||
int level = 80; /* edge threshold level */
|
int level = 80; /* edge threshold level */
|
||||||
|
|
||||||
/*sanity check */
|
/*sanity check */
|
||||||
if ((width < 3) || (height < 3))
|
if ((width < 3) || (height < 3))
|
||||||
return SANE_STATUS_INVAL;
|
return SANE_STATUS_INVAL;
|
||||||
|
|
||||||
/* TODO either put this value in a new field in Genesys_sensor struct
|
|
||||||
or, better, compute it from data */
|
|
||||||
if (dev->model->ccd_type == CCD_HP2300)
|
|
||||||
level = 60;
|
|
||||||
|
|
||||||
/* transformed image data */
|
/* transformed image data */
|
||||||
size = width * height;
|
size = width * height;
|
||||||
|
@ -1481,9 +1476,11 @@ sanei_genesys_search_reference_point (Genesys_Device * dev, u_int8_t * data,
|
||||||
-1 0 1
|
-1 0 1
|
||||||
-2 0 2
|
-2 0 2
|
||||||
-1 0 1
|
-1 0 1
|
||||||
|
and finds threshold level
|
||||||
*/
|
*/
|
||||||
for (y = 1; y < height - 1; y++)
|
level = 0;
|
||||||
for (x = 1; x < width - 1; x++)
|
for (y = 2; y < height - 2; y++)
|
||||||
|
for (x = 2; x < width - 2; x++)
|
||||||
{
|
{
|
||||||
current =
|
current =
|
||||||
data[(y - 1) * width + x + 1] - data[(y - 1) * width + x - 1] +
|
data[(y - 1) * width + x + 1] - data[(y - 1) * width + x - 1] +
|
||||||
|
@ -1491,16 +1488,24 @@ sanei_genesys_search_reference_point (Genesys_Device * dev, u_int8_t * data,
|
||||||
data[(y + 1) * width + x + 1] - data[(y + 1) * width + x - 1];
|
data[(y + 1) * width + x + 1] - data[(y + 1) * width + x - 1];
|
||||||
if (current < 0)
|
if (current < 0)
|
||||||
current = -current;
|
current = -current;
|
||||||
|
if (current > 255)
|
||||||
|
current = 255;
|
||||||
image[y * width + x] = current;
|
image[y * width + x] = current;
|
||||||
|
if(current>level)
|
||||||
|
level = current;
|
||||||
}
|
}
|
||||||
if (DBG_LEVEL >= DBG_data)
|
if (DBG_LEVEL >= DBG_data)
|
||||||
sanei_genesys_write_pnm_file ("xsobel.pnm", image, 8, 1, width, height);
|
sanei_genesys_write_pnm_file ("xsobel.pnm", image, 8, 1, width, height);
|
||||||
|
|
||||||
|
/* set up detection level */
|
||||||
|
level = level / 3;
|
||||||
|
|
||||||
/* find left black margin first
|
/* find left black margin first
|
||||||
todo: search top before left
|
todo: search top before left
|
||||||
we average the result of N searches */
|
we average the result of N searches */
|
||||||
left = 0;
|
left = 0;
|
||||||
for (y = 1; y < 11; y++)
|
count = 0;
|
||||||
|
for (y = 2; y < 11; y++)
|
||||||
{
|
{
|
||||||
x = 8;
|
x = 8;
|
||||||
while ((x < width / 2) && (image[y * width + x] < level))
|
while ((x < width / 2) && (image[y * width + x] < level))
|
||||||
|
@ -1508,9 +1513,12 @@ sanei_genesys_search_reference_point (Genesys_Device * dev, u_int8_t * data,
|
||||||
image[y * width + x] = 255;
|
image[y * width + x] = 255;
|
||||||
x++;
|
x++;
|
||||||
}
|
}
|
||||||
|
count ++;
|
||||||
left += x;
|
left += x;
|
||||||
}
|
}
|
||||||
left = left / (y - 1);
|
if (DBG_LEVEL >= DBG_data)
|
||||||
|
sanei_genesys_write_pnm_file ("detected-xsobel.pnm", image, 8, 1, width, height);
|
||||||
|
left = left / count;
|
||||||
|
|
||||||
/* turn it in CCD pixel at full sensor optical resolution */
|
/* turn it in CCD pixel at full sensor optical resolution */
|
||||||
dev->sensor.CCD_start_xoffset =
|
dev->sensor.CCD_start_xoffset =
|
||||||
|
@ -1522,8 +1530,9 @@ sanei_genesys_search_reference_point (Genesys_Device * dev, u_int8_t * data,
|
||||||
0 0 0
|
0 0 0
|
||||||
1 2 1
|
1 2 1
|
||||||
*/
|
*/
|
||||||
for (y = 1; y < height - 1; y++)
|
level = 0;
|
||||||
for (x = 1; x < width - 1; x++)
|
for (y = 2; y < height - 2; y++)
|
||||||
|
for (x = 2; x < width - 2; x++)
|
||||||
{
|
{
|
||||||
current =
|
current =
|
||||||
-data[(y - 1) * width + x + 1] - 2 * data[(y - 1) * width + x] -
|
-data[(y - 1) * width + x + 1] - 2 * data[(y - 1) * width + x] -
|
||||||
|
@ -1531,35 +1540,51 @@ sanei_genesys_search_reference_point (Genesys_Device * dev, u_int8_t * data,
|
||||||
2 * data[(y + 1) * width + x] + data[(y + 1) * width + x - 1];
|
2 * data[(y + 1) * width + x] + data[(y + 1) * width + x - 1];
|
||||||
if (current < 0)
|
if (current < 0)
|
||||||
current = -current;
|
current = -current;
|
||||||
|
if (current > 255)
|
||||||
|
current = 255;
|
||||||
image[y * width + x] = current;
|
image[y * width + x] = current;
|
||||||
|
if(current>level)
|
||||||
|
level = current;
|
||||||
}
|
}
|
||||||
if (DBG_LEVEL >= DBG_data)
|
if (DBG_LEVEL >= DBG_data)
|
||||||
sanei_genesys_write_pnm_file ("ysobel.pnm", image, 8, 1, width, height);
|
sanei_genesys_write_pnm_file ("ysobel.pnm", image, 8, 1, width, height);
|
||||||
|
|
||||||
|
/* set up detection level */
|
||||||
|
level = level / 3;
|
||||||
|
|
||||||
/* search top of horizontal black stripe */
|
/* search top of horizontal black stripe */
|
||||||
if (dev->model->ccd_type == CCD_5345
|
if (dev->model->ccd_type == CCD_5345
|
||||||
&& dev->model->motor_type == MOTOR_5345)
|
&& dev->model->motor_type == MOTOR_5345)
|
||||||
{
|
{
|
||||||
top = 0;
|
top = 0;
|
||||||
|
count = 0;
|
||||||
for (x = width / 2; x < width - 1; x++)
|
for (x = width / 2; x < width - 1; x++)
|
||||||
{
|
{
|
||||||
y = 2;
|
y = 2;
|
||||||
while ((y < height) && (image[x + y * width] < level))
|
while ((y < height) && (image[x + y * width] < level))
|
||||||
y++;
|
{
|
||||||
|
image[y * width + x] = 255;
|
||||||
|
y++;
|
||||||
|
}
|
||||||
|
count ++;
|
||||||
top += y;
|
top += y;
|
||||||
}
|
}
|
||||||
top = top / (width / 2 - 1);
|
if (DBG_LEVEL >= DBG_data)
|
||||||
|
sanei_genesys_write_pnm_file ("detected-ysobel.pnm", image, 8, 1, width, height);
|
||||||
|
top = top / count;
|
||||||
|
|
||||||
/* find bottom of black stripe */
|
/* find bottom of black stripe */
|
||||||
bottom = 0;
|
bottom = 0;
|
||||||
|
count = 0;
|
||||||
for (x = width / 2; x < width - 1; x++)
|
for (x = width / 2; x < width - 1; x++)
|
||||||
{
|
{
|
||||||
y = top + 5;
|
y = top + 5;
|
||||||
while ((y < height) && (image[x + y * width] < level))
|
while ((y < height) && (image[x + y * width] < level))
|
||||||
y++;
|
y++;
|
||||||
bottom += y;
|
bottom += y;
|
||||||
|
count ++;
|
||||||
}
|
}
|
||||||
bottom = bottom / (width / 2 - 1);
|
bottom = bottom / count;
|
||||||
dev->model->y_offset_calib = SANE_FIX ((bottom * MM_PER_INCH) / dpi);
|
dev->model->y_offset_calib = SANE_FIX ((bottom * MM_PER_INCH) / dpi);
|
||||||
DBG (DBG_info,
|
DBG (DBG_info,
|
||||||
"sanei_genesys_search_reference_point: black stripe y_offset = %f mm \n",
|
"sanei_genesys_search_reference_point: black stripe y_offset = %f mm \n",
|
||||||
|
@ -1571,14 +1596,16 @@ sanei_genesys_search_reference_point (Genesys_Device * dev, u_int8_t * data,
|
||||||
&& dev->model->motor_type == MOTOR_HP2300)
|
&& dev->model->motor_type == MOTOR_HP2300)
|
||||||
{
|
{
|
||||||
top = 0;
|
top = 0;
|
||||||
|
count = 0;
|
||||||
for (x = 10; x < 60; x++)
|
for (x = 10; x < 60; x++)
|
||||||
{
|
{
|
||||||
y = 2;
|
y = 2;
|
||||||
while ((y < height) && (image[x + y * width] < level))
|
while ((y < height) && (image[x + y * width] < level))
|
||||||
y++;
|
y++;
|
||||||
top += y;
|
top += y;
|
||||||
|
count ++;
|
||||||
}
|
}
|
||||||
top = top / 50;
|
top = top / count;
|
||||||
dev->model->y_offset_calib = SANE_FIX ((top * MM_PER_INCH) / dpi);
|
dev->model->y_offset_calib = SANE_FIX ((top * MM_PER_INCH) / dpi);
|
||||||
DBG (DBG_info,
|
DBG (DBG_info,
|
||||||
"sanei_genesys_search_reference_point: white corner y_offset = %f mm\n",
|
"sanei_genesys_search_reference_point: white corner y_offset = %f mm\n",
|
||||||
|
@ -1587,8 +1614,8 @@ sanei_genesys_search_reference_point (Genesys_Device * dev, u_int8_t * data,
|
||||||
|
|
||||||
free (image);
|
free (image);
|
||||||
DBG (DBG_proc,
|
DBG (DBG_proc,
|
||||||
"sanei_genesys_search_reference_point: CCD_start_xoffset = %d, top = %d, bottom=%d\n",
|
"sanei_genesys_search_reference_point: CCD_start_xoffset = %d, left = %d, top = %d, bottom=%d\n",
|
||||||
dev->sensor.CCD_start_xoffset, top, bottom);
|
dev->sensor.CCD_start_xoffset, left, top, bottom);
|
||||||
|
|
||||||
return SANE_STATUS_GOOD;
|
return SANE_STATUS_GOOD;
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,7 +171,7 @@ static Genesys_Sensor Sensor[] = {
|
||||||
15, 0, 10872, 210, 200,
|
15, 0, 10872, 210, 200,
|
||||||
{0x14, 0x15, 0x00, 0x00}
|
{0x14, 0x15, 0x00, 0x00}
|
||||||
,
|
,
|
||||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x08, 0x30, 0x2a, 0x00, 0x00,
|
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbf, 0x08, 0x3f, 0x2a, 0x00, 0x00,
|
||||||
0x00, 0x02}
|
0x00, 0x02}
|
||||||
,
|
,
|
||||||
{0x0b, 0x0f, 0x13, 0x17, 0x03, 0x07, 0x63, 0x00, 0xc1, 0x00, 0x00, 0x00,
|
{0x0b, 0x0f, 0x13, 0x17, 0x03, 0x07, 0x63, 0x00, 0xc1, 0x00, 0x00, 0x00,
|
||||||
|
|
|
@ -720,6 +720,22 @@ gl646_setup_sensor (Genesys_Device * dev,
|
||||||
r->value = 0x80 | (r->value & 0x03); /* VSMP=16 */
|
r->value = 0x80 | (r->value & 0x03); /* VSMP=16 */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dev->model->ccd_type == CCD_HP2400)
|
||||||
|
{
|
||||||
|
/* settings for CCD used at half is max resolution */
|
||||||
|
if (half_ccd)
|
||||||
|
{
|
||||||
|
r = sanei_genesys_get_address (regs, 0x08);
|
||||||
|
r->value = 2;
|
||||||
|
r = sanei_genesys_get_address (regs, 0x09);
|
||||||
|
r->value = 4;
|
||||||
|
r = sanei_genesys_get_address (regs, 0x0a);
|
||||||
|
r->value = 0;
|
||||||
|
r = sanei_genesys_get_address (regs, 0x0b);
|
||||||
|
r->value = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Test if the ASIC works
|
/** Test if the ASIC works
|
||||||
|
@ -3840,6 +3856,11 @@ gl646_init_regs_for_warmup (Genesys_Device * dev,
|
||||||
slope_table[0] = 4480;
|
slope_table[0] = 4480;
|
||||||
slope_table[1] = 4480;
|
slope_table[1] = 4480;
|
||||||
}
|
}
|
||||||
|
else if (dev->model->motor_type == MOTOR_HP2400)
|
||||||
|
{
|
||||||
|
slope_table[0] = 7120;
|
||||||
|
slope_table[1] = 7120;
|
||||||
|
}
|
||||||
RIE (gl646_send_slope_table
|
RIE (gl646_send_slope_table
|
||||||
(dev, 0, slope_table, local_reg[reg_0x21].value));
|
(dev, 0, slope_table, local_reg[reg_0x21].value));
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue