예제 #1
0
void logEmoState(std::ostream& os, unsigned int userID,
                 EmoStateHandle eState, bool withHeader) {

	// Create the top header
	if (withHeader) {
		os << "Time,";
		os << "UserID,";
		os << "Wireless Signal Status,";
		os << "Blink,";
		os << "Wink Left,";
		os << "Wink Right,";
		os << "Surprise,";
		os << "Frown,";
		os << "Smile,";
		os << "Clench,";
		os << "Instantaneous Excitement,";
		os << "Long Term Excitement,";
		os << "Engagement/Boredom,";
		os << "MentalCommand Action,";
		os << "MentalCommand Power,";
		os << std::endl;
	}

	// Log the time stamp and user ID
	os << IS_GetTimeFromStart(eState) << ",";
	os << userID << ",";
	os << static_cast<int>(IS_GetWirelessSignalStatus(eState)) << ",";

	// FacialExpression Suite results
	os << IS_FacialExpressionIsBlink(eState) << ",";
	os << IS_FacialExpressionIsLeftWink(eState) << ",";
	os << IS_FacialExpressionIsRightWink(eState) << ",";



	std::map<IEE_FacialExpressionAlgo_t, float> expressivStates;

    IEE_FacialExpressionAlgo_t upperFaceAction =
            IS_FacialExpressionGetUpperFaceAction(eState);
    float upperFacePower  = IS_FacialExpressionGetUpperFaceActionPower(eState);

    IEE_FacialExpressionAlgo_t lowerFaceAction =
            IS_FacialExpressionGetLowerFaceAction(eState);
    float	lowerFacePower  = IS_FacialExpressionGetLowerFaceActionPower(eState);

	expressivStates[ upperFaceAction ] = upperFacePower;
	expressivStates[ lowerFaceAction ] = lowerFacePower;
	
	os << expressivStates[ FE_SURPRISE     ] << ","; // eyebrow
	os << expressivStates[ FE_FROWN      ] << ","; // furrow
	os << expressivStates[ FE_SMILE       ] << ","; // smile
	os << expressivStates[ FE_CLENCH      ] << ","; // clench

	// MentalCommand Suite results
	os << static_cast<int>(IS_MentalCommandGetCurrentAction(eState)) << ",";
	os << IS_MentalCommandGetCurrentActionPower(eState);

	os << std::endl;
}
void sendFacialExpressionAnimation(SocketClient& sock, EmoStateHandle eState) {

	std::ostringstream output;

    IEE_FacialExpressionAlgo_t upperFaceType =
                            IS_FacialExpressionGetUpperFaceAction(eState);
    IEE_FacialExpressionAlgo_t lowerFaceType =
                            IS_FacialExpressionGetLowerFaceAction(eState);

	float upperFaceAmp = IS_FacialExpressionGetUpperFaceActionPower(eState);
	float lowerFaceAmp = IS_FacialExpressionGetLowerFaceActionPower(eState);

	if (IS_FacialExpressionIsBlink(eState)) {
		output << "B,";
	}

	if (IS_FacialExpressionIsLeftWink(eState)) {
		output << "l,";
	}

	if (IS_FacialExpressionIsRightWink(eState)) {
		output << "r,";
	}


	if (upperFaceAmp > 0.0) {
		switch (upperFaceType) {
			case FE_SURPRISE:	output << "b";	break;
			case FE_FROWN:    output << "f";  break;
			default:			break;
		}
		output << numberToString(static_cast<int>(upperFaceAmp*100.0f)) << ",";
	}

	if (lowerFaceAmp > 0.0) {
		switch (lowerFaceType) {
			case FE_CLENCH:	output << "G";	break;
			case FE_SMILE:		output << "S";	break;
			default:			break;
		}
		output << numberToString(static_cast<int>(lowerFaceAmp*100.0f)) << ",";
	}

	std::string outString = output.str();

	// Remove the last comma
	if (outString.length()) {
		outString.resize(outString.length()-1);
	}

	if (!outString.length()) {
		outString = std::string("neutral");
	}

	sock.SendBytes(outString);
}