Assets/Watson/Scripts/Services/VisualRecognition/VisualRecognition.cs
/// <summary>
/// Classifies an image using byte data.
/// </summary>
/// <param name="callback">Callback.</param>
/// <param name="imageData">Byte array of image data.</param>
/// <param name="owners">Owners.</param>
/// <param name="classifierIDs">An array of classifier identifiers.</param>
/// <param name="threshold">Threshold.</param>
/// <param name="acceptLanguage">Accepted language.</param>
/// <param name="customData">Custom data.</param>
/// <returns></returns>
Classifies an image using byte data.
Classifies an image using byte data .
public bool Classify(OnClassify callback, byte[] imageData, 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 (callback == null)
                throw new ArgumentNullException("callback");
            if (imageData == null)
                throw new ArgumentNullException("Image data is required to classify!");
            RESTConnector connector = RESTConnector.GetConnector(SERVICE_ID, SERVICE_CLASSIFY);
            if(connector == null)
                return false;
            ClassifyReq req = new ClassifyReq();
            req.Callback = callback;
            req.Data = customData;
            req.Timeout = REQUEST_TIMEOUT;
            req.OnResponse = OnClassifyResp;
            req.AcceptLanguage = acceptLanguage;
            req.Parameters["api_key"] = mp_ApiKey;
            req.Parameters["version"] = VisualRecognitionVersion.Version;
            req.Headers["Content-Type"] = "application/x-www-form-urlencoded";
            req.Headers["Accept-Language"] = acceptLanguage;
            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;
            if (imageData != null)
                req.Send = imageData; 
            return connector.Send(req);
        }
public bool Classify ( OnClassify callback , byte [ ] imageData , 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 ( callback == null ) throw new ArgumentNullException ( " " ) ; if ( imageData == 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 . Timeout = REQUEST_TIMEOUT ; req . OnResponse = OnClassifyResp ; req . AcceptLanguage = acceptLanguage ; req . Parameters [ " " ] = mp_ApiKey ; req . Parameters [ " " ] = VisualRecognitionVersion . Version ; req . Headers [ " " ] = " " ; req . Headers [ " " ] = acceptLanguage ; 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 ; if ( imageData != null ) req . Send = imageData ; return connector . Send ( req ) ; }
Classifies an image using byte data.
Classifies an image using byte data .
None
callback
OnClassify
None
imageData
byte[]
Byte array of image data.
Byte array of image data .
owners
string[]
None
classifierIDs
string[]
An array of classifier identifiers.
An array of classifier identifiers .
threshold
float
None
acceptLanguage
string
None
customData
string
None