From b38fd876b2efdddaae6a2cde6ee124596c9cb334 Mon Sep 17 00:00:00 2001 From: Umang Mehta Date: Thu, 14 Jul 2016 15:50:07 -0400 Subject: [PATCH] SDK-664: Updating the sample apps with x64 (#9) * SDK-664: Updating the sample apps with x64 * Adding the yml for configuration * Updating the travis yml * Updating the project files to remove duplicate entries of x64 * Updating the configurations * Updating the yml to publish the Artifacts and rebasing master * Updating the verbosity of yml * Fix enum definition of ethinicity to the latest build changes * Adding the new AU's * Updating the README to indicate that the app supports x64 * Update linux SDK link to 3.1-396 --- .travis.yml | 2 +- README.md | 4 +- affdex-win-samples.sln | 20 +- appveyor.yml | 22 + common/PlottingImageListener.hpp | 655 +++++++++--------- opencv-webcam-demo/opencv-webcam-demo.cpp | 3 +- opencv-webcam-demo/opencv-webcam-demo.vcxproj | 20 +- .../opencv-webcam-demo.vcxproj.user | 4 +- video-demo/video-demo.cpp | 3 +- video-demo/video-demo.vcxproj | 22 +- 10 files changed, 394 insertions(+), 361 deletions(-) create mode 100644 appveyor.yml diff --git a/.travis.yml b/.travis.yml index 07e56a4..06e4344 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ compiler: - gcc-4.8 before_script: - sudo apt-get install -y gcc-4.8 g++-4.8 libopencv-dev libboost1.55-all-dev cmake - - wget http://affdex-sdk-dist.s3-website-us-east-1.amazonaws.com/linux/download_sdk.html -O /tmp/affdex-sdk.tar.gz + - wget https://download.affectiva.com/linux/affdex-cpp-sdk-3.1-396-linux-64bit.tar.gz -O /tmp/affdex-sdk.tar.gz - mkdir /tmp/affdex-sdk - tar -xzvf /tmp/affdex-sdk.tar.gz -C /tmp/affdex-sdk - mkdir build diff --git a/README.md b/README.md index a312f14..3d514af 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ #Sample Apps for Affdex SDK for Windows and Linux -Welcome to our repository on GitHub! Here you will find example code to get you started with our Affdex SDK 3.0 and begin emotion-enabling you own app! Documentation for the SDKs is available on the Affectiva's Developer Portal. +Welcome to our repository on GitHub! Here you will find example code to get you started with our Affdex SDK 3.1 and begin emotion-enabling you own app! Documentation for the SDKs is available on the Affectiva's Developer Portal. *Build Status* - Windows: [![Build status](https://ci.appveyor.com/api/projects/status/pn2y9h8a3nnkiw41?svg=true)] @@ -11,7 +11,7 @@ Dependencies ------------ *Windows* -- Affdex SDK 3.0 (32 bit) +- Affdex SDK 3.1 (64 bit) - Visual Studio 2013 or higher *Linux* diff --git a/affdex-win-samples.sln b/affdex-win-samples.sln index 76bce73..653a244 100644 --- a/affdex-win-samples.sln +++ b/affdex-win-samples.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 -VisualStudioVersion = 12.0.21005.1 +VisualStudioVersion = 12.0.40629.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opencv-webcam-demo", "opencv-webcam-demo\opencv-webcam-demo.vcxproj", "{8DCDC209-C25D-4C61-B2AC-2FBA1775DD6B}" EndProject @@ -9,23 +9,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "video-demo", "video-demo\vi EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Release|Mixed Platforms = Release|Mixed Platforms - Release|Win32 = Release|Win32 - Release|x86 = Release|x86 + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {8DCDC209-C25D-4C61-B2AC-2FBA1775DD6B}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {8DCDC209-C25D-4C61-B2AC-2FBA1775DD6B}.Release|Mixed Platforms.Build.0 = Release|Win32 - {8DCDC209-C25D-4C61-B2AC-2FBA1775DD6B}.Release|Win32.ActiveCfg = Release|Win32 - {8DCDC209-C25D-4C61-B2AC-2FBA1775DD6B}.Release|Win32.Build.0 = Release|Win32 - {8DCDC209-C25D-4C61-B2AC-2FBA1775DD6B}.Release|x86.ActiveCfg = Release|Win32 - {8DCDC209-C25D-4C61-B2AC-2FBA1775DD6B}.Release|x86.Build.0 = Release|Win32 - {5D5E4401-09DE-40D3-9E29-AFC4F2EF2C80}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {5D5E4401-09DE-40D3-9E29-AFC4F2EF2C80}.Release|Mixed Platforms.Build.0 = Release|Win32 - {5D5E4401-09DE-40D3-9E29-AFC4F2EF2C80}.Release|Win32.ActiveCfg = Release|Win32 - {5D5E4401-09DE-40D3-9E29-AFC4F2EF2C80}.Release|Win32.Build.0 = Release|Win32 - {5D5E4401-09DE-40D3-9E29-AFC4F2EF2C80}.Release|x86.ActiveCfg = Release|Win32 - {5D5E4401-09DE-40D3-9E29-AFC4F2EF2C80}.Release|x86.Build.0 = Release|Win32 + {8DCDC209-C25D-4C61-B2AC-2FBA1775DD6B}.Release|x64.ActiveCfg = Release|x64 + {5D5E4401-09DE-40D3-9E29-AFC4F2EF2C80}.Release|x64.ActiveCfg = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..a505698 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,22 @@ +version: 1.0.{build} +image: +- Visual Studio 2013 +- Visual Studio 2015 +before_build: +- cmd: >- + appveyor DownloadFile http://affdex-sdk-dist.s3-website-us-east-1.amazonaws.com/windows/AffdexSDK-3.1-339-win64.exe -FileName AffdexSDK-win64.exe + + AffdexSDK-win64.exe /S + + nuget restore affdex-win-samples.sln +build: + parallel: true + verbosity: detailed +artifacts: +- path: '\x64\Release' +deploy: +- provider: GitHub + release: 3.1 + auth_token: + secure: sjCE8t4b8ME8j2D6e0kRpNib8STOljgGVPdexj4n0gXU/nYxFkdaI9GXRukRHri5 + artifact: Release.zip diff --git a/common/PlottingImageListener.hpp b/common/PlottingImageListener.hpp index 90e9d47..6030932 100644 --- a/common/PlottingImageListener.hpp +++ b/common/PlottingImageListener.hpp @@ -1,315 +1,340 @@ -#pragma once - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - - -#include "ImageListener.h" - - -using namespace affdex; - -class PlottingImageListener : public ImageListener -{ - - std::mutex mMutex; - std::deque > > mDataArray; - - double mCaptureLastTS; - double mCaptureFPS; - double mProcessLastTS; - double mProcessFPS; - std::ofstream &fStream; - std::chrono::time_point mStartT; - const bool mDrawDisplay; - const int spacing = 10; - const float font_size = 0.5f; - const int font = cv::FONT_HERSHEY_COMPLEX_SMALL; - - std::vector expressions; - std::vector emotions; - std::vector emojis; - std::vector headAngles; - - std::map glassesMap; - std::map genderMap; - -public: - - - PlottingImageListener(std::ofstream &csv, const bool draw_display) - : fStream(csv), mDrawDisplay(draw_display), mStartT(std::chrono::system_clock::now()), - mCaptureLastTS(-1.0f), mCaptureFPS(-1.0f), - mProcessLastTS(-1.0f), mProcessFPS(-1.0f) - { - expressions = { - "smile", "innerBrowRaise", "browRaise", "browFurrow", "noseWrinkle", - "upperLipRaise", "lipCornerDepressor", "chinRaise", "lipPucker", "lipPress", - "lipSuck", "mouthOpen", "smirk", "eyeClosure", "attention" - }; - - emotions = { - "joy", "fear", "disgust", "sadness", "anger", - "surprise", "contempt", "valence", "engagement" - }; - - headAngles = { "pitch", "yaw", "roll" }; - - - emojis = std::vector { - "relaxed", "smiley", "laughing", - "kissing", "disappointed", - "rage", "smirk", "wink", - "stuckOutTongueWinkingEye", "stuckOutTongue", - "flushed", "scream" - }; - - genderMap = std::map { - { affdex::Gender::Male, "male" }, - { affdex::Gender::Female, "female" }, - { affdex::Gender::Unknown, "unknown" }, - - }; - - glassesMap = std::map { - { affdex::Glasses::Yes, "glasses" }, - { affdex::Glasses::No, "no glasses" } - }; - - fStream << "TimeStamp,faceId,interocularDistance,glasses,gender,dominantEmoji,"; - for (std::string angle : headAngles) fStream << angle << ","; - for (std::string emotion : emotions) fStream << emotion << ","; - for (std::string expression : expressions) fStream << expression << ","; - for (std::string emoji : emojis) fStream << emoji << ","; - fStream << std::endl; - fStream.precision(4); - fStream << std::fixed; - } - - FeaturePoint minPoint(VecFeaturePoint points) - { - VecFeaturePoint::iterator it = points.begin(); - FeaturePoint ret = *it; - for (; it != points.end(); it++) - { - if (it->x < ret.x) ret.x = it->x; - if (it->y < ret.y) ret.y = it->y; - } - return ret; - }; - - FeaturePoint maxPoint( VecFeaturePoint points) - { - VecFeaturePoint::iterator it = points.begin(); - FeaturePoint ret = *it; - for (; it != points.end(); it++) - { - if (it->x > ret.x) ret.x = it->x; - if (it->y > ret.y) ret.y = it->y; - } - return ret; - }; - - - double getProcessingFrameRate() - { - std::lock_guard lg(mMutex); - return mProcessFPS; - } - - double getCaptureFrameRate() - { - std::lock_guard lg(mMutex); - return mCaptureFPS; - } - - int getDataSize() - { - std::lock_guard lg(mMutex); - return mDataArray.size(); - - } - - std::pair> getData() - { - std::lock_guard lg(mMutex); - std::pair> dpoint = mDataArray.front(); - mDataArray.pop_front(); - return dpoint; - } - - void onImageResults(std::map faces, Frame image) override - { - std::lock_guard lg(mMutex); - mDataArray.push_back(std::pair> (image, faces) ); - std::chrono::time_point now = std::chrono::system_clock::now(); - std::chrono::milliseconds milliseconds = std::chrono::duration_cast(now - mStartT); - double seconds = milliseconds.count() / 1000.f; - mProcessFPS = 1.0f / (seconds - mProcessLastTS); - mProcessLastTS = seconds; - }; - - void onImageCapture(Frame image) override - { - std::lock_guard lg(mMutex); - mCaptureFPS = 1.0f / (image.getTimestamp() - mCaptureLastTS); - mCaptureLastTS = image.getTimestamp(); - }; - - void outputToFile(const std::map faces, const double timeStamp) - { - if (faces.empty()) - { - fStream << timeStamp << "nan,nan,no glasses,unknown, unknown,"; - for (std::string angle : headAngles) fStream << "nan,"; - for (std::string emotion : emotions) fStream << "nan,"; - for (std::string expression : expressions) fStream << "nan,"; - for (std::string emoji : emojis) fStream << "nan,"; - fStream << std::endl; - } - for (auto & face_id_pair : faces) - { - Face f = face_id_pair.second; - - fStream << timeStamp << "," - << f.id << "," - << f.measurements.interocularDistance << "," - << glassesMap[f.appearance.glasses] << "," - << genderMap[f.appearance.gender] << "," - << affdex::EmojiToString(f.emojis.dominantEmoji) << ","; - - float *values = (float *)&f.measurements.orientation; - for (std::string angle : headAngles) - { - fStream << (*values) << ","; - values++; - } - - values = (float *)&f.emotions; - for (std::string emotion : emotions) - { - fStream << (*values) << ","; - values++; - } - - values = (float *)&f.expressions; - for (std::string expression : expressions) - { - fStream << (*values) << ","; - values++; - } - - values = (float *)&f.emojis; - for (std::string emoji : emojis) - { - fStream << (*values) << ","; - values++; - } - - fStream << std::endl; - } - } - - void drawValues(const float * first, const std::vector names, - const int x, int &padding, const cv::Scalar clr, - cv::Mat img) - { - for (std::string name : names) - { - if (std::abs(*first) > 5.0f) - { - char m[50]; - sprintf(m, "%s: %3.2f", name.c_str(), (*first)); - cv::putText(img, m, cv::Point(x, padding += spacing), font, font_size, clr); - } - first++; - } - } - - void draw(const std::map faces, Frame image) - { - std::shared_ptr imgdata = image.getBGRByteArray(); - cv::Mat img = cv::Mat(image.getHeight(), image.getWidth(), CV_8UC3, imgdata.get()); - - const int left_margin = 30; - - - cv::Scalar clr = cv::Scalar(0, 0, 255); - cv::Scalar header_clr = cv::Scalar(255, 0, 0); - - for (auto & face_id_pair : faces) - { - Face f = face_id_pair.second; - VecFeaturePoint points = f.featurePoints; - for (auto& point : points) //Draw face feature points. - { - cv::circle(img, cv::Point(point.x, point.y), 2.0f, cv::Scalar(0, 0, 255)); - } - FeaturePoint tl = minPoint(points); - FeaturePoint br = maxPoint(points); - - //Output the results of the different classifiers. - int padding = tl.y + 10; - - cv::putText(img, "APPEARANCE", cv::Point(br.x, padding += (spacing * 2)), font, font_size, header_clr); - cv::putText(img, genderMap[f.appearance.gender], cv::Point(br.x, padding += spacing), font, font_size, clr); - cv::putText(img, glassesMap[f.appearance.glasses], cv::Point(br.x, padding += spacing), font, font_size, clr); - - - - Orientation headAngles = f.measurements.orientation; - - char strAngles[100]; - sprintf(strAngles, "Pitch: %3.2f Yaw: %3.2f Roll: %3.2f Interocular: %3.2f", - headAngles.pitch, headAngles.yaw, headAngles.roll, f.measurements.interocularDistance); - - - - char fId[10]; - sprintf(fId, "ID: %i", f.id); - cv::putText(img, fId, cv::Point(br.x, padding += spacing), font, font_size, clr); - - cv::putText(img, "MEASUREMENTS", cv::Point(br.x, padding += (spacing * 2)), font, font_size, header_clr); - - cv::putText(img, strAngles, cv::Point(br.x, padding += spacing), font, font_size, clr); - - cv::putText(img, "EMOJIS", cv::Point(br.x, padding += (spacing * 2)), font, font_size, header_clr); - - cv::putText(img, "dominantEmoji: " + affdex::EmojiToString(f.emojis.dominantEmoji), - cv::Point(br.x, padding += spacing), font, font_size, clr); - - drawValues((float *)&f.emojis, emojis, br.x, padding, clr, img); - - cv::putText(img, "EXPRESSIONS", cv::Point(br.x, padding += (spacing * 2)), font, font_size, header_clr); - - drawValues((float *)&f.expressions, expressions, br.x, padding, clr, img); - - cv::putText(img, "EMOTIONS", cv::Point(br.x, padding += (spacing * 2)), font, font_size, header_clr); - - drawValues((float *)&f.emotions, emotions, br.x, padding, clr, img); - - } - char fps_str[50]; - sprintf(fps_str, "capture fps: %2.0f", mCaptureFPS); - cv::putText(img, fps_str, cv::Point(img.cols - 110, img.rows - left_margin - spacing), font, font_size, clr); - sprintf(fps_str, "process fps: %2.0f", mProcessFPS); - cv::putText(img, fps_str, cv::Point(img.cols - 110, img.rows - left_margin), font, font_size, clr); - - cv::imshow("analyze video", img); - cv::waitKey(5); - } - -}; +#pragma once + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +#include "ImageListener.h" + + +using namespace affdex; + +class PlottingImageListener : public ImageListener +{ + + std::mutex mMutex; + std::deque > > mDataArray; + + double mCaptureLastTS; + double mCaptureFPS; + double mProcessLastTS; + double mProcessFPS; + std::ofstream &fStream; + std::chrono::time_point mStartT; + const bool mDrawDisplay; + const int spacing = 10; + const float font_size = 0.5f; + const int font = cv::FONT_HERSHEY_COMPLEX_SMALL; + + std::vector expressions; + std::vector emotions; + std::vector emojis; + std::vector headAngles; + + std::map glassesMap; + std::map genderMap; + std::map ageMap; + std::map ethnicityMap; + +public: + + + PlottingImageListener(std::ofstream &csv, const bool draw_display) + : fStream(csv), mDrawDisplay(draw_display), mStartT(std::chrono::system_clock::now()), + mCaptureLastTS(-1.0f), mCaptureFPS(-1.0f), + mProcessLastTS(-1.0f), mProcessFPS(-1.0f) + { + expressions = { + "smile", "innerBrowRaise", "browRaise", "browFurrow", "noseWrinkle", + "upperLipRaise", "lipCornerDepressor", "chinRaise", "lipPucker", "lipPress", + "lipSuck", "mouthOpen", "smirk", "eyeClosure", "attention", "eyeWiden", "cheekRaise", + "lidTighten", "dimpler", "lipStretch", "jawDrop" + }; + + emotions = { + "joy", "fear", "disgust", "sadness", "anger", + "surprise", "contempt", "valence", "engagement" + }; + + headAngles = { "pitch", "yaw", "roll" }; + + + emojis = std::vector { + "relaxed", "smiley", "laughing", + "kissing", "disappointed", + "rage", "smirk", "wink", + "stuckOutTongueWinkingEye", "stuckOutTongue", + "flushed", "scream" + }; + + genderMap = std::map { + { affdex::Gender::Male, "male" }, + { affdex::Gender::Female, "female" }, + { affdex::Gender::Unknown, "unknown" }, + + }; + + glassesMap = std::map { + { affdex::Glasses::Yes, "yes" }, + { affdex::Glasses::No, "no" } + }; + + ageMap = std::map { + { affdex::Age::AGE_UNKNOWN, "unknown"}, + { affdex::Age::AGE_UNDER_18, "under 18" }, + { affdex::Age::AGE_18_24, "18-24" }, + { affdex::Age::AGE_25_34, "25-34" }, + { affdex::Age::AGE_35_44, "35-44" }, + { affdex::Age::AGE_45_54, "45-54" }, + { affdex::Age::AGE_55_64, "55-64" }, + { affdex::Age::AGE_65_PLUS, "65 plus" } + }; + + ethnicityMap = std::map { + { affdex::Ethnicity::UNKNOWN, "unknown"}, + { affdex::Ethnicity::CAUCASIAN, "caucasian" }, + { affdex::Ethnicity::BLACK_AFRICAN, "black african" }, + { affdex::Ethnicity::SOUTH_ASIAN, "south asian" }, + { affdex::Ethnicity::EAST_ASIAN, "east asian" }, + { affdex::Ethnicity::HISPANIC, "hispanic" } + }; + + fStream << "TimeStamp,faceId,interocularDistance,glasses,age,ethnicity,gender,dominantEmoji,"; + for (std::string angle : headAngles) fStream << angle << ","; + for (std::string emotion : emotions) fStream << emotion << ","; + for (std::string expression : expressions) fStream << expression << ","; + for (std::string emoji : emojis) fStream << emoji << ","; + fStream << std::endl; + fStream.precision(4); + fStream << std::fixed; + } + + FeaturePoint minPoint(VecFeaturePoint points) + { + VecFeaturePoint::iterator it = points.begin(); + FeaturePoint ret = *it; + for (; it != points.end(); it++) + { + if (it->x < ret.x) ret.x = it->x; + if (it->y < ret.y) ret.y = it->y; + } + return ret; + }; + + FeaturePoint maxPoint(VecFeaturePoint points) + { + VecFeaturePoint::iterator it = points.begin(); + FeaturePoint ret = *it; + for (; it != points.end(); it++) + { + if (it->x > ret.x) ret.x = it->x; + if (it->y > ret.y) ret.y = it->y; + } + return ret; + }; + + + double getProcessingFrameRate() + { + std::lock_guard lg(mMutex); + return mProcessFPS; + } + + double getCaptureFrameRate() + { + std::lock_guard lg(mMutex); + return mCaptureFPS; + } + + int getDataSize() + { + std::lock_guard lg(mMutex); + return mDataArray.size(); + + } + + std::pair> getData() + { + std::lock_guard lg(mMutex); + std::pair> dpoint = mDataArray.front(); + mDataArray.pop_front(); + return dpoint; + } + + void onImageResults(std::map faces, Frame image) override + { + std::lock_guard lg(mMutex); + mDataArray.push_back(std::pair>(image, faces)); + std::chrono::time_point now = std::chrono::system_clock::now(); + std::chrono::milliseconds milliseconds = std::chrono::duration_cast(now - mStartT); + double seconds = milliseconds.count() / 1000.f; + mProcessFPS = 1.0f / (seconds - mProcessLastTS); + mProcessLastTS = seconds; + }; + + void onImageCapture(Frame image) override + { + std::lock_guard lg(mMutex); + mCaptureFPS = 1.0f / (image.getTimestamp() - mCaptureLastTS); + mCaptureLastTS = image.getTimestamp(); + }; + + void outputToFile(const std::map faces, const double timeStamp) + { + if (faces.empty()) + { + fStream << timeStamp << "nan,nan,no,unknown,unknown,unknown,unknown,"; + for (std::string angle : headAngles) fStream << "nan,"; + for (std::string emotion : emotions) fStream << "nan,"; + for (std::string expression : expressions) fStream << "nan,"; + for (std::string emoji : emojis) fStream << "nan,"; + fStream << std::endl; + } + for (auto & face_id_pair : faces) + { + Face f = face_id_pair.second; + + fStream << timeStamp << "," + << f.id << "," + << f.measurements.interocularDistance << "," + << glassesMap[f.appearance.glasses] << "," + << ageMap[f.appearance.age] << "," + << ethnicityMap[f.appearance.ethnicity] << "," + << genderMap[f.appearance.gender] << "," + << affdex::EmojiToString(f.emojis.dominantEmoji) << ","; + + float *values = (float *)&f.measurements.orientation; + for (std::string angle : headAngles) + { + fStream << (*values) << ","; + values++; + } + + values = (float *)&f.emotions; + for (std::string emotion : emotions) + { + fStream << (*values) << ","; + values++; + } + + values = (float *)&f.expressions; + for (std::string expression : expressions) + { + fStream << (*values) << ","; + values++; + } + + values = (float *)&f.emojis; + for (std::string emoji : emojis) + { + fStream << (*values) << ","; + values++; + } + + fStream << std::endl; + } + } + + void drawValues(const float * first, const std::vector names, + const int x, int &padding, const cv::Scalar clr, + cv::Mat img) + { + for (std::string name : names) + { + if (std::abs(*first) > 5.0f) + { + char m[50]; + sprintf(m, "%s: %3.2f", name.c_str(), (*first)); + cv::putText(img, m, cv::Point(x, padding += spacing), font, font_size, clr); + } + first++; + } + } + + void draw(const std::map faces, Frame image) + { + std::shared_ptr imgdata = image.getBGRByteArray(); + cv::Mat img = cv::Mat(image.getHeight(), image.getWidth(), CV_8UC3, imgdata.get()); + + const int left_margin = 30; + + + cv::Scalar clr = cv::Scalar(0, 0, 255); + cv::Scalar header_clr = cv::Scalar(255, 0, 0); + + for (auto & face_id_pair : faces) + { + Face f = face_id_pair.second; + VecFeaturePoint points = f.featurePoints; + for (auto& point : points) //Draw face feature points. + { + cv::circle(img, cv::Point(point.x, point.y), 2.0f, cv::Scalar(0, 0, 255)); + } + FeaturePoint tl = minPoint(points); + FeaturePoint br = maxPoint(points); + + //Output the results of the different classifiers. + int padding = tl.y + 10; + + cv::putText(img, "APPEARANCE", cv::Point(br.x, padding += (spacing * 2)), font, font_size, header_clr); + cv::putText(img, genderMap[f.appearance.gender], cv::Point(br.x, padding += spacing), font, font_size, clr); + cv::putText(img, glassesMap[f.appearance.glasses], cv::Point(br.x, padding += spacing), font, font_size, clr); + cv::putText(img, ageMap[f.appearance.age], cv::Point(br.x, padding += spacing), font, font_size, clr); + cv::putText(img, ethnicityMap[f.appearance.ethnicity], cv::Point(br.x, padding += spacing), font, font_size, clr); + + Orientation headAngles = f.measurements.orientation; + + char strAngles[100]; + sprintf(strAngles, "Pitch: %3.2f Yaw: %3.2f Roll: %3.2f Interocular: %3.2f", + headAngles.pitch, headAngles.yaw, headAngles.roll, f.measurements.interocularDistance); + + + + char fId[10]; + sprintf(fId, "ID: %i", f.id); + cv::putText(img, fId, cv::Point(br.x, padding += spacing), font, font_size, clr); + + cv::putText(img, "MEASUREMENTS", cv::Point(br.x, padding += (spacing * 2)), font, font_size, header_clr); + + cv::putText(img, strAngles, cv::Point(br.x, padding += spacing), font, font_size, clr); + + cv::putText(img, "EMOJIS", cv::Point(br.x, padding += (spacing * 2)), font, font_size, header_clr); + + cv::putText(img, "dominantEmoji: " + affdex::EmojiToString(f.emojis.dominantEmoji), + cv::Point(br.x, padding += spacing), font, font_size, clr); + + drawValues((float *)&f.emojis, emojis, br.x, padding, clr, img); + + cv::putText(img, "EXPRESSIONS", cv::Point(br.x, padding += (spacing * 2)), font, font_size, header_clr); + + drawValues((float *)&f.expressions, expressions, br.x, padding, clr, img); + + cv::putText(img, "EMOTIONS", cv::Point(br.x, padding += (spacing * 2)), font, font_size, header_clr); + + drawValues((float *)&f.emotions, emotions, br.x, padding, clr, img); + + } + char fps_str[50]; + sprintf(fps_str, "capture fps: %2.0f", mCaptureFPS); + cv::putText(img, fps_str, cv::Point(img.cols - 110, img.rows - left_margin - spacing), font, font_size, clr); + sprintf(fps_str, "process fps: %2.0f", mProcessFPS); + cv::putText(img, fps_str, cv::Point(img.cols - 110, img.rows - left_margin), font, font_size, clr); + + cv::imshow("analyze video", img); + cv::waitKey(30); + } + +}; diff --git a/opencv-webcam-demo/opencv-webcam-demo.cpp b/opencv-webcam-demo/opencv-webcam-demo.cpp index 40aa2c2..9cd61a0 100644 --- a/opencv-webcam-demo/opencv-webcam-demo.cpp +++ b/opencv-webcam-demo/opencv-webcam-demo.cpp @@ -127,8 +127,7 @@ int main(int argsc, char ** argsv) frameDetector->setDetectAllEmotions(true); frameDetector->setDetectAllExpressions(true); frameDetector->setDetectAllEmojis(true); - frameDetector->setDetectGender(true); - frameDetector->setDetectGlasses(true); + frameDetector->setDetectAllAppearances(true); frameDetector->setClassifierPath(DATA_FOLDER); frameDetector->setLicensePath(LICENSE_PATH); frameDetector->setImageListener(listenPtr.get()); diff --git a/opencv-webcam-demo/opencv-webcam-demo.vcxproj b/opencv-webcam-demo/opencv-webcam-demo.vcxproj index 36ea02a..3911b9a 100644 --- a/opencv-webcam-demo/opencv-webcam-demo.vcxproj +++ b/opencv-webcam-demo/opencv-webcam-demo.vcxproj @@ -2,9 +2,9 @@ - + Release - Win32 + x64 @@ -15,7 +15,7 @@ true - + Application false v120 @@ -25,16 +25,16 @@ - + 635eb584 - + false - + Level3 @@ -44,18 +44,18 @@ true WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) true - C:\Program Files %28x86%29\Affectiva\Affdex SDK\include;../common/;%(AdditionalDependencies) + C:\Program Files\Affectiva\Affdex SDK\include;../common/;%(AdditionalDependencies) Console true true true - C:\Program Files (x86)\Affectiva\Affdex SDK\lib\release\affdex-native.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + C:\Program Files\Affectiva\Affdex SDK\lib\release\affdex-native.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - xcopy /d /y "C:\Program Files (x86)\Affectiva\Affdex SDK\bin\release\affdex-native.dll" "$(OutDir)" -xcopy /d /s /y "C:\Program Files (x86)\Affectiva\Affdex SDK\data" "$(OutDir)data\" + xcopy /d /y "C:\Program Files\Affectiva\Affdex SDK\bin\release\affdex-native.dll" "$(OutDir)" +xcopy /d /s /y "C:\Program Files\Affectiva\Affdex SDK\data" "$(OutDir)data\" diff --git a/opencv-webcam-demo/opencv-webcam-demo.vcxproj.user b/opencv-webcam-demo/opencv-webcam-demo.vcxproj.user index dbeabab..8d43239 100644 --- a/opencv-webcam-demo/opencv-webcam-demo.vcxproj.user +++ b/opencv-webcam-demo/opencv-webcam-demo.vcxproj.user @@ -1,7 +1,7 @@  - - PATH=%PATH%;C:\Program Files (x86)\Affectiva\Affdex SDK\bin\release\;C:\Program Files (x86)\Affectiva\Affdex SDK\bin + + PATH=%PATH%;C:\Program Files\Affectiva\Affdex SDK\bin\release\;C:\Program Files\Affectiva\Affdex SDK\bin WindowsLocalDebugger \ No newline at end of file diff --git a/video-demo/video-demo.cpp b/video-demo/video-demo.cpp index 5975675..c4dd06b 100644 --- a/video-demo/video-demo.cpp +++ b/video-demo/video-demo.cpp @@ -140,8 +140,7 @@ int main(int argsc, char ** argsv) detector->setDetectAllEmotions(true); detector->setDetectAllExpressions(true); detector->setDetectAllEmojis(true); - detector->setDetectGender(true); - detector->setDetectGlasses(true); + detector->setDetectAllAppearances(true); detector->setClassifierPath(DATA_FOLDER); detector->setLicensePath(LICENSE_PATH); detector->setImageListener(listenPtr.get()); diff --git a/video-demo/video-demo.vcxproj b/video-demo/video-demo.vcxproj index 1e96edf..ef1f29e 100644 --- a/video-demo/video-demo.vcxproj +++ b/video-demo/video-demo.vcxproj @@ -2,9 +2,9 @@ - + Release - Win32 + x64 @@ -15,7 +15,7 @@ true - + Application false v120 @@ -25,16 +25,16 @@ - + 5c6c3308 - + false - + Level3 @@ -44,19 +44,19 @@ true WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) true - C:\Program Files %28x86%29\Affectiva\Affdex SDK\include;../common;%(AdditionalDependencies) + C:\Program Files\Affectiva\Affdex SDK\include;../common;%(AdditionalDependencies) Console true true true - C:\Program Files (x86)\Affectiva\Affdex SDK\lib\release\affdex-native.lib;%(AdditionalDependencies) + C:\Program Files\Affectiva\Affdex SDK\lib\release\affdex-native.lib;%(AdditionalDependencies) - xcopy /d /y "C:\Program Files (x86)\Affectiva\Affdex SDK\bin\release\affdex-native.dll" "$(OutDir)" -xcopy /d /y "C:\Program Files (x86)\Affectiva\Affdex SDK\bin\opencv_ffmpeg248.dll" "$(OutDir)" -xcopy /d /s /y "C:\Program Files (x86)\Affectiva\Affdex SDK\data" "$(OutDir)data\" + xcopy /d /y "C:\Program Files\Affectiva\Affdex SDK\bin\release\affdex-native.dll" "$(OutDir)" +xcopy /d /y "C:\Program Files\Affectiva\Affdex SDK\bin\opencv_ffmpeg248_64.dll" "$(OutDir)" +xcopy /d /s /y "C:\Program Files\Affectiva\Affdex SDK\data" "$(OutDir)data\"