Assets/Watson/Scripts/Services/VisualRecognition/VisualRecognition.cs
/// <summary>
/// Classifies an image from the file system.
/// </summary>
/// <param name="callback">Callback.</param>
/// <param name="imagePath">Image path.</param>
/// <param name="owners">Owners.</param>
/// <param name="classifierIDs">Classifier I ds.</param>
/// <param name="threshold">Threshold.</param>
/// <param name="acceptLanguage">Accept language.</param>
/// <param name="customData">Custom data.</param>
Classifies an image from the file system.
Classifies an image from the file system .
public bool Classify(string imagePath, OnClassify callback, 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(string.IsNullOrEmpty(imagePath))
                throw new ArgumentNullException("Define an image path to classify!");
            byte[] imageData = null;
            if(!string.IsNullOrEmpty(imagePath))
            {
                if(LoadFile != null)
                {
                    imageData = LoadFile(imagePath);
                }
                else
                {
                    #if !UNITY_WEBPLAYER
                    imageData = File.ReadAllBytes(imagePath);
                    #endif
                }
                if(imageData == null)
                    Log.Error("VisualRecognition", "Failed to upload {0}!", imagePath);
            }
            return Classify(callback, imageData, owners, classifierIDs, threshold, acceptLanguage);
        }
public bool Classify ( string imagePath , OnClassify callback , 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 ( string . IsNullOrEmpty ( imagePath ) ) throw new ArgumentNullException ( " " ) ; byte [ ] imageData = null ; if ( ! string . IsNullOrEmpty ( imagePath ) ) { if ( LoadFile != null ) { imageData = LoadFile ( imagePath ) ; } else { if ! UNITY_WEBPLAYER imageData = File . ReadAllBytes ( imagePath ) ; endif } if ( imageData == null ) Log . Error ( " " , " " , imagePath ) ; } return Classify ( callback , imageData , owners , classifierIDs , threshold , acceptLanguage ) ; }
Classifies an image from the file system.
Classifies an image from the file system .
imagePath
string
None
callback
OnClassify
None
owners
string[]
None
classifierIDs
string[]
Classifier I ds.
Classifier I ds .
threshold
float
None
acceptLanguage
string
None
customData
string
None