private bool RecognizeText(OnRecognizeText callback, string imagePath, byte[] imageData = default(byte[])) { RESTConnector connector = RESTConnector.GetConnector(SERVICE_ID, SERVICE_RECOGNIZE_TEXT); if (connector == null) { return(false); } RecognizeTextReq req = new RecognizeTextReq(); req.Callback = callback; req.Timeout = REQUEST_TIMEOUT; req.OnResponse = OnRecognizeTextResp; req.Parameters["api_key"] = mp_ApiKey; req.Parameters["version"] = VisualRecognitionVersion.Version; if (imageData != null) { req.Send = imageData; } return(connector.Send(req)); }
/// <summary> /// Recognizes text given an image url. /// </summary> /// <returns><c>true</c>, if text was recognized, <c>false</c> otherwise.</returns> /// <param name="url">URL.</param> /// <param name="callback">Callback.</param> public bool RecognizeText(string url, OnRecognizeText callback) { if (string.IsNullOrEmpty(url)) { throw new ArgumentNullException("url"); } if (callback == null) { throw new ArgumentNullException("callback"); } if (string.IsNullOrEmpty(mp_ApiKey)) { mp_ApiKey = Config.Instance.GetAPIKey(SERVICE_ID); } if (string.IsNullOrEmpty(mp_ApiKey)) { throw new WatsonException("FindClassifier - VISUAL_RECOGNITION_API_KEY needs to be defined in config.json"); } RESTConnector connector = RESTConnector.GetConnector(SERVICE_ID, SERVICE_RECOGNIZE_TEXT); if (connector == null) { return(false); } RecognizeTextReq req = new RecognizeTextReq(); req.Callback = callback; req.OnResponse = OnRecognizeTextResp; req.Parameters["api_key"] = mp_ApiKey; req.Parameters["url"] = url; req.Parameters["version"] = VisualRecognitionVersion.Version; return(connector.Send(req)); }