Ive got a .wav file which Im playing whenever any person's Face is detected in camera. Please have a look at the playsound section of this snippet (main.cpp). The sound is playing but I think its slowing down the FaceRecognition also. Is system command slowing down the recognition/detection process ? Is there a faster /better way to play audio without slowing down the recognition/detection ?
#ifdef RECOGNIZE_FACE
cv::String Str;
cv::Scalar color;
int baseLine = 0;
switch(obj.Color){
case 0 : color = cv::Scalar(255, 255, 255); break; //default white -> face ok
case 1 : color = cv::Scalar( 80, 255, 255); break; //yellow ->stranger
case 2 : color = cv::Scalar(255, 237, 178); break; //blue -> too tiny
case 3 : color = cv::Scalar(127, 127, 255); break; //red -> fake
case 4 : color = cv::Scalar( 32, 32, 255); break; //pure red -> mask
default: color = cv::Scalar(255, 255, 255);
}
switch(obj.NameIndex){
case -1: Str="Stranger"; break;
case -2: Str="too tiny"; break;
case -3: Str="Fake !"; break;
case -4: Str="Mask !"; break;
default: Str=NameFaces[obj.NameIndex];
}
cv::Size label_size = cv::getTextSize(Str, cv::FONT_HERSHEY_SIMPLEX, 0.6, 1, &baseLine);
/////// ======== PLAY SOUND ============================ ///////////////
// DETECT NAME & OUTPUT ON CONSOLE LOG
cout << "NAME DETECTED AS \n\n " << Str << std::endl;
//PLAY WELCOME SOUND
string str1 = "aplay ";
str1 = str1 + "-Dhw:0,3 Welcome.wav" + " & ";
const char *command = str1.c_str();
system(command);
}
On the FaceMaskRecognition console im getting this error. I think whenever a face is detected audio is being called to play while the previous audio file hasnt finished playing. Is there a way to solve this ?
aplay : audio open error: device or resource busy