質問編集履歴
2
文章変更
    
        title	
    CHANGED
    
    | 
            File without changes
         | 
    
        body	
    CHANGED
    
    | @@ -5,7 +5,7 @@ | |
| 5 5 | 
             
            リアルタイム笑顔検出は、できるようになりました。
         | 
| 6 6 | 
             
            現在行おうとしていることが、リアルタイムで得た動画にエッジ検出を適応することです。
         | 
| 7 7 | 
             
            新しく加えた箇所は、以下のとおりです。
         | 
| 8 | 
            -
            ``` | 
| 8 | 
            +
            ```
         | 
| 9 9 | 
             
            ////////////////////////////////////////////////////
         | 
| 10 10 | 
             
              capture >> frame;
         | 
| 11 11 | 
             
              // (2)calculate the first image derivatives using an Sobel operator
         | 
| @@ -58,21 +58,7 @@ | |
| 58 58 | 
             
              double scale;
         | 
| 59 59 |  | 
| 60 60 | 
             
              ////////////////////////////////////////////////////
         | 
| 61 | 
            -
              capture >> frame;
         | 
| 62 | 
            -
              // (2)calculate the first image derivatives using an Sobel operator
         | 
| 63 | 
            -
              Mat tmp_img, sobel_img, laplacian_img, canny_img;
         | 
| 64 | 
            -
              Sobel(frame, tmp_img, CV_32F, 1, 1);
         | 
| 65 | 
            -
              convertScaleAbs(tmp_img, sobel_img, 1, 0);
         | 
| 66 | 
            -
              // (3)calculate the Laplacian of an image  
         | 
| 67 | 
            -
              Laplacian(frame, tmp_img, CV_32F, 3);
         | 
| 68 | 
            -
              convertScaleAbs(tmp_img, laplacian_img, 1, 0);
         | 
| 69 | 
            -
              // (4)implement the Canny algorithm for edge detection
         | 
| 70 | 
            -
              Canny(frame, canny_img, 50, 200);
         | 
| 71 | 
            -
              // (5)show original gray and their edge images respectively, 
         | 
| 72 | 
            -
              //    and quit when any key pressed
         | 
| 73 | 
            -
              imshow("Canny", canny_img);
         | 
| 74 | 
            -
               | 
| 61 | 
            +
              上記のコードの場所
         | 
| 75 | 
            -
             | 
| 76 62 | 
             
              //////////////////////////////////////////
         | 
