質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
dlib

dlibは、機械学習のC++の画像処理ライブラリの一つ。性能の高い顔の器官検出が簡単にでき、Pythonバインドもあります。オープンソースで無料で使用でき、機械学習以外の様々な機能も搭載されています。

OpenCV

OpenCV(オープンソースコンピュータービジョン)は、1999年にインテルが開発・公開したオープンソースのコンピュータビジョン向けのクロスプラットフォームライブラリです。

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

Q&A

解決済

1回答

1189閲覧

dlib.get_frontal_face_detector(img, 1)の第2引数に指定されている1の意味が分かりません

rouka

総合スコア1

dlib

dlibは、機械学習のC++の画像処理ライブラリの一つ。性能の高い顔の器官検出が簡単にでき、Pythonバインドもあります。オープンソースで無料で使用でき、機械学習以外の様々な機能も搭載されています。

OpenCV

OpenCV(オープンソースコンピュータービジョン)は、1999年にインテルが開発・公開したオープンソースのコンピュータビジョン向けのクロスプラットフォームライブラリです。

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

0グッド

0クリップ

投稿2022/04/06 12:45

以下は秀和システムの『Python 実践データ分析 100本ノック』のP220、ノック86のコードです。

Python3

1import cv2 2import dlib 3import math 4 5# 準備 # 6predictor = dlib.shape_predictor("shape_predictor_68_face_landmarks.dat") 7detector = dlib.get_frontal_face_detector() 8 9# 検出 # 10img = cv2.imread("img/img02.jpg") 11dets = detector(img, 1) 12 13for k, d in enumerate(dets): 14 shape = predictor(img, d) 15 16 # 顔領域の表示 17 color_f = (0, 0, 225) 18 color_l_out = (255, 0, 0) 19 color_l_in = (0, 255, 0) 20 line_w = 3 21 circle_r = 3 22 fontType = cv2.FONT_HERSHEY_SIMPLEX 23 fontSize = 1 24 cv2.rectangle(img, (d.left(), d.top()), (d.right(), d.bottom()), color_f, line_w) 25 cv2.putText(img, str(k), (d.left(), d.top()), fontType, fontSize, color_f, line_w) 26 27 # 重心を導出する箱を用意 28 num_of_points_out = 17 29 num_of_points_in = shape.num_parts - num_of_points_out 30 gx_out = 0 31 gy_out = 0 32 gx_in = 0 33 gy_in = 0 34 for shape_point_count in range(shape.num_parts): 35 shape_point = shape.part(shape_point_count) 36 #print("顔器官No.{} 座標位置: ({},{})".format(shape_point_count, shape_point.x, shape_point.y)) 37 #器官ごとに描画 38 if shape_point_count<num_of_points_out: 39 cv2.circle(img,(shape_point.x, shape_point.y),circle_r,color_l_out, line_w) 40 gx_out = gx_out + shape_point.x/num_of_points_out 41 gy_out = gy_out + shape_point.y/num_of_points_out 42 else: 43 cv2.circle(img,(shape_point.x, shape_point.y),circle_r,color_l_in, line_w) 44 gx_in = gx_in + shape_point.x/num_of_points_in 45 gy_in = gy_in + shape_point.y/num_of_points_in 46 47 # 重心位置を描画 48 cv2.circle(img,(int(gx_out), int(gy_out)),circle_r,(0,0,255), line_w) 49 cv2.circle(img,(int(gx_in), int(gy_in)),circle_r,(0,0,0), line_w) 50 51 # 顔の方位を計算 52 theta = math.asin(2*(gx_in-gx_out)/(d.right()-d.left())) 53 radian = theta*180/math.pi 54 print("顔方位:{} (角度:{}度)".format(theta,radian)) 55 56 # 顔方位を表示 57 if radian<0: 58 textPrefix = " left " 59 else: 60 textPrefix = " right " 61 textShow = textPrefix + str(round(abs(radian),1)) + " deg." 62 cv2.putText(img, textShow, (d.left(), d.top()), fontType, fontSize, color_f, line_w) 63 64 65cv2.imshow("img",img) 66cv2.imwrite("temp.jpg",img) 67cv2.waitKey(0)

ここで分からない部分があります。

dets = detector(img, 1)

の第2引数の1はいったい何を意味しているのでしょうか?
マニュアルを読んだり検索したのですが、よく分かりませんでした。

お答えいただけたらありがたいです。
宜しくお願い致します。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

投稿2022/04/06 22:42

jbpb0

総合スコア7651

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

rouka

2022/04/08 12:18

教えて頂きありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問