Assets/Watson/Scripts/Services/VisualRecognition/VisualRecognition.cs
/// <summary>
/// Classifies image specified by URL.
/// </summary>
/// <param name="url">URL.</param>
/// <param name="callback">Callback.</param>
/// <param name="owners">Owners.</param>
/// <param name="classifierIDs">Classifier IDs to be classified against.</param>
/// <param name="threshold">Threshold.</param>
/// <param name="acceptLanguage">Accept language.</param>
/// <param name="customData">Custom data.</param>
Classifies image specified by URL.
Classifies image specified by URL .
public bool Classify(OnClassify callback, string url, string[] owners = default(string[]), string[] classifierIDs = default(string[]), float threshold = default(float), string acceptLanguage = "en", 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(string.IsNullOrEmpty(url))
                throw new ArgumentNullException("url");
            if(callback == null)
                throw new ArgumentNullException("callback");
            RESTConnector connector = RESTConnector.GetConnector(SERVICE_ID, SERVICE_CLASSIFY);
            if(connector == null)
                return false;
            ClassifyReq req = new ClassifyReq();
            req.Callback = callback;
            req.Data = customData;
            req.OnResponse = OnClassifyResp;
            req.Timeout = REQUEST_TIMEOUT;
            req.AcceptLanguage = acceptLanguage;
            req.Headers["Accepted-Language"] = acceptLanguage;
            req.Parameters["api_key"] = mp_ApiKey;
            req.Parameters["url"] = url;
            req.Parameters["version"] = VisualRecognitionVersion.Version;
            if(owners != default(string[]))
                req.Parameters["owners"] = string.Join(",", owners);
            if(classifierIDs != default(string[]))
                req.Parameters["classifier_ids"] = string.Join(",", classifierIDs);
            if(threshold != default(float))
                req.Parameters["threshold"] = threshold;
            return connector.Send(req);
        }
public bool Classify ( OnClassify callback , string url , string [ ] owners = default ( string [ ] ) , string [ ] classifierIDs = default ( string [ ] ) , float threshold = default ( float ) , string acceptLanguage = " " , 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 ( string . IsNullOrEmpty ( url ) ) throw new ArgumentNullException ( " " ) ; if ( callback == null ) throw new ArgumentNullException ( " " ) ; RESTConnector connector = RESTConnector . GetConnector ( SERVICE_ID , SERVICE_CLASSIFY ) ; if ( connector == null ) return false ; ClassifyReq req = new ClassifyReq ( ) ; req . Callback = callback ; req . Data = customData ; req . OnResponse = OnClassifyResp ; req . Timeout = REQUEST_TIMEOUT ; req . AcceptLanguage = acceptLanguage ; req . Headers [ " " ] = acceptLanguage ; req . Parameters [ " " ] = mp_ApiKey ; req . Parameters [ " " ] = url ; req . Parameters [ " " ] = VisualRecognitionVersion . Version ; if ( owners != default ( string [ ] ) ) req . Parameters [ " " ] = string . Join ( " " , owners ) ; if ( classifierIDs != default ( string [ ] ) ) req . Parameters [ " " ] = string . Join ( " " , classifierIDs ) ; if ( threshold != default ( float ) ) req . Parameters [ " " ] = threshold ; return connector . Send ( req ) ; }
Classifies image specified by URL.
Classifies image specified by URL .
callback
OnClassify
None
url
string
None
owners
string[]
None
classifierIDs
string[]
Classifier IDs to be classified against.
Classifier IDs to be classified against .
threshold
float
None
acceptLanguage
string
None
customData
string
None