IEnumerator TestClient() { yield return(null); // new WaitForSeconds(1f); try{ // Test POC AWS client AWSClient awsClient = AWSClientObject.GetComponent <AWSClient>(); string streamName = "AmazonRekognitionStreamOut"; awsClient.ReadStream(streamName, (response) => { List <Amazon.Kinesis.Model.Record> records = response.Records; foreach (Amazon.Kinesis.Model.Record awsRecord in records) { try{ string recordString = Encoding.ASCII.GetString(awsRecord.Data.ToArray()); Rekog.Record record = Rekog.Record.Deserialize(recordString); // Debug.Log(record); if (record.rekog_face_details.Count > 0) { printAge(record.rekog_face_details[0].AgeRange.Low, record.rekog_face_details[0].AgeRange.High); printGender(record.rekog_face_details[0].Gender.Value, record.rekog_face_details[0].Gender.Confidence); emotionStr = ""; foreach (Rekog.Emotion emotion in record.rekog_face_details[0].Emotions) { string s = printEmotion(emotion.Type, emotion.Confidence); emotionStr = emotionStr + s; } //emotionText.text = emotionStr; //printConfidence(record.rekog_face_details[0].Mustache.Confidence, record.rekog_face_details[0].Mustache.Value,mustacheText); //printConfidence(record.rekog_face_details[0].Beard.Confidence,record.rekog_face_details[0].Beard.Value ,beardText); //printConfidence(record.rekog_face_details[0].Eyeglasses.Confidence, record.rekog_face_details[0].Eyeglasses.Value, glassesText); } } catch (Exception e) { HandleError(e); } } }); } catch (Exception e) { HandleError(e); } }
IEnumerator ReadKinesisStream() { yield return(null); try{ awsClient.ReadStream(streamName, (response) => { List <Amazon.Kinesis.Model.Record> records = response.Records; foreach (Amazon.Kinesis.Model.Record awsRecord in records) { try{ if (stopPrinting) { return; } string recordString = Encoding.ASCII.GetString(awsRecord.Data.ToArray()); Rekog.Record record = Rekog.Record.Deserialize(recordString); if (record.rekog_face_details.Count > 0) { printAge(record.rekog_face_details[0].AgeRange.Low, record.rekog_face_details[0].AgeRange.High); printGender(record.rekog_face_details[0].Gender.Value, record.rekog_face_details[0].Gender.Confidence); emotionStr = ""; foreach (Rekog.Emotion emotion in record.rekog_face_details[0].Emotions) { string s = printEmotion(emotion.Type, emotion.Confidence); emotionStr = emotionStr + s; } emotionText.text = emotionStr; printConfidence(record.rekog_face_details[0].Mustache.Confidence, record.rekog_face_details[0].Mustache.Value, mustacheText); printConfidence(record.rekog_face_details[0].Beard.Confidence, record.rekog_face_details[0].Beard.Value, beardText); printConfidence(record.rekog_face_details[0].Eyeglasses.Confidence, record.rekog_face_details[0].Eyeglasses.Value, glassesText); } } catch (Exception e) { HandleError(e); } } }); }catch (Exception e) { HandleError(e); } }