public void ToStringMultibyte() { const string value = "OpenCV"; using var s = new StdString(value); Assert.Equal(value, s.ToString()); }
/// <summary> /// Recognize text using the tesseract-ocr API. /// Takes image on input and returns recognized text in the output_text parameter. /// Optionally provides also the Rects for individual text elements found(e.g.words), /// and the list of those text elements with their confidence values. /// </summary> /// <param name="image">Input image CV_8UC1 or CV_8UC3</param> /// <param name="outputText">Output text of the tesseract-ocr.</param> /// <param name="componentRects">If provided the method will output a list of Rects for the individual /// text elements found(e.g.words or text lines).</param> /// <param name="componentTexts">If provided the method will output a list of text strings for the /// recognition of individual text elements found(e.g.words or text lines).</param> /// <param name="componentConfidences">If provided the method will output a list of confidence values /// for the recognition of individual text elements found(e.g.words or text lines).</param> /// <param name="componentLevel">OCR_LEVEL_WORD (by default), or OCR_LEVEL_TEXT_LINE.</param> public override void Run( Mat image, out string outputText, out Rect[] componentRects, out string?[] componentTexts, out float[] componentConfidences, ComponentLevels componentLevel = ComponentLevels.Word) { if (image == null) { throw new ArgumentNullException(nameof(image)); } image.ThrowIfDisposed(); using var outputTextString = new StdString(); using var componentRectsVector = new VectorOfRect(); using var componentTextsVector = new VectorOfString(); using var componentConfidencesVector = new VectorOfFloat(); NativeMethods.HandleException( NativeMethods.text_OCRTesseract_run1( ptr, image.CvPtr, outputTextString.CvPtr, componentRectsVector.CvPtr, componentTextsVector.CvPtr, componentConfidencesVector.CvPtr, (int)componentLevel)); outputText = outputTextString.ToString(); componentRects = componentRectsVector.ToArray(); componentTexts = componentTextsVector.ToArray(); componentConfidences = componentConfidencesVector.ToArray(); GC.KeepAlive(this); GC.KeepAlive(image); }
public void ToStringSinglebyte() { const string value = "https://www.amazon.co.jp/"; using var s = new StdString(value); Assert.Equal(value, s.ToString()); }
private string GetName() { StdString name = StdString.Create(); Looper.GetName(Pointer, name.Pointer); return(name.ToString()); }
/// <summary> /// /// </summary> /// <param name="key"></param> /// <param name="defaultVal"></param> /// <returns></returns> public string GetString(string key, string?defaultVal = null) { using var result = new StdString(); NativeMethods.HandleException( NativeMethods.flann_IndexParams_getString(ptr, key, defaultVal, result.CvPtr)); GC.KeepAlive(this); return(result.ToString()); }
public static void Deserialize(this IDictionary <string, LossMulticlassLogPerPixel> maps, ProxyDeserialize deserialize, int networkType = 0) { if (deserialize == null) { throw new ArgumentNullException(nameof(deserialize)); } deserialize.ThrowIfDisposed(); var keys = IntPtr.Zero; var values = IntPtr.Zero; try { var error = NativeMethods.LossMulticlassLogPerPixel_deserialize_proxy_map(networkType, deserialize.NativePtr, out keys, out values, out var size, out var errorMessage); Dnn.Cuda.ThrowCudaException(error); switch (error) { case NativeMethods.ErrorType.DnnNotSupportNetworkType: throw new NotSupportNetworkTypeException(networkType); case NativeMethods.ErrorType.GeneralSerialization: throw new SerializationException(StringHelper.FromStdString(errorMessage, true)); } for (var i = 0; i < size; i++) { var key = IntPtr.Add(keys, IntPtr.Size * i); var value = IntPtr.Add(values, IntPtr.Size * i); key = Marshal.ReadIntPtr(key); value = Marshal.ReadIntPtr(value); using (var stdString = new StdString(key)) { var str = stdString.ToString(); var net = new LossMulticlassLogPerPixel(value, networkType); maps.Add(str, net); } } } finally { if (keys != IntPtr.Zero) { NativeMethods.stdlib_free(keys); } if (values != IntPtr.Zero) { NativeMethods.stdlib_free(values); } } }
public void ToStringSinglebyte() { const string value = "foo"; using (var s = new StdString(value)) { Assert.Equal(value, s.ToString()); } }
/// <summary> /// Dump net to String. /// Call method after setInput(). To see correct backend, target and fusion run after forward(). /// </summary> /// <returns>String with structure, hyperparameters, backend, target and fusion</returns> public string Dump() { ThrowIfDisposed(); using var stdString = new StdString(); NativeMethods.HandleException( NativeMethods.dnn_Net_dump(ptr, stdString.CvPtr)); GC.KeepAlive(this); return(stdString.ToString()); }
public unsafe byte ProcessChatInput_Hook(IntPtr pThis, IntPtr pWindow, IntPtr pCmdText) { StdString tokenized = StdString.Create(); ChatGUIModule_t.ExpandChatTextArgs(tokenized.Pointer, pCmdText); _lastChatInput = tokenized.ToString(); _lastChatInputWindowPtr = pWindow; return(CommandInterpreter_c.ProcessChatInput(pThis, pWindow, pCmdText)); }
/// <summary> /// Gets string information by label. /// If an unknown label id is provided or there is no label information associated with the specified /// label id the method returns an empty string. /// </summary> /// <param name="label"></param> /// <returns></returns> public string GetLabelInfo(int label) { ThrowIfDisposed(); using var resultString = new StdString(); NativeMethods.HandleException( NativeMethods.face_FaceRecognizer_getLabelInfo(ptr, label, resultString.CvPtr)); GC.KeepAlive(this); return(resultString.ToString()); }
/// <summary> /// Returns the scale factor of the model /// </summary> /// <returns>Current algorithm.</returns> public string GetAlgorithm() { ThrowIfDisposed(); using var result = new StdString(); NativeMethods.HandleException( NativeMethods.dnn_superres_DnnSuperResImpl_getAlgorithm( ptr, result.CvPtr)); GC.KeepAlive(this); return(result.ToString()); }