Commit a694fed40688cc0d59285b935a59456e852cfad1

Authored by Ezequiel Silva
1 parent d46f8520
Exists in master and in 1 other branch devel

Correção no Reconhecedor

@@ -0,0 +1,4 @@ @@ -0,0 +1,4 @@
  1 +Wed May 6 14:05:56 2015
  2 +[ERRO: recognize.cpp] Arquivo não encontrado.
  3 +
  4 +
0 \ No newline at end of file 5 \ No newline at end of file
mixer/src/Mixer.cpp
@@ -121,7 +121,7 @@ void Mixer::mixVideos () { @@ -121,7 +121,7 @@ void Mixer::mixVideos () {
121 " [out]\" -sameq -strict experimental -vcodec mpeg2video -r 30 -threads "+this->numThreads+" "+pathFinal; 121 " [out]\" -sameq -strict experimental -vcodec mpeg2video -r 30 -threads "+this->numThreads+" "+pathFinal;
122 */ 122 */
123 123
124 - string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" -y -vf \"movie="+this->secondaryVideo+", "+ 124 + string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" -v quiet -y -vf \"movie="+this->secondaryVideo+", "+
125 "scale="+ num1String +":"+num2String+", setpts=PTS-STARTPTS, [movie] overlay"+transparency+"="+strPosition+ 125 "scale="+ num1String +":"+num2String+", setpts=PTS-STARTPTS, [movie] overlay"+transparency+"="+strPosition+
126 " [out]\" -qscale 0 -strict experimental -vcodec libx264 -preset fast -r 30 -threads "+this->numThreads+" "+pathFinal; 126 " [out]\" -qscale 0 -strict experimental -vcodec libx264 -preset fast -r 30 -threads "+this->numThreads+" "+pathFinal;
127 127
@@ -153,7 +153,7 @@ void Mixer::setPathFinal(){ @@ -153,7 +153,7 @@ void Mixer::setPathFinal(){
153 /*Ajusta o FPS do vídeo principal para 45 se preciso...*/ 153 /*Ajusta o FPS do vídeo principal para 45 se preciso...*/
154 void Mixer::adjustVideosFps(){ 154 void Mixer::adjustVideosFps(){
155 //primeiro executo a linha de comando que me dá todas as informações do vídeo 155 //primeiro executo a linha de comando que me dá todas as informações do vídeo
156 - string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" 2> "+temporaryTextFile; 156 + string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" 2> "+temporaryTextFile;
157 system(ffmpegSentence.c_str()); //executo o comando ffmpeg que escreve no arquivo temporário 157 system(ffmpegSentence.c_str()); //executo o comando ffmpeg que escreve no arquivo temporário
158 158
159 fpsAndLine arrayDeFps[10]; //array onde será guardado os fps encontrados 159 fpsAndLine arrayDeFps[10]; //array onde será guardado os fps encontrados
@@ -223,7 +223,7 @@ void Mixer::convertMainVideoFPS(fpsAndLine arrayDeFps [], int * qtdadeDeFPSEncon @@ -223,7 +223,7 @@ void Mixer::convertMainVideoFPS(fpsAndLine arrayDeFps [], int * qtdadeDeFPSEncon
223 //printf("\n\n\n\n\n\n\nPID do canal: %s \n\n\n\n\n\n\n",arrayDeFps[i].possibleProgramID.c_str()); 223 //printf("\n\n\n\n\n\n\nPID do canal: %s \n\n\n\n\n\n\n",arrayDeFps[i].possibleProgramID.c_str());
224 if(indexMainVideo1 > 0 && indexMainVideo2 > 0 && indexMainVideo3 > 0){ //eis aqui o vídeo principal 224 if(indexMainVideo1 > 0 && indexMainVideo2 > 0 && indexMainVideo3 > 0){ //eis aqui o vídeo principal
225 //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()); 225 //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());
226 - string ffmpegSentence45 = "ffmpeg -i "+this->mainVideo+" -y -r 45 -vcodec libx264 -streamid 0:"+arrayDeFps[i].possibleProgramID+ 226 + string ffmpegSentence45 = "ffmpeg -i "+this->mainVideo+" -v quiet -y -r 45 -vcodec libx264 -streamid 0:"+arrayDeFps[i].possibleProgramID+
227 "-sameq -threads "+this->numThreads+" "+nameOfMainVideo+"-45fps.ts"; 227 "-sameq -threads "+this->numThreads+" "+nameOfMainVideo+"-45fps.ts";
228 system(ffmpegSentence45.c_str()); 228 system(ffmpegSentence45.c_str());
229 //string removeVideoCMD = "rm -rf "+nameOfMainVideo+".ts"; //removo o vídeo exemplo.ts 229 //string removeVideoCMD = "rm -rf "+nameOfMainVideo+".ts"; //removo o vídeo exemplo.ts
@@ -235,7 +235,7 @@ void Mixer::convertMainVideoFPS(fpsAndLine arrayDeFps [], int * qtdadeDeFPSEncon @@ -235,7 +235,7 @@ void Mixer::convertMainVideoFPS(fpsAndLine arrayDeFps [], int * qtdadeDeFPSEncon
235 } 235 }
236 else{ 236 else{
237 //cout << "\n############################\nConverter fps do vídeo principal com apenas um canal!\n############################\n"); 237 //cout << "\n############################\nConverter fps do vídeo principal com apenas um canal!\n############################\n");
238 - string ffmpegSentence45 = "ffmpeg -i "+this->mainVideo+" -y -r 45 -vcodec libx264 " 238 + string ffmpegSentence45 = "ffmpeg -i "+this->mainVideo+" -v quiet -y -r 45 -vcodec libx264 "
239 "-sameq -threads "+this->numThreads+" "+nameOfMainVideo+"-45fps.ts"; 239 "-sameq -threads "+this->numThreads+" "+nameOfMainVideo+"-45fps.ts";
240 system(ffmpegSentence45.c_str()); 240 system(ffmpegSentence45.c_str());
241 //string removeVideoCMD = "rm -rf "+nameOfMainVideo+".ts"; //removo o vídeo exemplo.ts 241 //string removeVideoCMD = "rm -rf "+nameOfMainVideo+".ts"; //removo o vídeo exemplo.ts
recognize/src/include/recognize.h
@@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
21 #define INPUT_PATTERN 1 /* 1 = Raw file, 2 = Mic */ 21 #define INPUT_PATTERN 1 /* 1 = Raw file, 2 = Mic */
22 #define BLOCS_PATTERN 10 22 #define BLOCS_PATTERN 10
23 #define SIZE_BUFFER 256 23 #define SIZE_BUFFER 256
24 -#define CONFIDENCE_RATE 0.45 24 +#define CONFIDENCE_RATE 0.10
25 25
26 #define PATH_API_UPLOADS "vlibras_user/vlibras-api/uploads/" 26 #define PATH_API_UPLOADS "vlibras_user/vlibras-api/uploads/"
27 #define PATH_AUDIO_ORIGIN "/audio/origin/audio_origin.wav" 27 #define PATH_AUDIO_ORIGIN "/audio/origin/audio_origin.wav"
recognize/src/recognize.cpp
@@ -71,11 +71,11 @@ void Recognize::Run(){ @@ -71,11 +71,11 @@ void Recognize::Run(){
71 breakVideoParts(getTimeMediaSec()); 71 breakVideoParts(getTimeMediaSec());
72 executeJuliusEngine(); 72 executeJuliusEngine();
73 generateConfidence(); 73 generateConfidence();
74 - filterOutputJulius(); 74 + //filterOutputJulius();
75 //cleanFiles(); 75 //cleanFiles();
76 76
77 finish = true; 77 finish = true;
78 - notifyEndExtraction(count_lines); 78 + //notifyEndExtraction(count_lines);
79 } 79 }
80 80
81 void Recognize::setFrequency(int freq) { 81 void Recognize::setFrequency(int freq) {
@@ -245,10 +245,12 @@ void Recognize::generateConfidence() { @@ -245,10 +245,12 @@ void Recognize::generateConfidence() {
245 } else { 245 } else {
246 string line; 246 string line;
247 float tmp; 247 float tmp;
  248 + int pass = 0;
248 do { 249 do {
249 getline(in, line); 250 getline(in, line);
250 std::istringstream buf(line); 251 std::istringstream buf(line);
251 if (line.length() > 0) { 252 if (line.length() > 0) {
  253 + pass++;
252 istream_iterator<std::string> beg(buf), end; 254 istream_iterator<std::string> beg(buf), end;
253 vector<string> tokens(beg, end); 255 vector<string> tokens(beg, end);
254 float sizeAvgScores = 0; 256 float sizeAvgScores = 0;
@@ -277,9 +279,17 @@ void Recognize::generateConfidence() { @@ -277,9 +279,17 @@ void Recognize::generateConfidence() {
277 } 279 }
278 } 280 }
279 scores.push_back(avgScores/sizeAvgScores); 281 scores.push_back(avgScores/sizeAvgScores);
  282 +
  283 + }else if(pass==0){
  284 +
  285 + notifyListeners((char*) "SENTENCA_COM_BAIXA_QUALIDADE", 0);
  286 + notifyEndExtraction(count_lines);
  287 + return;
280 } 288 }
281 } while (!in.eof()); 289 } while (!in.eof());
282 in.close(); 290 in.close();
  291 + filterOutputJulius();
  292 + notifyEndExtraction(count_lines);
283 } 293 }
284 } 294 }
285 295
@@ -326,15 +336,19 @@ void Recognize::filterOutputJulius() { @@ -326,15 +336,19 @@ void Recognize::filterOutputJulius() {
326 strcpy(sentence_ptr, (char*) strFilter.c_str()); 336 strcpy(sentence_ptr, (char*) strFilter.c_str());
327 if(getConfidence()) 337 if(getConfidence())
328 notifyListeners(sentence_ptr, pts.front()); 338 notifyListeners(sentence_ptr, pts.front());
329 - else 339 + else{
  340 +
330 notifyListeners((char*) "SENTENCA_COM_BAIXA_QUALIDADE", pts.front()); 341 notifyListeners((char*) "SENTENCA_COM_BAIXA_QUALIDADE", pts.front());
  342 + }
331 scores.erase(scores.begin()); 343 scores.erase(scores.begin());
332 count_lines++; 344 count_lines++;
333 } 345 }
334 pts.erase(pts.begin()); 346 pts.erase(pts.begin());
335 } 347 }
  348 +
336 } while (!in.eof()); 349 } while (!in.eof());
337 in.close(); 350 in.close();
  351 + //notifyListeners((char*) "SENTENCA_COM_BAIXA_QUALIDADE", pts.front());
338 } 352 }
339 353
340 /*char* ptr_strFilter; 354 /*char* ptr_strFilter;
@@ -345,7 +359,7 @@ void Recognize::filterOutputJulius() { @@ -345,7 +359,7 @@ void Recognize::filterOutputJulius() {
345 359
346 void Recognize::notifyListeners(char* text, int64_t pts) { 360 void Recognize::notifyListeners(char* text, int64_t pts) {
347 //cout << "NOTIFY: " << text << endl; 361 //cout << "NOTIFY: " << text << endl;
348 - 362 +
349 for(list<RecognizeListener*>::iterator it = listeners->begin(); it != listeners->end(); it++){ 363 for(list<RecognizeListener*>::iterator it = listeners->begin(); it != listeners->end(); it++){
350 (*it)->notifyTextRecognized((unsigned char*) text, calcula_pts(pts)); 364 (*it)->notifyTextRecognized((unsigned char*) text, calcula_pts(pts));
351 } 365 }
servico/src/serviceWindowGeneration.cpp
@@ -203,6 +203,7 @@ void ServiceWindowGeneration::transcodeVideoToWebm() { @@ -203,6 +203,7 @@ void ServiceWindowGeneration::transcodeVideoToWebm() {
203 string command = "ffmpeg -i "; 203 string command = "ffmpeg -i ";
204 command.append(path_libras) 204 command.append(path_libras)
205 .append(" -vcodec libvpx -acodec libvorbis ") 205 .append(" -vcodec libvpx -acodec libvorbis ")
  206 + .append(" -v quiet ")
206 .append(PATH_API) 207 .append(PATH_API)
207 .append(getUserId()) 208 .append(getUserId())
208 .append(".webm"); 209 .append(".webm");
@@ -218,6 +219,7 @@ void ServiceWindowGeneration::transcodeVideoToMp4() { @@ -218,6 +219,7 @@ void ServiceWindowGeneration::transcodeVideoToMp4() {
218 string command = "ffmpeg -i "; 219 string command = "ffmpeg -i ";
219 command.append(path_libras) 220 command.append(path_libras)
220 .append(" -qscale 0 -strict experimental -vcodec libx264 -preset fast -r 30 ") 221 .append(" -qscale 0 -strict experimental -vcodec libx264 -preset fast -r 30 ")
  222 + .append(" -v quiet ")
221 .append(PATH_API) 223 .append(PATH_API)
222 .append(getUserId()) 224 .append(getUserId())
223 .append(".mp4"); 225 .append(".mp4");
@@ -233,6 +235,7 @@ void ServiceWindowGeneration::createThumbnail(){ @@ -233,6 +235,7 @@ void ServiceWindowGeneration::createThumbnail(){
233 string command = "ffmpeg -ss 10 -i "; 235 string command = "ffmpeg -ss 10 -i ";
234 command.append(PATH_API).append(user_id).append(".mp4") 236 command.append(PATH_API).append(user_id).append(".mp4")
235 .append(" -vcodec png -vframes 1 -an -f rawvideo -y -vf scale=200:200 ") 237 .append(" -vcodec png -vframes 1 -an -f rawvideo -y -vf scale=200:200 ")
  238 + .append(" -v quiet ")
236 .append(PATH_API).append(user_id).append(".png"); 239 .append(PATH_API).append(user_id).append(".png");
237 system(command.c_str()); 240 system(command.c_str());
238 } 241 }