diff --git a/README.md b/README.md index e811c3a..b71d2e0 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -#Sample Apps for Affdex C++ SDK for Windows / Linux +#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. @@ -74,7 +74,7 @@ The following command line arguments can be used to run it: Video-demo (c++) ---------- -Project for demoing the Windows SDK [VideoDetector class](http://developer.affectiva.com/v3/windows/analyze-video/). It processs video files, displays the emotion metrics and exports the results in a csv file. +Project for demoing the C++ SDK [VideoDetector class](http://developer.affectiva.com/v3/windows/analyze-video/). It processs video files, displays the emotion metrics and exports the results in a csv file. The following command line arguments can be used to run it: diff --git a/opencv-webcam-demo/opencv-webcam-demo.cpp b/opencv-webcam-demo/opencv-webcam-demo.cpp index e32f744..40aa2c2 100644 --- a/opencv-webcam-demo/opencv-webcam-demo.cpp +++ b/opencv-webcam-demo/opencv-webcam-demo.cpp @@ -52,7 +52,7 @@ int main(int argsc, char ** argsv) std::cerr.precision(precision); std::cout.precision(precision); - po::options_description description("Project for demoing the Windows SDK CameraDetector class (grabbing and processing frames from the camera)."); + po::options_description description("Project for demoing the Affdex SDK CameraDetector class (grabbing and processing frames from the camera)."); description.add_options() ("help,h", po::bool_switch()->default_value(false), "Display this help message.") #ifdef _WIN32 diff --git a/video-demo/video-demo.cpp b/video-demo/video-demo.cpp index 695ff1a..dadd059 100644 --- a/video-demo/video-demo.cpp +++ b/video-demo/video-demo.cpp @@ -23,9 +23,9 @@ using namespace affdex; int main(int argsc, char ** argsv) { - - - + + + std::map VIDEO_EXTS = { {boost::filesystem::path(".avi"), 1}, {boost::filesystem::path(".mov"), 1}, {boost::filesystem::path(".flv"), 1}, @@ -40,13 +40,13 @@ int main(int argsc, char ** argsv) bool loop = false; unsigned int nFaces = 1; int faceDetectorMode = (int)FaceDetectorMode::LARGE_FACES; - + const int precision = 2; std::cerr.precision(precision); std::cout.precision(precision); - + namespace po = boost::program_options; // abbreviate namespace - po::options_description description("Project for demoing the Windows SDK VideoDetector class (processing video files)."); + po::options_description description("Project for demoing the Affdex SDK VideoDetector class (processing video files)."); description.add_options() ("help,h", po::bool_switch()->default_value(false), "Display this help message.") #ifdef _WIN32 @@ -81,7 +81,7 @@ int main(int argsc, char ** argsv) std::cerr << "For help, use the -h option." << std::endl << std::endl; return 1; } - + // Parse and check the data folder (with assets) if (!boost::filesystem::exists(DATA_FOLDER)) { @@ -93,19 +93,19 @@ int main(int argsc, char ** argsv) try { std::shared_ptr detector; - + //Initialize out file boost::filesystem::path csvPath(videoPath); boost::filesystem::path fileExt = csvPath.extension(); csvPath.replace_extension(".csv"); std::ofstream csvFileStream(csvPath.c_str()); - + if (!csvFileStream.is_open()) { std::cerr << "Unable to open csv file " << csvPath << std::endl; return 1; } - + if (VIDEO_EXTS[fileExt]) // IF it is a video file. { detector = std::make_shared(process_framerate, nFaces, (affdex::FaceDetectorMode) faceDetectorMode); @@ -114,12 +114,12 @@ int main(int argsc, char ** argsv) { detector = std::make_shared(nFaces, (affdex::FaceDetectorMode) faceDetectorMode); } - - + + //VideoDetector videoDetector(process_framerate, nFaces, (affdex::FaceDetectorMode) faceDetectorMode); - - - + + + std::cout << "Max num of faces set to: " << detector->getMaxNumberFaces() << std::endl; std::string mode; switch (detector->getFaceDetectorMode()) @@ -133,10 +133,10 @@ int main(int argsc, char ** argsv) default: break; } - + std::cout << "Face detector mode set to: " << mode << std::endl; shared_ptr listenPtr(new PlottingImageListener(csvFileStream, draw_display)); - + detector->setDetectAllEmotions(true); detector->setDetectAllExpressions(true); detector->setDetectAllEmojis(true); @@ -145,10 +145,10 @@ int main(int argsc, char ** argsv) detector->setClassifierPath(DATA_FOLDER); detector->setLicensePath(LICENSE_PATH); detector->setImageListener(listenPtr.get()); - - + + detector->start(); //Initialize the detectors .. call only once - + do { shared_ptr videoListenPtr = std::make_shared(); @@ -161,13 +161,13 @@ int main(int argsc, char ** argsv) { //videoPath is of type std::wstring on windows, but std::string on other platforms. cv::Mat img = cv::imread(std::string(videoPath.begin(), videoPath.end())); - + // Create a frame Frame frame(img.size().width, img.size().height, img.data, Frame::COLOR_FORMAT::BGR); - + ((PhotoDetector *)detector.get())->process(frame); //Process an image } - + while (!VIDEO_EXTS[fileExt] || videoListenPtr->isRunning()) { if (listenPtr->getDataSize() > 0) @@ -175,32 +175,32 @@ int main(int argsc, char ** argsv) std::pair > dataPoint = listenPtr->getData(); Frame frame = dataPoint.first; std::map faces = dataPoint.second; - - + + if (draw_display) { listenPtr->draw(faces, frame); } - + std::cerr << "timestamp: " << frame.getTimestamp() << " cfps: " << listenPtr->getCaptureFrameRate() << " pfps: " << listenPtr->getProcessingFrameRate() << " faces: "<< faces.size() << endl; - + listenPtr->outputToFile(faces, frame.getTimestamp()); } } } while(loop); - + detector->stop(); csvFileStream.close(); - + std::cout << "Output written to file: " << csvPath << std::endl; } catch (AffdexException ex) { std::cerr << ex.what(); } - + return 0; }