您可以在功能detectFaceInImage
中找到地標。在相同功能的底部,你看如何繪製面部檢測的地標:
flandmark_detect(input, bbox, model, landmarks);
// display landmarks
cvRectangle(orig, cvPoint(bbox[0], bbox[1]), cvPoint(bbox[2], bbox[3]), CV_RGB(255, 0, 0));
cvRectangle(orig,
cvPoint((int) model.bb().get(0), (int) model.bb().get(1)),
cvPoint((int) model.bb().get(2), (int) model.bb().get(3)), CV_RGB(0, 0, 255));
cvCircle(orig,
cvPoint((int) landmarks[0], (int) landmarks[1]), 3, CV_RGB(0, 0, 255), CV_FILLED, 8, 0);
for (int i = 2; i < 2 * model.data().options().M(); i += 2) {
cvCircle(orig, cvPoint((int) (landmarks[i]), (int) (landmarks[i + 1])), 3, CV_RGB(255, 0, 0), CV_FILLED, 8, 0);
}
bbox
是包含臉部邊界框的座標作爲int[]
:
int[0] -> top left x
int[1] -> top left y
int[2] -> bottom right x
int[3] -> bottom right y
landmarks
是double[]
,其中包含地標點順序的座標:
index: 0 1 2 3 ...
coord: s0x s0y s1x s1y ...
with從flandmark homepage
參照圖像的地標總數被存儲在model.data().options().M()
。現在,您已具備了打印地標座標的所有基本知識:
for (int i = 0; i < 2 * model.data().options().M(); i += 2) {
System.out.println("S" + (i/2) + ": (" + (int)(landmarks[i]) + ", " + (int)(landmarks[i+1]) + ")");
}