1389 {
1390 int16_t occupation;
1391
1392 BLOBNBOX_IT blob_it = row->
blob_list ();
1393 BLOBNBOX_IT start_it;
1394 BLOBNBOX_IT plot_it;
1395 int16_t blob_count;
1398 int32_t prev_right;
1399 int scale_factor;
1400 int32_t sp_count;
1401 FPSEGPT_LIST seg_list;
1402 FPSEGPT_IT seg_it;
1403 int16_t segpos;
1404 int16_t cellpos;
1405
1406 ICOORDELT_IT cell_it = row_cells;
1408 double sqsum;
1409 double spsum;
1410 double sp_var;
1411 double word_sync;
1412 int32_t total_count;
1413
1414 if ((pitsync_linear_version & 3) > 1) {
1416 projection_right, initial_pitch,
1417 occupation, mid_cuts, row_cells,
1418 testing_on, start, end);
1419 sp_sd = occupation;
1420 return word_sync;
1421 }
1422 mid_cuts = 0;
1423 cellpos = 0;
1424 total_count = 0;
1425 sqsum = 0;
1426 sp_count = 0;
1427 spsum = 0;
1428 prev_right = -1;
1429 if (blob_it.empty ())
1430 return space_size * 10;
1431#ifndef GRAPHICS_DISABLED
1432 if (testing_on &&
to_win !=
nullptr) {
1433 blob_box = blob_it.data ()->bounding_box ();
1436 }
1437#endif
1438 start_it = blob_it;
1439 blob_count = 0;
1441 blob_it.mark_cycle_pt ();
1442 do {
1443 for (; blob_count > 0; blob_count--)
1445 do {
1446 prev_box = blob_box;
1447 blob_count++;
1449 }
1450 while (!blob_it.cycled_list ()
1451 && blob_box.
left () - prev_box.
right () < space_size);
1452 plot_it = start_it;
1453 if (pitsync_linear_version & 3)
1454 word_sync =
1455 check_pitch_sync2 (&start_it, blob_count,
static_cast<int16_t
>(initial_pitch), 2,
1456 projection, projection_left, projection_right,
1458 occupation, &seg_list, start, end);
1459 else
1460 word_sync =
1461 check_pitch_sync (&start_it, blob_count,
static_cast<int16_t
>(initial_pitch), 2,
1462 projection, &seg_list);
1463 if (testing_on) {
1464 tprintf (
"Word ending at (%d,%d), len=%d, sync rating=%g, ",
1465 prev_box.
right (), prev_box.
top (),
1466 seg_list.length () - 1, word_sync);
1467 seg_it.set_to_list (&seg_list);
1468 for (seg_it.mark_cycle_pt (); !seg_it.cycled_list ();
1469 seg_it.forward ()) {
1470 if (seg_it.data ()->faked)
1472 tprintf (
"%d, ", seg_it.data ()->position ());
1473
1474
1475
1476
1477 }
1479 }
1480#ifndef GRAPHICS_DISABLED
1483#endif
1484 seg_it.set_to_list (&seg_list);
1485 if (prev_right >= 0) {
1486 sp_var = seg_it.data ()->position () - prev_right;
1487 sp_var -= floor (sp_var / initial_pitch + 0.5) * initial_pitch;
1488 sp_var *= sp_var;
1489 spsum += sp_var;
1490 sp_count++;
1491 }
1492 for (seg_it.mark_cycle_pt (); !seg_it.cycled_list (); seg_it.forward ()) {
1493 segpos = seg_it.data ()->position ();
1494 if (cell_it.empty () || segpos > cellpos + initial_pitch / 2) {
1495
1496 while (!cell_it.empty () && segpos > cellpos + initial_pitch * 3 / 2) {
1497 cell =
new ICOORDELT (cellpos +
static_cast<int16_t
>(initial_pitch), 0);
1498 cell_it.add_after_then_move (cell);
1499 cellpos += static_cast<int16_t>(initial_pitch);
1500 }
1501
1503 cell_it.add_after_then_move (cell);
1504 cellpos = segpos;
1505 }
1506 else if (segpos > cellpos - initial_pitch / 2) {
1507 cell = cell_it.data ();
1508
1509 cell->
set_x ((cellpos + segpos) / 2);
1510 cellpos = cell->
x ();
1511 }
1512 }
1513 seg_it.move_to_last ();
1514 prev_right = seg_it.data ()->position ();
1516 scale_factor = (seg_list.length () - 2) / 2;
1517 if (scale_factor < 1)
1518 scale_factor = 1;
1519 }
1520 else
1521 scale_factor = 1;
1522 sqsum += word_sync * scale_factor;
1523 total_count += (seg_list.length () - 1) * scale_factor;
1524 seg_list.clear ();
1525 }
1526 while (!blob_it.cycled_list ());
1527 sp_sd = sp_count > 0 ? sqrt (spsum / sp_count) : 0;
1528 return total_count > 0 ? sqrt (sqsum / total_count) : space_size * 10;
1529}
TBOX box_next(BLOBNBOX_IT *it)
void plot_fp_cells2(ScrollView *win, ScrollView::Color colour, TO_ROW *row, FPSEGPT_LIST *seg_list)
bool textord_show_fixed_cuts
double check_pitch_sync2(BLOBNBOX_IT *blob_it, int16_t blob_count, int16_t pitch, int16_t pitch_error, STATS *projection, int16_t projection_left, int16_t projection_right, float projection_scale, int16_t &occupation_count, FPSEGPT_LIST *seg_list, int16_t start, int16_t end)
double check_pitch_sync(BLOBNBOX_IT *blob_it, int16_t blob_count, int16_t pitch, int16_t pitch_error, STATS *projection, FPSEGPT_LIST *seg_list)
float compute_pitch_sd2(TO_ROW *row, STATS *projection, int16_t projection_left, int16_t projection_right, float initial_pitch, int16_t &occupation, int16_t &mid_cuts, ICOORDELT_LIST *row_cells, bool testing_on, int16_t start, int16_t end)
double textord_projection_scale
bool textord_pitch_scalebigwords
BLOBNBOX_LIST * blob_list()
void set_x(int16_t xin)
rewrite function
int16_t x() const
access function
void plot(ScrollView *window, float xorigin, float yorigin, float xscale, float yscale, ScrollView::Color colour) const