/// <summary> /// Returns the null terminated UTF-8 encoded text string for the current choice /// </summary> /// <remarks> /// NOTE: Unlike LTRResultIterator::GetUTF8Text, the return points to an /// internal structure and should NOT be delete[]ed to free after use. /// </remarks> /// <param name="choiceIteratorHandle"></param> /// <returns>string</returns> internal static string ChoiceIteratorGetUTF8Text(HandleRef choiceIteratorHandle) { Guard.Require("choiceIteratorHandle", choiceIteratorHandle.Handle != IntPtr.Zero, "ChoiceIterator Handle cannot be a null IntPtr and is required"); IntPtr txtChoiceHandle = Native.ChoiceIteratorGetUTF8TextInternal(choiceIteratorHandle); return(MarshalHelper.PtrToString(txtChoiceHandle, Encoding.UTF8)); }
public static string BaseApiGetStringVariable(HandleRef handle, string name) { var resultHandle = Native.BaseApiGetStringVariableInternal(handle, name); if (resultHandle != IntPtr.Zero) { return(MarshalHelper.PtrToString(resultHandle, Encoding.UTF8)); } return(null); }
public static string ResultIteratorWordRecognitionLanguage(HandleRef handle) { // per docs (ltrresultiterator.h:118 as of 4897796 in github:tesseract-ocr/tesseract) // this return value should *NOT* be deleted. IntPtr txtHandle = Native.ResultIteratorWordRecognitionLanguageInternal(handle); return(txtHandle != IntPtr.Zero ? MarshalHelper.PtrToString(txtHandle, Encoding.UTF8) : null); }
public static string BaseApiGetVersion() { IntPtr versionHandle = Native.GetVersion(); if (versionHandle != IntPtr.Zero) { var result = MarshalHelper.PtrToString(versionHandle, Encoding.UTF8); return(result); } return(null); }
public static string ResultIteratorGetUTF8Text(HandleRef handle, PageIteratorLevel level) { var txtHandle = Native.ResultIteratorGetUTF8TextInternal(handle, level); if (txtHandle != IntPtr.Zero) { var result = MarshalHelper.PtrToString(txtHandle, Encoding.UTF8); Native.DeleteText(txtHandle); return(result); } return(null); }
public static string BaseAPIGetHOCRText(HandleRef handle, int pageNum) { var txtHandle = Native.BaseAPIGetHOCRTextInternal(handle, pageNum); if (txtHandle != IntPtr.Zero) { var result = MarshalHelper.PtrToString(txtHandle, Encoding.UTF8); Native.DeleteText(txtHandle); return(htmlBeginTag + result + htmlEndTag); } return(null); }
public static string BaseAPIGetUTF8Text(HandleRef handle) { var txtHandle = Native.BaseAPIGetUTF8TextInternal(handle); if (txtHandle != IntPtr.Zero) { var result = MarshalHelper.PtrToString(txtHandle, Encoding.UTF8); Native.DeleteText(txtHandle); return(result); } return(null); }
public static string BaseAPIGetWordStrBoxText(HandleRef handle, int pageNum) { IntPtr txtHandle = Native.BaseApiGetWordStrBoxTextInternal(handle, pageNum); if (txtHandle != IntPtr.Zero) { var result = MarshalHelper.PtrToString(txtHandle, Encoding.UTF8); TessApi.Native.DeleteText(txtHandle); return(result); } else { return(null); } }
public static string ResultIteratorGetUTF8Text(IntPtr handle, PageIteratorLevel level) { IntPtr txtHandle = ResultIteratorGetUTF8TextInternal(handle, level); if (txtHandle != IntPtr.Zero) { var result = MarshalHelper.PtrToString(txtHandle, Encoding.UTF8); TessApi.DeleteText(txtHandle); return(result); } else { return(null); } }
public static string BaseAPIGetHOCRText(IntPtr handle, int pageNum) { IntPtr txtHandle = BaseAPIGetHOCRTextInternal(handle, pageNum); if (txtHandle != IntPtr.Zero) { var result = MarshalHelper.PtrToString(txtHandle, Encoding.UTF8); TessApi.DeleteText(txtHandle); return(htmlBeginTag + result + htmlEndTag); } else { return(null); } }
public static string BaseAPIGetUTF8Text(IntPtr handle) { IntPtr txtHandle = BaseAPIGetUTF8TextInternal(handle); if (txtHandle != IntPtr.Zero) { var result = MarshalHelper.PtrToString(txtHandle, Encoding.UTF8); TessApi.DeleteText(txtHandle); return(result); } else { return(null); } }
public static string ResultIteratorGetWordRecognitionLanguage(HandleRef handle) { IntPtr txtHandle = Native.ResultIteratorGetWordRecognitionLanguageInternal(handle); if (txtHandle != IntPtr.Zero) { var result = MarshalHelper.PtrToString(txtHandle, Encoding.UTF8); // txtHandle must not be deleted, see method WordRecognistionLanguage // in tesseract/ccmain/ltrresultiterator.h. return(result); } else { return(null); } }
public static string ResultIteratorGetWordFontAttributes(HandleRef handle, out bool isBold, out bool isItalic, out bool isUnderlined, out bool isMonospace, out bool isSerif, out bool isSmallCaps, out int pointSize, out int fontId) { int bold, italic, underlined, monospace, serif, smallCaps; IntPtr txtHandle = Native.ResultIteratorGetWordFontAttributesInternal(handle, out bold, out italic, out underlined, out monospace, out serif, out smallCaps, out pointSize, out fontId); if (txtHandle != IntPtr.Zero) { var result = MarshalHelper.PtrToString(txtHandle, Encoding.UTF8); // txtHandle must not be deleted, see method WordFontAttributes // in tesseract/ccmain/ltrresultiterator.h. isBold = Convert.ToBoolean(bold); isItalic = Convert.ToBoolean(italic); isUnderlined = Convert.ToBoolean(underlined); isMonospace = Convert.ToBoolean(monospace); isSerif = Convert.ToBoolean(serif); isSmallCaps = Convert.ToBoolean(smallCaps); return(result); } else { isBold = false; isItalic = false; isUnderlined = false; isMonospace = false; isSerif = false; isSmallCaps = false; pointSize = 0; fontId = -1; return(null); } }
internal static string getLeptonicaVersion() { return(MarshalHelper.PtrToString(getLeptonicaVersionInternal())); }
internal static string BaseApiGetStringVariable(HandleRef handle, string name) { return(MarshalHelper.PtrToString(BaseApiGetStringVariableInternal(handle, name))); // return string cannot be deleted, it comes from a c_str call. }
internal static extern IntPtr ChoiceIteratorGetUTF8TextInternal(HandleRef handle); // Returns internal memory internal static string ChoiceIteratorGetUTF8Text(HandleRef handle) { return(MarshalHelper.PtrToString(ChoiceIteratorGetUTF8TextInternal(handle))); }
internal static string GetVersion() { return(MarshalHelper.PtrToString(GetVersionInternal())); // Do not free as it is a constant on the stack }