简体   繁体   English

使用flandmark(Javacv)显示每个关键点的协调

[英]Show coordinated for each keypoints using flandmark (Javacv)

I am currently using this example from flandmark using JavaCV. 我目前正在使用JavaCV从flandmark使用此示例。 Refer to: https://github.com/bytedeco/javacv-examples/blob/master/flandmark-demo/src/main/java/flandmark/Example1.java . 请参阅: https : //github.com/bytedeco/javacv-examples/blob/master/flandmark-demo/src/main/java/flandmark/Example1.java I managed to run the code but is there a way that I could display the coordinated of each of the key point from the face (eye, mouth, nose)? 我设法运行了代码,但是有没有办法显示人脸(眼睛,嘴巴,鼻子)每个关键点的坐标呢? There are around 7/8 key points that could be detected by the flandmark library. flandmark库可以检测到大约7/8个关键点。 Thanks. 谢谢。

You find landmarks in function detectFaceInImage . 您可以在函数detectFaceInImage找到界标。 At the bottom of the same function you see how to draw the detected landmarks on the face: 在同一功能的底部,您将看到如何在面部上绘制检测到的界标:

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 is a int[] containing the coordinates of the face bounding box as: bbox是一个int[]包含如下形式的面部边界框的坐标:

int[0] -> top left x
int[1] -> top left y
int[2] -> bottom right x
int[3] -> bottom right y

landmarks is a double[] , containing the coordinates of the points of the landmark in sequence: landmarksdouble[] ,按顺序包含标志点的坐标:

index: 0   1   2   3   ...
coord: s0x s0y s1x s1y ...

with reference to the image from the flandmark homepage 参考flandmark主页上的图片

在此处输入图片说明

The total number of landmarks is stored in model.data().options().M() . 地标总数存储在model.data().options().M() Now you have all the basics to print the coordinates of the landmarks: 现在,您已经具备了打印地标坐标的所有基础知识:

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]) + ")");
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM