Esempio n. 1
0
// char* TessResultIteratorGetUTF8Text(const TessResultIterator* handle, TessPageIteratorLevel level);
func (r *ResultIterator) Text(level PageIteratorLevel) (string, error) {
	cText := C.TessResultIteratorGetUTF8Text(r.ri, C.TessPageIteratorLevel(level))
	if cText == nil {
		return "", errors.New("already at the end")
	}
	defer C.free(unsafe.Pointer(cText))
	text := C.GoString(cText)
	return text, nil
}
Esempio n. 2
0
func GetWord(ri *C.struct_TessResultIterator) TessWord {
	cWord := C.TessResultIteratorGetUTF8Text(ri, C.RIL_WORD)
	// TESS_API const char* TESS_CALL
	// TessResultIteratorWordFontAttributes(const TessResultIterator* handle,
	// BOOL* is_bold, BOOL* is_italic, BOOL* is_underlined,
	// BOOL* is_monospace, BOOL* is_serif, BOOL* is_smallcaps, int* pointsize, int* font_id);
	is_bold := C.BOOL(0)
	is_italic := C.BOOL(0)
	is_underlined := C.BOOL(0)
	is_monospace := C.BOOL(0)
	is_serif := C.BOOL(0)
	is_smallcaps := C.BOOL(0)
	pointsize := C.int(0)
	font_id := C.int(0)

	font_name := C.TessResultIteratorWordFontAttributes(ri, &is_bold, &is_italic, &is_underlined, &is_monospace, &is_serif, &is_smallcaps, &pointsize, &font_id)
	conf := C.TessResultIteratorConfidence(ri, C.RIL_WORD)

	return TessWord{C.GoString(cWord), float32(conf), B(is_bold), B(is_italic), B(is_underlined), B(is_monospace), B(is_serif), B(is_smallcaps), int(pointsize), int(font_id), C.GoString(font_name)}
}