2014-07-05 3 views
-2

행복/슬픔/중립/혐오감/놀라움의 감정을 인식 할 수있는 응용 프로그램입니다.OpenCV - 줄 대신 백분율을 표시합니다.

줄은 현재 인식하고있는 감정에 따라 증가합니다.

아래의 링크는 현재 작업하고있는 이미지이지만 선 대신 백분율을 표시하고 싶지만 그 방법은 확실하지 않습니다.

http://postimg.org/image/j6hhe4dy7/

사람은 정말 감사하겠습니다이 나에게 도움이 될 수 있습니다.

cvPutText(img, EXP_NAMES[i], cvPoint(5, current), &font, expColor); 

과 : 당신은 당신이 정확히 방법은 통화 할 보여줍니다 감정 제목을 인쇄 라인을 볼 수 있습니다, 잘

if(showTrackerGui) { 
    CvScalar expColor = cvScalar(0,254,0); 
    cvFlip(img, NULL, 1); 

    int start=12, step=15, current; 
    current = start; 
    for(int i = 0; i < N_EXPRESSIONS; i++, current+=step) 
    { 
     //this line display the emotion. 
     cvPutText(img, EXP_NAMES[i], cvPoint(5, current), &font, expColor); 
    } 

    expressions = get_class_weights(features); 

    current = start - 3; 
    for(int i = 0; i < N_EXPRESSIONS; i++, current+=step) 
    { 
     //this is the line which display the green line but I want to display percentage. 
     cvLine(img, cvPoint(80, current), cvPoint((int)(80+expressions.at<double>(0,i)*50), current), expColor, 2); 
    } 

    current += step + step; 
    if(showFeatures == 1) 
    { 
     for(int i=0; i<N_FEATURES; i++) 
     { 
      current += step; 
      char buf[4]; 
      sprintf(buf, "%.2f", features.at<float>(0,i)); 
      cvPutText(img, buf, cvPoint(5, current), &font, expColor); 
     } 
    } 
} 
} 

답변

0

: 여기

코드의 일부입니다 변경하려는 행은 다음과 같습니다.

cvLine(img, cvPoint(80, current), cvPoint((int)(80+expressions.at<double>(0,i)*50), current), expColor, 2); 

으로 바꾸십시오.210 다음 :

// Assuming expressions.at<double>(0, i) returns a value between 0.0 and 
// 1.0, convert it to 0.0 to 100.0. 
double percentage = expressions.at<double>(0, i) * 100.0; 

// Format the string buffer to hold "{percentage} %" (e.g., "50 %"). 
char buf[6]; // 3 bytes for the percentage, 1 for the space, 1 for the "%", 1 for the null byte. 
sprintf(buf, "%3.f %%", percentage); 

// Display percentage. 
cvPutText(img, buf, cvPoint(80, current), &font, expColor); 
+0

정말 고마워요! – anshinanren

관련 문제