Assets/Watson/Scripts/Services/VisualRecognition/VisualRecognition.cs
/// <summary>
/// Detects faces in a jpg, gif, png or zip file.
/// </summary>
/// <returns><c>true</c>, if faces was detected, <c>false</c> otherwise.</returns>
/// <param name="callback">Callback.</param>
/// <param name="imagePath">Image path.</param>
/// <param name="customData">Custom data.</param>
Detects faces in a jpg, gif, png or zip file.
Detects faces in a jpg gif png or zip file .
public bool DetectFaces(string imagePath, OnDetectFaces callback, string customData = default(string))
        {
            if(string.IsNullOrEmpty(imagePath))
                throw new ArgumentNullException("Define an image path to classify!");
            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!");
            byte[] imageData = null;
            if(imagePath != default(string))
            {
                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 DetectFaces(callback, imageData, customData);
        }
public bool DetectFaces ( string imagePath , OnDetectFaces callback , string customData = default ( string ) ) { if ( string . IsNullOrEmpty ( imagePath ) ) throw new ArgumentNullException ( " " ) ; if ( string . IsNullOrEmpty ( mp_ApiKey ) ) mp_ApiKey = Config . Instance . GetAPIKey ( SERVICE_ID ) ; if ( string . IsNullOrEmpty ( mp_ApiKey ) ) throw new WatsonException ( " " ) ; byte [ ] imageData = null ; if ( imagePath != default ( string ) ) { if ( LoadFile != null ) { imageData = LoadFile ( imagePath ) ; } else { if ! UNITY_WEBPLAYER imageData = File . ReadAllBytes ( imagePath ) ; endif } if ( imageData == null ) Log . Error ( " " , " " , imagePath ) ; } return DetectFaces ( callback , imageData , customData ) ; }
Detects faces in a jpg, gif, png or zip file.
Detects faces in a jpg gif png or zip file .
None
imagePath
string
None
callback
OnDetectFaces
None
customData
string
None