In a Unity environment, images streamed using FFmpeg are Mat-converted using OpenCV and face detection is performed by Dlib.
-
Create a Unity project with a 3D template.
-
Window→Package Manager → Set "Packages" to "My Assets" in the upper left corner and import "OpenCV For Unity".
-
Import and setup Dlib Face Landmark Detector in the same way.
-
Import and Setup FFmpeg for Unity.
-
Import Runtime Inspector & Hierarchy.
-
Import In-game Debug Console.
-
Rewrite the C# script named FfplayToMatHelperExample.cs in Assets/FfmpegWithOpenCVForUnityExample/FfplayToMatHelperExample/ (see diagram below) to the code named FfPlayStreamingFaceDetectionExample.cs
By setting the URL appropriately, face detection can be performed from streaming video. (However, we have confirmed that the delay is quite large.)
It is hard to see, but it detects a face and marks around the face. (All sky equirectangular format)