I'm trying to train/create my own classifier, I attached this code to main camera and I didn't got any response from the console nor getting any errors. Or I just doing it the wrong way?
public class VisualRecog : MonoBehaviour{
private VisualRecognition m_VisualRecognition = new VisualRecognition();
void Start()
{
string m_positiveExamplesPath = Application.dataPath + "/testData/cpu_positive_examples.zip";
string m_negativeExamplesPath = Application.dataPath + "/testData/negative_examples.zip";
Dictionary<string, string> positiveExamples = new Dictionary<string, string>();
positiveExamples.Add("cpu", m_positiveExamplesPath);
if (!m_VisualRecognition.TrainClassifier(OnTrainClassifier, "compClassifier", positiveExamples, m_negativeExamplesPath))
Log.Debug("ExampleVisualRecognition", "Train classifier failed!");
}
private void OnTrainClassifier(GetClassifiersPerClassifierVerbose classifier, string data)
{
if (classifier != null)
{
Log.Debug("ExampleVisualRecognition", "Classifier is training! " + classifier);
}
else
{
Log.Debug("ExampleVisualRecognition", "Failed to train classifier!");
}
}
}
by the way here is the link of the Unity SDK. Thanks!
If
m_positiveExamplesPathandm_negativeExamplesPathare not valid path, you will get exception that says:If your did not setup your credentials then you will get the error:
Those two problems are eliminated .
It takes about
10seconds to get a reply from IBM server when you run this code. Please wait for at-least15seconds for a reply. The wait time actually depends on how big your cpu_positive_examples.zip and negative_examples.zip files are. Sometimes, it can take few minutes.The problem is from the
Logfunction. If you look closely, you will realize that IBM is usingLog.Debuginstead ofDebug.Log. IBM'sLog.Debugcomes from theIBM.Watson.DeveloperCloud.Loggingnamespace and it doesn't show in the Editor Console tab. I can't tell if this is a bug or a feature but replacing all theLog.DebugwithDebug.Logshould fix your problem.I got a reply with the code below within 10 seconds(Used
Debug.Log):