private void OnGetClassifier(GetClassifiersPerClassifierVerbose classifier) { if (Callback != null) { Callback(classifier); } }
private void OnGetClassifierResp(RESTConnector.Request req, RESTConnector.Response resp) { GetClassifiersPerClassifierVerbose classifier = new GetClassifiersPerClassifierVerbose(); if (resp.Success) { try { fsData data = null; fsResult r = fsJsonParser.Parse(Encoding.UTF8.GetString(resp.Data), out data); if (!r.Succeeded) { throw new WatsonException(r.FormattedMessages); } object obj = classifier; r = sm_Serializer.TryDeserialize(data, obj.GetType(), ref obj); if (!r.Succeeded) { throw new WatsonException(r.FormattedMessages); } } catch (Exception e) { Log.Error("Visual Recognition", "GetClassifier Exception: {0}", e.ToString()); resp.Success = false; } } if (((GetClassifierReq)req).Callback != null) { ((GetClassifierReq)req).Callback(resp.Success ? classifier : null); } }
private void OnCheckService(GetClassifiersPerClassifierVerbose classifier) { if (m_GetClassifierCount > 0) { m_GetClassifierCount -= 1; if (classifier != null) { Log.Debug("VisualRecognition", "classifier status: {0}", classifier.status); if (classifier.status == "unavailable" || classifier.status == "failed") { Log.Debug("VisualRecognition", "Status of classifier {0} came back as {1}.", classifier.classifier_id, classifier.status); } else { // try to classify something with this classifier. if (!m_Service.Classify("https://upload.wikimedia.org/wikipedia/commons/e/e9/Official_portrait_of_Barack_Obama.jpg", OnClassify)) { Log.Debug("VisualRecognition", "Failed to invoke Classify!"); } else { m_ClassifyCount += 1; } } } else { OnFailure("Failed to get classifier."); } } }