質問編集履歴
2
文章変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
|
13
13
|
新しく加えた箇所は、以下のとおりです。
|
14
14
|
|
15
|
-
```
|
15
|
+
```
|
16
16
|
|
17
17
|
////////////////////////////////////////////////////
|
18
18
|
|
@@ -118,35 +118,7 @@
|
|
118
118
|
|
119
119
|
////////////////////////////////////////////////////
|
120
120
|
|
121
|
-
capture >> frame;
|
122
|
-
|
123
|
-
// (2)calculate the first image derivatives using an Sobel operator
|
124
|
-
|
125
|
-
Mat tmp_img, sobel_img, laplacian_img, canny_img;
|
126
|
-
|
127
|
-
Sobel(frame, tmp_img, CV_32F, 1, 1);
|
128
|
-
|
129
|
-
convertScaleAbs(tmp_img, sobel_img, 1, 0);
|
130
|
-
|
131
|
-
// (3)calculate the Laplacian of an image
|
132
|
-
|
133
|
-
Laplacian(frame, tmp_img, CV_32F, 3);
|
134
|
-
|
135
|
-
convertScaleAbs(tmp_img, laplacian_img, 1, 0);
|
136
|
-
|
137
|
-
// (4)implement the Canny algorithm for edge detection
|
138
|
-
|
139
|
-
Canny(frame, canny_img, 50, 200);
|
140
|
-
|
141
|
-
// (5)show original gray and their edge images respectively,
|
142
|
-
|
143
|
-
// and quit when any key pressed
|
144
|
-
|
145
|
-
imshow("Canny", canny_img);
|
146
|
-
|
147
|
-
|
121
|
+
上記のコードの場所
|
148
|
-
|
149
|
-
|
150
122
|
|
151
123
|
//////////////////////////////////////////
|
152
124
|
|
1
見やすさの改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -10,9 +10,49 @@
|
|
10
10
|
|
11
11
|
現在行おうとしていることが、リアルタイムで得た動画にエッジ検出を適応することです。
|
12
12
|
|
13
|
-
|
13
|
+
新しく加えた箇所は、以下のとおりです。
|
14
|
+
|
14
|
-
|
15
|
+
```加えた箇所
|
16
|
+
|
17
|
+
////////////////////////////////////////////////////
|
18
|
+
|
19
|
+
capture >> frame;
|
20
|
+
|
21
|
+
// (2)calculate the first image derivatives using an Sobel operator
|
22
|
+
|
23
|
+
Mat tmp_img, sobel_img, laplacian_img, canny_img;
|
24
|
+
|
25
|
+
Sobel(frame, tmp_img, CV_32F, 1, 1);
|
26
|
+
|
27
|
+
convertScaleAbs(tmp_img, sobel_img, 1, 0);
|
28
|
+
|
29
|
+
// (3)calculate the Laplacian of an image
|
30
|
+
|
31
|
+
Laplacian(frame, tmp_img, CV_32F, 3);
|
32
|
+
|
33
|
+
convertScaleAbs(tmp_img, laplacian_img, 1, 0);
|
34
|
+
|
35
|
+
// (4)implement the Canny algorithm for edge detection
|
36
|
+
|
37
|
+
Canny(frame, canny_img, 50, 200);
|
38
|
+
|
39
|
+
// (5)show original gray and their edge images respectively,
|
40
|
+
|
41
|
+
// and quit when any key pressed
|
42
|
+
|
43
|
+
imshow("Canny", canny_img);
|
44
|
+
|
45
|
+
waitKey(0);
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
//////////////////////////////////////////
|
50
|
+
|
51
|
+
```
|
52
|
+
|
53
|
+
|
54
|
+
|
15
|
-
下記が
|
55
|
+
下記が全体のコード文です。コード文の下に、実行した際のエラーを載せておきます。
|
16
56
|
|
17
57
|
よろしくお願いします。
|
18
58
|
|
@@ -416,8 +456,6 @@
|
|
416
456
|
|
417
457
|
static int max_neighbors=-1;
|
418
458
|
|
419
|
-
//int max_neighbors=-1;
|
420
|
-
|
421
459
|
static int min_neighbors=-1;
|
422
460
|
|
423
461
|
if (min_neighbors == -1)
|
@@ -432,34 +470,22 @@
|
|
432
470
|
|
433
471
|
//(現在の笑顔-笑顔の最小値)/(笑顔の最大値 - 笑顔の最小値 + 1)
|
434
472
|
|
435
|
-
//(float)img.rows
|
436
|
-
|
437
473
|
double rect_height = cvRound((float)img.rows* intensityZeroOne)/2;
|
438
474
|
|
439
475
|
char rectchar[256];
|
440
476
|
|
441
|
-
//char nowsmile[256];
|
442
|
-
|
443
477
|
char maxsmile[256];
|
444
478
|
|
445
479
|
char minsmile[256];
|
446
480
|
|
447
|
-
//char imgrow[256];
|
448
|
-
|
449
481
|
Scalar col = Scalar((float)255 * intensityZeroOne, 0, 0);
|
450
482
|
|
451
|
-
//cout<<img.rows<<endl;
|
452
|
-
|
453
483
|
sprintf(rectchar, "%f", rect_height);//対応しているのはdouble型
|
454
484
|
|
455
|
-
//sprintf(nowsmile, "%f", intensityZeroOne);//対応しているのはdouble型
|
456
|
-
|
457
485
|
sprintf(maxsmile, "%d", max_neighbors);//対応しているのはint型
|
458
486
|
|
459
487
|
sprintf(minsmile, "%d", min_neighbors);//対応しているのはint型
|
460
488
|
|
461
|
-
//sprintf(imgrow, "f", img.rows);
|
462
|
-
|
463
489
|
|
464
490
|
|
465
491
|
//greenline
|
@@ -490,8 +516,6 @@
|
|
490
516
|
|
491
517
|
{
|
492
518
|
|
493
|
-
//positive line
|
494
|
-
|
495
519
|
rectangle(img, cvPoint(0, 235), cvPoint(img.cols/10, 240-rect_height), CV_RGB(200,0,0), CV_FILLED);
|
496
520
|
|
497
521
|
putText(img, "GOOD", cvPoint(535,50), face[0], 1.2, cv::Scalar(0,0,200), 2, CV_AA);
|
@@ -502,22 +526,12 @@
|
|
502
526
|
|
503
527
|
{
|
504
528
|
|
505
|
-
//negative line
|
506
|
-
|
507
529
|
rectangle(img, cvPoint(0,245), cvPoint(img.cols/10,240-rect_height), CV_RGB(0,0,200), CV_FILLED);
|
508
530
|
|
509
531
|
putText(img, "BAD", cvPoint(535,50), face[0], 1.2, cv::Scalar(0,0,200), 2, CV_AA);
|
510
532
|
|
511
533
|
}
|
512
534
|
|
513
|
-
|
514
|
-
|
515
|
-
//文字や数字を囲む四角
|
516
|
-
|
517
|
-
//rectangle(img, cvPoint(400,430),cvPoint(630,395),CV_RGB(0,0,200), 3, 4);
|
518
|
-
|
519
|
-
//putText(img, rectchar, cv::Point(400,425), face[0], 1.2, cv::Scalar(0,0,200), 2, CV_AA);
|
520
|
-
|
521
535
|
}
|
522
536
|
|
523
537
|
imshow( "result", img );
|