public IEnumerator TrainFromTexturesCoroutine(List<Texture2D> faceImages)
{
loadingBar.gameObject.SetActive(true);
loadingBar.value = 0;
float progress = 0f;
// STEP 1: Load model
if (!trainer.LoadModel())
{
Debug.LogError("Model not found");
yield break;
}
progress = 0.3f;
loadingBar.value = progress;
yield return null;
// STEP 2: Load face cascade
string cascadePath = Utils.getFilePath(LBP_CASCADE_FILENAME);
faceCascade = new CascadeClassifier(cascadePath);
if (faceCascade == null || faceCascade.empty())
{
Debug.LogError("Failed to load cascade classifier from " + cascadePath);
yield break;
}
progress = 0.6f;
loadingBar.value = progress;
yield return null;
// STEP 3: Open webcam
capture = new VideoCapture(0);
if (!capture.isOpened())
{
Debug.LogError("Cannot open webcam");
yield break;
}
progress = 1f;
loadingBar.value = progress;
frameMat = new Mat();
isCameraRunning = true;
yield return new WaitForSeconds(1);
loadingBar.gameObject.SetActive(false);
}