private IEnumerator HandleIt() { if (label.Length > 1) { audioSource.clip = Resources.Load("imageNetSounds/" + label) as AudioClip; audioSource.Play(); messageBehavior.ShowMessage(label); label = ""; yield return(new WaitForSeconds(1.0f)); label = ""; } }
void ProcessImage() { //pass in input tensor var tensor = TransformInput(camFeed.GetImage(), INPUT_SIZE, INPUT_SIZE); var runner = session.GetRunner(); runner.AddInput(graph [INPUT_TENSOR] [0], tensor).Fetch(graph [OUTPUT_TENSOR] [0]); var output = runner.Run(); //put results into one dimensional array float[] probs = ((float [] [])output[0].GetValue(jagged: true)) [0]; //get max value of probabilities and find its associated label index float maxValue = probs.Max(); int maxIndex = probs.ToList().IndexOf(maxValue); //print label with highest probability string label = labels [maxIndex]; print(label); audioSource.clip = Resources.Load("imageNetSounds/" + label) as AudioClip; audioSource.Play(); messageBehavior.ShowMessage(label); }
IEnumerator Post(string url, string bodyJsonString) { var request = new UnityWebRequest(url, "POST"); byte[] bodyRaw = Encoding.UTF8.GetBytes(bodyJsonString); request.uploadHandler = (UploadHandler) new UploadHandlerRaw(bodyRaw); request.downloadHandler = (DownloadHandler) new DownloadHandlerBuffer(); request.SetRequestHeader("Content-Type", "application/json"); yield return(request.SendWebRequest()); //messageBehavior.ShowMessage(request.downloadHandler.text.ToString()); //Debug.Log("Status Code: " + request.responseCode); //Debug.Log(request.downloadHandler.text.ToString()); fromServer = request.downloadHandler.text.ToString(); switch (fromServer.Split('"')[1]) { case "amenity": messageBehavior.ShowMessage("Student Amenity Centre"); PlaceModel(StudentAmenityCenter, DetailStudentAmenityCenter); PlayAudio(AudioStudentAmenityCenter); break; case "budget": messageBehavior.ShowMessage("Center For Budget Studies"); PlaceModel(Budget_Studies, DetailBudget_Studies); PlayAudio(AudioBudget_Studies); break; case "engscience": messageBehavior.ShowMessage("Engineering Sciences"); PlaceModel(Engineering_Sciences, DetailEngineering_Sciences); PlayAudio(AudioEngineering_Sciences); break; case "library": messageBehavior.ShowMessage("University Library"); PlaceModel(Library, DetailLibrary); PlayAudio(AudioLibrary); break; case "oldsoe": messageBehavior.ShowMessage("Old SOE Block"); PlaceModel(Old_SOE, DetailOld_SOE); PlayAudio(AudioOld_SOE); break; case "photonics": messageBehavior.ShowMessage("International School Of Photonics"); PlaceModel(Photonics, DetailPhotonics); PlayAudio(AudioPhotonics); break; case "postoffice": messageBehavior.ShowMessage("CUSAT Post Office"); PlaceModel(PostOffice, DetailPostOffice); PlayAudio(AudioPostOffice); break; case "scipark": messageBehavior.ShowMessage("C-SIS Science Park"); PlayAudio(AudioCSiS); vid.SetActive(true); btnclos.SetActive(true); PlaceModel(CSiS, DetailCSiS); break; default: messageBehavior.ShowMessage("Try Again !!!"); break; } }