From a694fed40688cc0d59285b935a59456e852cfad1 Mon Sep 17 00:00:00 2001 From: Ezequiel Silva Date: Wed, 6 May 2015 15:45:58 -0300 Subject: [PATCH] Correção no Reconhecedor --- log/log | 4 ++++ mixer/src/Mixer.cpp | 8 ++++---- recognize/src/include/recognize.h | 2 +- recognize/src/recognize.cpp | 22 ++++++++++++++++++---- servico/src/serviceWindowGeneration.cpp | 3 +++ 5 files changed, 30 insertions(+), 9 deletions(-) diff --git a/log/log b/log/log index e69de29..7a3bb44 100644 --- a/log/log +++ b/log/log @@ -0,0 +1,4 @@ +Wed May 6 14:05:56 2015 +[ERRO: recognize.cpp] Arquivo não encontrado. + + \ No newline at end of file diff --git a/mixer/src/Mixer.cpp b/mixer/src/Mixer.cpp index 74e574f..a04d49f 100644 --- a/mixer/src/Mixer.cpp +++ b/mixer/src/Mixer.cpp @@ -121,7 +121,7 @@ void Mixer::mixVideos () { " [out]\" -sameq -strict experimental -vcodec mpeg2video -r 30 -threads "+this->numThreads+" "+pathFinal; */ - string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" -y -vf \"movie="+this->secondaryVideo+", "+ + string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" -v quiet -y -vf \"movie="+this->secondaryVideo+", "+ "scale="+ num1String +":"+num2String+", setpts=PTS-STARTPTS, [movie] overlay"+transparency+"="+strPosition+ " [out]\" -qscale 0 -strict experimental -vcodec libx264 -preset fast -r 30 -threads "+this->numThreads+" "+pathFinal; @@ -153,7 +153,7 @@ void Mixer::setPathFinal(){ /*Ajusta o FPS do vídeo principal para 45 se preciso...*/ void Mixer::adjustVideosFps(){ //primeiro executo a linha de comando que me dá todas as informações do vídeo - string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" 2> "+temporaryTextFile; + string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" 2> "+temporaryTextFile; system(ffmpegSentence.c_str()); //executo o comando ffmpeg que escreve no arquivo temporário fpsAndLine arrayDeFps[10]; //array onde será guardado os fps encontrados @@ -223,7 +223,7 @@ void Mixer::convertMainVideoFPS(fpsAndLine arrayDeFps [], int * qtdadeDeFPSEncon //printf("\n\n\n\n\n\n\nPID do canal: %s \n\n\n\n\n\n\n",arrayDeFps[i].possibleProgramID.c_str()); if(indexMainVideo1 > 0 && indexMainVideo2 > 0 && indexMainVideo3 > 0){ //eis aqui o vídeo principal //printf("\n\n\n\n\n\n\nPID do canal a ser alterado: %s \n\n\n\n\n\n\n",arrayDeFps[i].possibleProgramID.c_str()); - string ffmpegSentence45 = "ffmpeg -i "+this->mainVideo+" -y -r 45 -vcodec libx264 -streamid 0:"+arrayDeFps[i].possibleProgramID+ + string ffmpegSentence45 = "ffmpeg -i "+this->mainVideo+" -v quiet -y -r 45 -vcodec libx264 -streamid 0:"+arrayDeFps[i].possibleProgramID+ "-sameq -threads "+this->numThreads+" "+nameOfMainVideo+"-45fps.ts"; system(ffmpegSentence45.c_str()); //string removeVideoCMD = "rm -rf "+nameOfMainVideo+".ts"; //removo o vídeo exemplo.ts @@ -235,7 +235,7 @@ void Mixer::convertMainVideoFPS(fpsAndLine arrayDeFps [], int * qtdadeDeFPSEncon } else{ //cout << "\n############################\nConverter fps do vídeo principal com apenas um canal!\n############################\n"); - string ffmpegSentence45 = "ffmpeg -i "+this->mainVideo+" -y -r 45 -vcodec libx264 " + string ffmpegSentence45 = "ffmpeg -i "+this->mainVideo+" -v quiet -y -r 45 -vcodec libx264 " "-sameq -threads "+this->numThreads+" "+nameOfMainVideo+"-45fps.ts"; system(ffmpegSentence45.c_str()); //string removeVideoCMD = "rm -rf "+nameOfMainVideo+".ts"; //removo o vídeo exemplo.ts diff --git a/recognize/src/include/recognize.h b/recognize/src/include/recognize.h index 7908590..75b81a2 100644 --- a/recognize/src/include/recognize.h +++ b/recognize/src/include/recognize.h @@ -21,7 +21,7 @@ #define INPUT_PATTERN 1 /* 1 = Raw file, 2 = Mic */ #define BLOCS_PATTERN 10 #define SIZE_BUFFER 256 -#define CONFIDENCE_RATE 0.45 +#define CONFIDENCE_RATE 0.10 #define PATH_API_UPLOADS "vlibras_user/vlibras-api/uploads/" #define PATH_AUDIO_ORIGIN "/audio/origin/audio_origin.wav" diff --git a/recognize/src/recognize.cpp b/recognize/src/recognize.cpp index 9ce6488..0e9acf5 100644 --- a/recognize/src/recognize.cpp +++ b/recognize/src/recognize.cpp @@ -71,11 +71,11 @@ void Recognize::Run(){ breakVideoParts(getTimeMediaSec()); executeJuliusEngine(); generateConfidence(); - filterOutputJulius(); + //filterOutputJulius(); //cleanFiles(); finish = true; - notifyEndExtraction(count_lines); + //notifyEndExtraction(count_lines); } void Recognize::setFrequency(int freq) { @@ -245,10 +245,12 @@ void Recognize::generateConfidence() { } else { string line; float tmp; + int pass = 0; do { getline(in, line); std::istringstream buf(line); if (line.length() > 0) { + pass++; istream_iterator beg(buf), end; vector tokens(beg, end); float sizeAvgScores = 0; @@ -277,9 +279,17 @@ void Recognize::generateConfidence() { } } scores.push_back(avgScores/sizeAvgScores); + + }else if(pass==0){ + + notifyListeners((char*) "SENTENCA_COM_BAIXA_QUALIDADE", 0); + notifyEndExtraction(count_lines); + return; } } while (!in.eof()); in.close(); + filterOutputJulius(); + notifyEndExtraction(count_lines); } } @@ -326,15 +336,19 @@ void Recognize::filterOutputJulius() { strcpy(sentence_ptr, (char*) strFilter.c_str()); if(getConfidence()) notifyListeners(sentence_ptr, pts.front()); - else + else{ + notifyListeners((char*) "SENTENCA_COM_BAIXA_QUALIDADE", pts.front()); + } scores.erase(scores.begin()); count_lines++; } pts.erase(pts.begin()); } + } while (!in.eof()); in.close(); + //notifyListeners((char*) "SENTENCA_COM_BAIXA_QUALIDADE", pts.front()); } /*char* ptr_strFilter; @@ -345,7 +359,7 @@ void Recognize::filterOutputJulius() { void Recognize::notifyListeners(char* text, int64_t pts) { //cout << "NOTIFY: " << text << endl; - + for(list::iterator it = listeners->begin(); it != listeners->end(); it++){ (*it)->notifyTextRecognized((unsigned char*) text, calcula_pts(pts)); } diff --git a/servico/src/serviceWindowGeneration.cpp b/servico/src/serviceWindowGeneration.cpp index de40c25..edae9c0 100644 --- a/servico/src/serviceWindowGeneration.cpp +++ b/servico/src/serviceWindowGeneration.cpp @@ -203,6 +203,7 @@ void ServiceWindowGeneration::transcodeVideoToWebm() { string command = "ffmpeg -i "; command.append(path_libras) .append(" -vcodec libvpx -acodec libvorbis ") + .append(" -v quiet ") .append(PATH_API) .append(getUserId()) .append(".webm"); @@ -218,6 +219,7 @@ void ServiceWindowGeneration::transcodeVideoToMp4() { string command = "ffmpeg -i "; command.append(path_libras) .append(" -qscale 0 -strict experimental -vcodec libx264 -preset fast -r 30 ") + .append(" -v quiet ") .append(PATH_API) .append(getUserId()) .append(".mp4"); @@ -233,6 +235,7 @@ void ServiceWindowGeneration::createThumbnail(){ string command = "ffmpeg -ss 10 -i "; command.append(PATH_API).append(user_id).append(".mp4") .append(" -vcodec png -vframes 1 -an -f rawvideo -y -vf scale=200:200 ") + .append(" -v quiet ") .append(PATH_API).append(user_id).append(".png"); system(command.c_str()); } -- libgit2 0.21.2