Assets/Watson/Scripts/Services/VisualRecognition/VisualRecognition.cs
/// <summary>
/// Find Similar Images by image path.
/// </summary>
/// <param name="callback">The callback.</param>
/// <param name="collectionID">The identifier of the collection to add images to.</param>
/// <param name="imagePath">The path in the filesystem of the image to query.</param>
/// <param name="limit">The number of similar results you want returned. Default limit is 10 results, you can specify a maximum limit of 100 results.</param>
/// <param name="customData">Optional custom data.</param>
/// <returns>Returns true if succeess, false if failure.</returns>
Find Similar Images by image path.
Find Similar Images by image path .
public bool FindSimilar(OnFindSimilar callback, string collectionID, string imagePath, int limit = 10, string customData = null)
        {
            if (callback == null)
                throw new ArgumentNullException("callback");
            if (string.IsNullOrEmpty(collectionID))
                throw new ArgumentNullException("collectionID");
            if (string.IsNullOrEmpty(imagePath))
                throw new ArgumentNullException("imagePath");
            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 (!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 FindSimilar(callback, collectionID, imageData, limit, customData);
        }
public bool FindSimilar ( OnFindSimilar callback , string collectionID , string imagePath , int limit = 10 , string customData = null ) { if ( callback == null ) throw new ArgumentNullException ( " " ) ; if ( string . IsNullOrEmpty ( collectionID ) ) throw new ArgumentNullException ( " " ) ; 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 ( ! 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 FindSimilar ( callback , collectionID , imageData , limit , customData ) ; }
Find Similar Images by image path.
Find Similar Images by image path .
Returns true if succeess, false if failure.
Returns true if succeess false if failure .
callback
OnFindSimilar
None
collectionID
string
The identifier of the collection to add images to.
The identifier of the collection to add images to .
imagePath
string
The path in the filesystem of the image to query.
The path in the filesystem of the image to query .
limit
int
The number of similar results you want returned. Default limit is 10 results, you can specify a maximum limit of 100 results.
The number of similar results you want returned . Default limit is 10 results you can specify a maximum limit of 100 results .
customData
string
Optional custom data.
Optional custom data .