| 77 63 |  | 
| 78 64 | 
             
              cv::CommandLineParser parser(argc, argv,
         | 
1
見やすさの改善
    
        title	
    CHANGED
    
    | 
            File without changes
         | 
    
        body	
    CHANGED
    
    | @@ -4,8 +4,28 @@ | |
| 4 4 |  | 
| 5 5 | 
             
            リアルタイム笑顔検出は、できるようになりました。
         | 
| 6 6 | 
             
            現在行おうとしていることが、リアルタイムで得た動画にエッジ検出を適応することです。
         | 
| 7 | 
            +
            新しく加えた箇所は、以下のとおりです。
         | 
| 8 | 
            +
            ```加えた箇所
         | 
| 9 | 
            +
            ////////////////////////////////////////////////////
         | 
| 10 | 
            +
              capture >> frame;
         | 
| 11 | 
            +
              // (2)calculate the first image derivatives using an Sobel operator
         | 
| 12 | 
            +
              Mat tmp_img, sobel_img, laplacian_img, canny_img;
         | 
| 13 | 
            +
              Sobel(frame, tmp_img, CV_32F, 1, 1);
         | 
| 14 | 
            +
              convertScaleAbs(tmp_img, sobel_img, 1, 0);
         | 
| 15 | 
            +
              // (3)calculate the Laplacian of an image  
         | 
| 16 | 
            +
              Laplacian(frame, tmp_img, CV_32F, 3);
         | 
| 17 | 
            +
              convertScaleAbs(tmp_img, laplacian_img, 1, 0);
         | 
| 18 | 
            +
              // (4)implement the Canny algorithm for edge detection
         | 
| 19 | 
            +
              Canny(frame, canny_img, 50, 200);
         | 
| 20 | 
            +
              // (5)show original gray and their edge images respectively, 
         | 
| 21 | 
            +
              //    and quit when any key pressed
         | 
| 22 | 
            +
              imshow("Canny", canny_img);
         | 
| 23 | 
            +
              waitKey(0);
         | 
| 7 24 |  | 
| 25 | 
            +
              //////////////////////////////////////////
         | 
| 26 | 
            +
            ```
         | 
| 27 | 
            +
             | 
| 8 | 
            -
            下記が | 
| 28 | 
            +
            下記が全体のコード文です。コード文の下に、実行した際のエラーを載せておきます。
         | 
| 9 29 | 
             
            よろしくお願いします。
         | 
| 10 30 |  | 
| 11 31 | 
             
            ```C++
         | 
| @@ -207,7 +227,6 @@ | |
| 207 227 | 
             
                  //accurate only after a first smile has been displayed by the user.
         | 
| 208 228 | 
             
                  const int smile_neighbors = (int)nestedObjects.size();
         | 
| 209 229 | 
             
                  static int max_neighbors=-1;
         | 
| 210 | 
            -
                  //int max_neighbors=-1;
         | 
| 211 230 | 
             
                  static int min_neighbors=-1;
         | 
| 212 231 | 
             
                  if (min_neighbors == -1)
         | 
| 213 232 | 
             
                    min_neighbors = smile_neighbors;
         | 
| @@ -215,20 +234,14 @@ | |
| 215 234 | 
             
                  // Draw rectangle on the left side of the image reflecting smile intensity
         | 
| 216 235 | 
             
                  float intensityZeroOne = ((float)smile_neighbors - min_neighbors) / (max_neighbors - min_neighbors + 1);
         | 
| 217 236 | 
             
                  //(現在の笑顔-笑顔の最小値)/(笑顔の最大値 - 笑顔の最小値 + 1)
         | 
| 218 | 
            -
                  //(float)img.rows
         | 
| 219 237 | 
             
                double rect_height = cvRound((float)img.rows* intensityZeroOne)/2;
         | 
| 220 238 | 
             
                char rectchar[256];
         | 
| 221 | 
            -
                //char nowsmile[256];
         | 
| 222 239 | 
             
                char maxsmile[256];
         | 
| 223 240 | 
             
                char minsmile[256];
         | 
| 224 | 
            -
                //char imgrow[256];
         | 
| 225 241 | 
             
                Scalar col = Scalar((float)255 * intensityZeroOne, 0, 0);
         | 
| 226 | 
            -
                //cout<<img.rows<<endl;
         | 
| 227 242 | 
             
                sprintf(rectchar, "%f", rect_height);//対応しているのはdouble型
         | 
| 228 | 
            -
                //sprintf(nowsmile, "%f", intensityZeroOne);//対応しているのはdouble型
         | 
| 229 243 | 
             
                sprintf(maxsmile, "%d", max_neighbors);//対応しているのはint型
         | 
| 230 244 | 
             
                sprintf(minsmile, "%d", min_neighbors);//対応しているのはint型
         | 
| 231 | 
            -
                //sprintf(imgrow, "f", img.rows);
         | 
| 232 245 |  | 
| 233 246 | 
             
                //greenline
         | 
| 234 247 | 
             
                line(img,Point(0,240), Point(70,240), Scalar(0,200,0), 5, CV_AA);
         | 
| @@ -244,20 +257,14 @@ | |
| 244 257 |  | 
| 245 258 | 
             
                if(rect_height>0)
         | 
| 246 259 | 
             
                  {
         | 
| 247 | 
            -
            	//positive line
         | 
| 248 260 | 
             
            	rectangle(img, cvPoint(0, 235), cvPoint(img.cols/10, 240-rect_height), CV_RGB(200,0,0), CV_FILLED);
         | 
| 249 261 | 
             
            	putText(img, "GOOD", cvPoint(535,50), face[0], 1.2, cv::Scalar(0,0,200), 2, CV_AA);
         | 
| 250 262 | 
             
                  }
         | 
| 251 263 | 
             
                else
         | 
| 252 264 | 
             
                  {
         | 
| 253 | 
            -
            	//negative line
         | 
| 254 265 | 
             
            	rectangle(img, cvPoint(0,245), cvPoint(img.cols/10,240-rect_height), CV_RGB(0,0,200), CV_FILLED);
         | 
| 255 266 | 
             
            	putText(img, "BAD", cvPoint(535,50), face[0], 1.2, cv::Scalar(0,0,200), 2, CV_AA);
         | 
| 256 267 | 
             
                  }
         | 
| 257 | 
            -
             | 
| 258 | 
            -
                //文字や数字を囲む四角
         | 
| 259 | 
            -
                //rectangle(img, cvPoint(400,430),cvPoint(630,395),CV_RGB(0,0,200), 3, 4);
         | 
| 260 | 
            -
                //putText(img, rectchar, cv::Point(400,425), face[0], 1.2, cv::Scalar(0,0,200), 2, CV_AA);
         | 
| 261 268 | 
             
                }
         | 
| 262 269 | 
             
              imshow( "result", img );
         | 
| 263 270 | 
             
            }
         | 
