本文整理匯總了C++中ROW類的典型用法代碼示例。如果您正苦於以下問題:C++ ROW類的具體用法?C++ ROW怎麽用?C++ ROW使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ROW類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: row_it
void BLOCK::compress() { // squash it up
#define ROW_SPACING 5
ROW_IT row_it(&rows);
ROW *row;
ICOORD row_spacing (0, ROW_SPACING);
ICOORDELT_IT icoordelt_it;
sort_rows();
box = TBOX (box.topleft (), box.topleft ());
box.move_bottom_edge (ROW_SPACING);
for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ()) {
row = row_it.data ();
row->move (box.botleft () - row_spacing -
row->bounding_box ().topleft ());
box += row->bounding_box ();
}
leftside.clear ();
icoordelt_it.set_to_list (&leftside);
icoordelt_it.add_to_end (new ICOORDELT (box.left (), box.bottom ()));
icoordelt_it.add_to_end (new ICOORDELT (box.left (), box.top ()));
rightside.clear ();
icoordelt_it.set_to_list (&rightside);
icoordelt_it.add_to_end (new ICOORDELT (box.right (), box.bottom ()));
icoordelt_it.add_to_end (new ICOORDELT (box.right (), box.top ()));
}
示例2: PreenXHeights
/// Builds a PAGE_RES from the block_list in the way required for ApplyBoxes:
/// All fuzzy spaces are removed, and all the words are maximally chopped.
PAGE_RES* Tesseract::SetupApplyBoxes(const GenericVector<TBOX>& boxes,
BLOCK_LIST *block_list) {
PreenXHeights(block_list);
// Strip all fuzzy space markers to simplify the PAGE_RES.
BLOCK_IT b_it(block_list);
for (b_it.mark_cycle_pt(); !b_it.cycled_list(); b_it.forward()) {
BLOCK* block = b_it.data();
ROW_IT r_it(block->row_list());
for (r_it.mark_cycle_pt(); !r_it.cycled_list(); r_it.forward ()) {
ROW* row = r_it.data();
WERD_IT w_it(row->word_list());
for (w_it.mark_cycle_pt(); !w_it.cycled_list(); w_it.forward()) {
WERD* word = w_it.data();
if (word->cblob_list()->empty()) {
delete w_it.extract();
} else {
word->set_flag(W_FUZZY_SP, false);
word->set_flag(W_FUZZY_NON, false);
}
}
}
}
PAGE_RES* page_res = new PAGE_RES(false, block_list, NULL);
PAGE_RES_IT pr_it(page_res);
WERD_RES* word_res;
while ((word_res = pr_it.word()) != NULL) {
MaximallyChopWord(boxes, pr_it.block()->block,
pr_it.row()->row, word_res);
pr_it.forward();
}
return page_res;
}
示例3: value_type
void LRURowStorage<ROW, V>::insert_inactive(int32_t row_id,
const ROW<V>& new_row) {
// Sanity check.
int num_rows = inactive_list_.size() + active_list_.size();
CHECK_LE(num_rows, this->capacity_)
<< "Number of rows exceed storage size.";
// If necessary, make space...
if (num_rows == this->capacity_) {
// ...by purging the least-recently-used element (head of list).
VLOG(1) << "Evicting row " << inactive_list_.right.begin()->second
<< " to insert row " << row_id;
inactive_list_.right.erase(inactive_list_.right.begin());
}
// Create a new record from the key and the value
// bimap's list_view defaults to inserting this at
// the list tail (considered most-recently-used).
int threshold_count = static_cast<int>(num_row_access_to_active_ *
new_row.get_num_columns()); // Compute the threshold count.
AccessStatsRow new_inactive_row = boost::tuples::make_tuple(new_row, 0,
threshold_count);
inactive_list_.insert(
typename AccessCountMapList::value_type(row_id, new_inactive_row));
VLOG(1) << "Inserted new row (row id = " << row_id << ") of size "
<< new_row.get_num_columns() << " with threshold count = "
<< threshold_count;
}
示例4: PrintSegmentationStats
void PrintSegmentationStats(BLOCK_LIST* block_list) {
int num_blocks = 0;
int num_rows = 0;
int num_words = 0;
int num_blobs = 0;
BLOCK_IT block_it(block_list);
for (block_it.mark_cycle_pt(); !block_it.cycled_list(); block_it.forward()) {
BLOCK* block = block_it.data();
++num_blocks;
ROW_IT row_it(block->row_list());
for (row_it.mark_cycle_pt(); !row_it.cycled_list(); row_it.forward()) {
++num_rows;
ROW* row = row_it.data();
// Iterate over all werds in the row.
WERD_IT werd_it(row->word_list());
for (werd_it.mark_cycle_pt(); !werd_it.cycled_list(); werd_it.forward()) {
WERD* werd = werd_it.data();
++num_words;
num_blobs += werd->cblob_list()->length();
}
}
}
tprintf("Block list stats:\nBlocks = %d\nRows = %d\nWords = %d\nBlobs = %d\n",
num_blocks, num_rows, num_words, num_blobs);
}
示例5: apply_box_training
void apply_box_training(BLOCK_LIST *block_list) {
BLOCK_IT block_it(block_list);
ROW_IT row_it;
ROW *row;
WERD_IT word_it;
WERD *word;
WERD *bln_word;
WERD copy_outword; // copy to denorm
PBLOB_IT blob_it;
DENORM denorm;
INT16 count = 0;
char ch[2];
ch[1] = '\0';
tprintf ("Generating training data\n");
for (block_it.mark_cycle_pt ();
!block_it.cycled_list (); block_it.forward ()) {
row_it.set_to_list (block_it.data ()->row_list ());
for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ()) {
row = row_it.data ();
word_it.set_to_list (row->word_list ());
for (word_it.mark_cycle_pt ();
!word_it.cycled_list (); word_it.forward ()) {
word = word_it.data ();
if ((strlen (word->text ()) == 1) &&
(word->gblob_list ()->length () == 1)) {
/* Here is a word with a single char label and a single blob so train on it */
bln_word =
make_bln_copy (word, row, row->x_height (), &denorm);
blob_it.set_to_list (bln_word->blob_list ());
ch[0] = *word->text ();
tess_training_tester (blob_it.data (),
//single blob
&denorm, TRUE, //correct
ch, //correct ASCII char
1, //ASCII length
NULL);
copy_outword = *(bln_word);
copy_outword.baseline_denormalise (&denorm);
blob_it.set_to_list (copy_outword.blob_list ());
ch[0] = *word->text ();
delete bln_word;
count++;
}
}
}
}
tprintf ("Generated training data for %d blobs\n", count);
}
示例6: DestroyAllEditControls
void TABLE::tCut()
{
if(TABLE_ATTRIBUTES::AutoFill())
return;
DestroyAllEditControls();
Copy();
RUNTIMEINFO* rtime = (RUNTIMEINFO*)AObjGetRuntimeInfo(theObject);
ROW* row = rtime->GetRow();
row->DeleteSelectedRows();
PostObjectChanged(CHANGED_NUMROWS);
}
示例7: GetWindowRect
void TABLE::DestroyEditControl()
{
if(hEdit)
{
// Get the rectangle of the cell for intelligent update
RECT cellRect;
GetWindowRect(hEdit, &cellRect);
ScreenToClient(hTable, (POINT*)&cellRect);
ScreenToClient(hTable, (POINT*)&cellRect.right);
cellRect.left -= COLUMN::CellCharWidth(editCol);
cellRect.top = cellRect.bottom - TABLE_ATTRIBUTES::CellHeight();
cellRect.right += COLUMN::CellCharWidth(editCol);
// un-subclass the control in preparation for destroy
RemoveProp(hEdit, "loPtr");
RemoveProp(hEdit, "hiPtr");
RemoveProp(hEdit, "number");
SetWindowLong(hEdit, GWL_WNDPROC, (long)oldEditControlProc);
// get the text and update the cell as necessary
WORD len = (WORD)SendMessage(hEdit, WM_GETTEXTLENGTH, 0, 0L)+1;
char* buffer = new char[len];
SendMessage(hEdit, WM_GETTEXT, (WPARAM)(len+1), (LPARAM)buffer);
RUNTIMEINFO* rtime = (RUNTIMEINFO*)AObjGetRuntimeInfo(theObject);
ROW* row = rtime->GetRow();
if(hstrcmp(row->GetCell(editRow, editCol, FALSE, NULL), buffer))
{
row->SetCell(editRow, editCol, buffer);
TABLE_ATTRIBUTES::SetEditRow(editRow);
TABLE_ATTRIBUTES::SetEditColumn(editCol);
PostObjectChanged(CHANGED_FULLREDRAW);
AEvtPostSignalAtMark(theObject, SIGNAL_TABLEEDITED);
}
delete buffer;
// destroy the window
DestroyWindow(hEdit);
hEdit = NULL;
DeleteObject(hEditFont);
AEvtPostSignalAtMark(theObject, SIGNAL_STOPEDITING);
// make sure the proper region is redrawn
InvalidateRect(hTable, &cellRect, FALSE);
UpdateWindow(hTable);
// wipPreventThieves(ParentID, FALSE); SKJ need replacement
}
}
示例8: cleanup_nontext_block
void Textord::cleanup_blocks(bool clean_noise, BLOCK_LIST* blocks) {
BLOCK_IT block_it = blocks; //iterator
ROW_IT row_it; //row iterator
int num_rows = 0;
int num_rows_all = 0;
int num_blocks = 0;
int num_blocks_all = 0;
for (block_it.mark_cycle_pt(); !block_it.cycled_list();
block_it.forward()) {
BLOCK* block = block_it.data();
if (block->pdblk.poly_block() != nullptr && !block->pdblk.poly_block()->IsText()) {
cleanup_nontext_block(block);
continue;
}
num_rows = 0;
num_rows_all = 0;
if (clean_noise) {
row_it.set_to_list(block->row_list());
for (row_it.mark_cycle_pt(); !row_it.cycled_list(); row_it.forward()) {
ROW* row = row_it.data();
++num_rows_all;
clean_small_noise_from_words(row);
if ((textord_noise_rejrows && !row->word_list()->empty() &&
clean_noise_from_row(row)) ||
row->word_list()->empty()) {
delete row_it.extract(); // lose empty row.
} else {
if (textord_noise_rejwords)
clean_noise_from_words(row_it.data());
if (textord_blshift_maxshift >= 0)
tweak_row_baseline(row, textord_blshift_maxshift,
textord_blshift_xfraction);
++num_rows;
}
}
}
if (block->row_list()->empty()) {
delete block_it.extract(); // Lose empty text blocks.
} else {
++num_blocks;
}
++num_blocks_all;
if (textord_noise_debug)
tprintf("cleanup_blocks: # rows = %d / %d\n", num_rows, num_rows_all);
}
if (textord_noise_debug)
tprintf("cleanup_blocks: # blocks = %d / %d\n", num_blocks, num_blocks_all);
}
示例9: IsClipboardFormatAvailable
void TABLE::tPaste()
{
if(TABLE_ATTRIBUTES::AutoFill())
return;
BOOL available = IsClipboardFormatAvailable(CF_TEXT);
if(!available)
return;
DestroyAllEditControls();
OpenClipboard(hParentWnd);
HGLOBAL hClipboard = GetClipboardData(CF_TEXT);
if(!hClipboard)
{
CloseClipboard();
return;
}
HGLOBAL hCopy = GlobalAlloc(GHND, GlobalSize(hClipboard));
if(!hCopy)
{
CloseClipboard();
return;
}
char* copy = (char*)GlobalLock(hCopy);
char* clip = (char*)GlobalLock(hClipboard);
hmemcpy(copy, clip, GlobalSize(hClipboard));
GlobalUnlock(hClipboard);
CloseClipboard();
RUNTIMEINFO* rtime = (RUNTIMEINFO*)AObjGetRuntimeInfo(theObject);
ROW* row = rtime->GetRow();
long first = row->FirstSelection();
char* token = (char*)myStrtok((char huge*)copy);
while(token)
{
row->AddRow(first, token, TABLE_ATTRIBUTES::NumColumns(), FALSE);
token = (char*)myStrtok(NULL);
first++;
}
GlobalUnlock(hCopy);
GlobalFree(hCopy);
row->DeleteSelectedRows();
PostObjectChanged(CHANGED_NUMROWS);
}
示例10: tCopy
void TABLE::tCopy()
{
RUNTIMEINFO* rtime = (RUNTIMEINFO*)AObjGetRuntimeInfo(theObject);
ROW* row = rtime->GetRow();
long numRows = row->NumSelections();
long length = numRows;
BOOL dbAccessed = FALSE;
if(numRows<1 || numRows>row->NumRows())
return;
for(long i=0; i<numRows; i++)
length += row->RowLength(row->GetSelection(i), TRUE, &dbAccessed);
HGLOBAL hClip = GlobalAlloc(GHND, length);
if(!hClip)
{
if(dbAccessed)
AEvtPostSignalAtMark(theObject, SIGNAL_TABLEAUTOFILLED);
return;
}
char huge* clip = (char huge*)GlobalLock(hClip);
long sel;
long offset=0;
for(i=0; i<numRows; i++)
{
sel = row->GetSelection(i);
length = row->RowLength(sel, TRUE, &dbAccessed);
row->GetRow(sel, clip+offset, length, TRUE, TRUE, &dbAccessed);
if(i!=(numRows-1))
{
// give the cr-lf combination
*(clip+(offset + length - 1)) = '\r';
*(clip+(offset + length++)) = '\n';
}
else
*(clip+(offset + length - 1)) = 0;
offset+=length;
}
GlobalUnlock(hClip);
OpenClipboard(hParentWnd);
EmptyClipboard();
SetClipboardData(CF_TEXT, hClip);
CloseClipboard();
if(dbAccessed)
AEvtPostSignalAtMark(theObject, SIGNAL_TABLEAUTOFILLED);
}
示例11:
//----------------------------------------------------------------------
MAT EEMD::eemdf90( ROW input, float noise_amplitude, int num_imfs, int num_ensembles ) {
// Tanspose the Row vector into a Column vector
VEC col_input = input.t();
MAT col_imfs = eemdf90(col_input, noise_amplitude, num_imfs, num_ensembles);
MAT row_imfs = col_imfs.t();
return row_imfs;
}
示例12: RefreshWordBlobsFromNewBlobs
void RefreshWordBlobsFromNewBlobs(BLOCK_LIST* block_list,
C_BLOB_LIST* new_blobs,
C_BLOB_LIST* not_found_blobs) {
// Now iterate over all the blobs in the segmentation_block_list_, and just
// replace the corresponding c-blobs inside the werds.
BLOCK_IT block_it(block_list);
for (block_it.mark_cycle_pt(); !block_it.cycled_list(); block_it.forward()) {
BLOCK* block = block_it.data();
if (block->poly_block() != NULL && !block->poly_block()->IsText())
continue; // Don't touch non-text blocks.
// Iterate over all rows in the block.
ROW_IT row_it(block->row_list());
for (row_it.mark_cycle_pt(); !row_it.cycled_list(); row_it.forward()) {
ROW* row = row_it.data();
// Iterate over all werds in the row.
WERD_IT werd_it(row->word_list());
WERD_LIST new_words;
WERD_IT new_words_it(&new_words);
for (werd_it.mark_cycle_pt(); !werd_it.cycled_list(); werd_it.forward()) {
WERD* werd = werd_it.extract();
WERD* new_werd = werd->ConstructWerdWithNewBlobs(new_blobs,
not_found_blobs);
if (new_werd) {
// Insert this new werd into the actual row's werd-list. Remove the
// existing one.
new_words_it.add_after_then_move(new_werd);
delete werd;
} else {
// Reinsert the older word back, for lack of better options.
// This is critical since dropping the words messes up segmentation:
// eg. 1st word in the row might otherwise have W_FUZZY_NON turned on.
new_words_it.add_after_then_move(werd);
}
}
// Get rid of the old word list & replace it with the new one.
row->word_list()->clear();
werd_it.move_to_first();
werd_it.add_list_after(&new_words);
}
}
}
示例13: MedianXHeight
/// Any row xheight that is significantly different from the median is set
/// to the median.
void Tesseract::PreenXHeights(BLOCK_LIST *block_list) {
double median_xheight = MedianXHeight(block_list);
double max_deviation = kMaxXHeightDeviationFraction * median_xheight;
// Strip all fuzzy space markers to simplify the PAGE_RES.
BLOCK_IT b_it(block_list);
for (b_it.mark_cycle_pt(); !b_it.cycled_list(); b_it.forward()) {
BLOCK* block = b_it.data();
ROW_IT r_it(block->row_list());
for (r_it.mark_cycle_pt(); !r_it.cycled_list(); r_it.forward ()) {
ROW* row = r_it.data();
float diff = fabs(row->x_height() - median_xheight);
if (diff > max_deviation) {
if (applybox_debug) {
tprintf("row xheight=%g, but median xheight = %g\n",
row->x_height(), median_xheight);
}
row->set_x_height(static_cast<float>(median_xheight));
}
}
}
}
示例14: throw
const FP_LIB_TABLE::ROW* FP_LIB_TABLE::FindRow( const wxString& aNickname )
throw( IO_ERROR )
{
ROW* row = findRow( aNickname );
if( !row )
{
wxString msg = wxString::Format(
_( "fp-lib-table files contain no lib with nickname '%s'" ),
GetChars( aNickname ) );
THROW_IO_ERROR( msg );
}
// We've been 'lazy' up until now, but it cannot be deferred any longer,
// instantiate a PLUGIN of the proper kind if it is not already in this ROW.
if( !row->plugin )
row->setPlugin( IO_MGR::PluginFind( row->type ) );
return row;
}
示例15: Baseline
/**
* Returns the baseline of the current object at the given level.
* The baseline is the line that passes through (x1, y1) and (x2, y2).
* WARNING: with vertical text, baselines may be vertical!
*/
bool PageIterator::Baseline(PageIteratorLevel level,
int* x1, int* y1, int* x2, int* y2) const {
if (it_->word() == NULL) return false; // Already at the end!
ROW* row = it_->row()->row;
WERD* word = it_->word()->word;
TBOX box = (level == RIL_WORD || level == RIL_SYMBOL)
? word->bounding_box()
: row->bounding_box();
int left = box.left();
ICOORD startpt(left, static_cast<inT16>(row->base_line(left) + 0.5));
int right = box.right();
ICOORD endpt(right, static_cast<inT16>(row->base_line(right) + 0.5));
// Rotate to image coordinates and convert to global image coords.
startpt.rotate(it_->block()->block->re_rotation());
endpt.rotate(it_->block()->block->re_rotation());
*x1 = startpt.x() / scale_ + rect_left_;
*y1 = (rect_height_ - startpt.y()) / scale_ + rect_top_;
*x2 = endpt.x() / scale_ + rect_left_;
*y2 = (rect_height_ - endpt.y()) / scale_ + rect_top_;
return true;
}