Returns the polygon outline of the current block. The returned Pta must * be ptaDestroy-ed after use. */
| 365 | /** Returns the polygon outline of the current block. The returned Pta must |
| 366 | * be ptaDestroy-ed after use. */ |
| 367 | Pta* PageIterator::BlockPolygon() const { |
| 368 | if (it_->block() == NULL || it_->block()->block == NULL) |
| 369 | return NULL; // Already at the end! |
| 370 | if (it_->block()->block->poly_block() == NULL) |
| 371 | return NULL; // No layout analysis used - no polygon. |
| 372 | ICOORDELT_IT it(it_->block()->block->poly_block()->points()); |
| 373 | Pta* pta = ptaCreate(it.length()); |
| 374 | int num_pts = 0; |
| 375 | for (it.mark_cycle_pt(); !it.cycled_list(); it.forward(), ++num_pts) { |
| 376 | ICOORD* pt = it.data(); |
| 377 | // Convert to top-down coords within the input image. |
| 378 | float x = static_cast<float>(pt->x()) / scale_ + rect_left_; |
| 379 | float y = rect_top_ + rect_height_ - static_cast<float>(pt->y()) / scale_; |
| 380 | ptaAddPt(pta, x, y); |
| 381 | } |
| 382 | return pta; |
| 383 | } |
| 384 | |
| 385 | /** |
| 386 | * Returns a binary image of the current object at the given level. |
nothing calls this directly
no test coverage detected