xiaoshuizhu333 2016-08-13 12:34 采纳率: 0%
浏览 900

基于opencv的人脸描述,用语言来描述输入脸的特征。建了对象,数据显示都是0。跪求大神急急急!!!

我写了一个类Facedescribe,在main函数里建了一个这个类的对象a,运行后得到的数据都是0;如果直接把Eye1_Eye2()和Faceheight( )放在main函数里,得到的输出数据eye1_eye2和faceheight正常。跪求大神建的这个类不对吗,类Facedescribe和main函数如下:
class Facedescribe{
private:
double eye1_eye2; //两眼瞳孔之间的距离
double facewidth; //脸宽
double faceheight; //脸长
double nosewidth; //鼻子宽度
double mouthwidth; //嘴巴宽度

public:
Facedescribe() :eye1_eye2(0), facewidth(0), faceheight(0), nosewidth(0), mouthwidth(0){ }
//定位瞳孔,求出两眼瞳孔之间的距离
double Eye1_Eye2()
{
eye1_eye2 = sqrt(pow(cvRound(landmarks[38 * 2 + 1]) - cvRound(landmarks[39 * 2 + 1]), 2) + pow(cvRound(landmarks[38 * 2]) - cvRound(landmarks[39 * 2]), 2));
cout << "eye1_eye2 = " << eye1_eye2 << endl;
return eye1_eye2;
}
double faceheightb = eye1_eye2 * 8;//脸长与眼宽的黄金比例

double Faceheight( )
{
double faceheight = sqrt(pow(cvRound(landmarks[6 * 2 + 1]) - cvRound(landmarks[14 * 2 + 1]), 2) + pow(cvRound(landmarks[6 * 2]) - cvRound(landmarks[14 * 2]), 2));
cout << "faceheight = " << faceheight << endl;
return faceheight;
}
bool Facemodel()
{
if (faceheight > faceheightb)
{
cout << "长脸" << endl;
return true;
}
else
{
cout << "不是长脸" << endl;
return false;
}
}
};

int main()
{
//const char* const path = "../data";

cv::Mat_<unsigned char> img(cv::imread(path, CV_LOAD_IMAGE_GRAYSCALE));

if (!img.data)
{
    printf("Cannot load %s\n", path);
    exit(1);
}

int foundface;
float landmarks[2 * stasm_NLANDMARKS]; // x,y coords (note the 2)

if (!stasm_search_single(&foundface, landmarks,
    (const char*)img.data, img.cols, img.rows, path, "../data"))
{
    printf("Error in stasm_search_single: %s\n", stasm_lasterr());
    exit(1);
}

if (!foundface)
    printf("No face found in %s\n", path);
else
{
    // draw the landmarks on the image as white dots圆点 (image is monochrom单色的,黑白的)
    stasm_force_points_into_image(landmarks, img.cols, img.rows);
    for (int i = 0; i <stasm_NLANDMARKS; i++)
        img(cvRound(landmarks[i * 2 + 1]), cvRound(landmarks[i * 2])) = 255;    

}
cv::imwrite("minimal.bmp", img);
cv::imshow("stasm minimal", img);
cv::waitKey();
Facedescribe a;
a.Eye1_Eye2();
a.Faceheight();
a.Facemodel();
system("pause");
}
  • 写回答

1条回答 默认 最新

  • xiaoshuizhu333 2016-08-13 12:34
    关注

    建对象那儿是不是不对?

    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?