Assets/Watson/Scripts/Services/VisualRecognition/VisualRecognition.cs
/// <summary>
/// Recognizes text in image bytedata.
/// </summary>
/// <param name="callback">Callback.</param>
/// <param name="imageData">Image's byte array data.</param>
/// <param name="customData">Custom data.</param>
/// <returns></returns>
Recognizes text in image bytedata.
Recognizes text in image bytedata .
public bool RecognizeText(OnRecognizeText callback, byte[] imageData = default(byte[]), string customData = default(string))
        {
            if (string.IsNullOrEmpty(mp_ApiKey))
                mp_ApiKey = Config.Instance.GetAPIKey(SERVICE_ID);
            if (string.IsNullOrEmpty(mp_ApiKey))
                throw new WatsonException("No API Key was found!");
            if (callback == null)
                throw new ArgumentNullException("callback");
            if (imageData == null)
                throw new ArgumentNullException("Image data is required to RecognizeText!");
            RESTConnector connector = RESTConnector.GetConnector(SERVICE_ID, SERVICE_RECOGNIZE_TEXT);
            if(connector == null)
                return false;
            RecognizeTextReq req = new RecognizeTextReq();
            req.Callback = callback;
            req.Data = customData;
            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);
        }
public bool RecognizeText ( OnRecognizeText callback , byte [ ] imageData = default ( byte [ ] ) , string customData = default ( string ) ) { if ( string . IsNullOrEmpty ( mp_ApiKey ) ) mp_ApiKey = Config . Instance . GetAPIKey ( SERVICE_ID ) ; if ( string . IsNullOrEmpty ( mp_ApiKey ) ) throw new WatsonException ( " " ) ; if ( callback == null ) throw new ArgumentNullException ( " " ) ; if ( imageData == null ) throw new ArgumentNullException ( " " ) ; RESTConnector connector = RESTConnector . GetConnector ( SERVICE_ID , SERVICE_RECOGNIZE_TEXT ) ; if ( connector == null ) return false ; RecognizeTextReq req = new RecognizeTextReq ( ) ; req . Callback = callback ; req . Data = customData ; req . Timeout = REQUEST_TIMEOUT ; req . OnResponse = OnRecognizeTextResp ; req . Parameters [ " " ] = mp_ApiKey ; req . Parameters [ " " ] = VisualRecognitionVersion . Version ; if ( imageData != null ) req . Send = imageData ; return connector . Send ( req ) ; }
Recognizes text in image bytedata.
Recognizes text in image bytedata .
None
callback
OnRecognizeText
None
imageData
byte[]
Image's byte array data.
Image ' s byte array data .
customData
string
None