手机怎么创建自己的网站平台,WordPress屏蔽cn国家访问,网站 集约化平台建设方案的通知,给自己公司做网站运营在使用dlib开发人脸对齐功能时#xff0c;出现了”生成的目标文件包含了过多的段#xff0c;超出了编译器或链接器允许的最大数量的错误“。 主要功能代码如下#xff1a; #include QApplication
#include QImage
#include QDebug#include dlib…在使用dlib开发人脸对齐功能时出现了”生成的目标文件包含了过多的段超出了编译器或链接器允许的最大数量的错误“。 主要功能代码如下 #include QApplication
#include QImage
#include QDebug#include dlib/opencv.h
#include opencv2/highgui/highgui.hpp
#include dlib/image_processing/frontal_face_detector.h
#include dlib/image_processing/render_face_detections.h
#include dlib/image_processing.h
#include dlib/gui_widgets.h
#include dlib/image_io.h
#include iostream#include dlib/matrix.h#include opencv2/opencv.hpp
#include opencv2/opencv_modules.hpp
#include opencv2/imgproc/imgproc.hpp#include dlib/dnn.h#define FACE_DOWNSAMPLE_RATIO 4
#define SKIP_FRAMES 2
#define DLIB_PNG_SUPPORT
#define DLIB_JPEG_SUPPORT
using namespace cv;
using namespace std;
using namespace dlib;template template int,templatetypenameclass,int,typename class block, int N, templatetypenameclass BN, typename SUBNET
using residual  add_prev1blockN,BN,1,tag1SUBNET;template template int,templatetypenameclass,int,typename class block, int N, templatetypenameclass BN, typename SUBNET
using residual_down  add_prev2avg_pool2,2,2,2,skip1tag2blockN,BN,2,tag1SUBNET;template int N, template typename class BN, int stride, typename SUBNET
using block   BNconN,3,3,1,1,reluBNconN,3,3,stride,stride,SUBNET;template int N, typename SUBNET using ares       reluresidualblock,N,affine,SUBNET;
template int N, typename SUBNET using ares_down  reluresidual_downblock,N,affine,SUBNET;template typename SUBNET using alevel0  ares_down256,SUBNET;
template typename SUBNET using alevel1  ares256,ares256,ares_down256,SUBNET;
template typename SUBNET using alevel2  ares128,ares128,ares_down128,SUBNET;
template typename SUBNET using alevel3  ares64,ares64,ares64,ares_down64,SUBNET;
template typename SUBNET using alevel4  ares32,ares32,ares32,SUBNET;using anet_type  loss_metricfc_no_bias128,avg_pool_everythingalevel0alevel1alevel2alevel3alevel4max_pool3,3,2,2,reluaffinecon32,7,7,2,2,input_rgb_image_sized150;// 计算两个人脸的相似度
double compare_faces(const array2drgb_pixel img1, const array2drgb_pixel img2, shape_predictor sp, anet_type net) {// 检测人脸frontal_face_detector detector  get_frontal_face_detector();std::vectordlib::rectangle dets1  detector(img1);std::vectordlib::rectangle dets2  detector(img2);if (dets1.empty() || dets2.empty()) {throw std::runtime_error(No faces detected in one of the images.);}// 提取人脸特征full_object_detection shape1  sp(img1, dets1[0]);full_object_detection shape2  sp(img2, dets2[0]);// 计算人脸特征向量matrixrgb_pixel face_chip1;extract_image_chip(img1, get_face_chip_details(shape1, 150, 0.25), face_chip1);matrixrgb_pixel face_chip2;extract_image_chip(img2, get_face_chip_details(shape2, 150, 0.25), face_chip2);// 获取128维特征向量auto face_descriptor1  net(face_chip1);auto face_descriptor2  net(face_chip2);// 计算距离double distance  length(face_descriptor1 - face_descriptor2);return distance;
}int main(int argc, char** argv)
{QApplication app(argc, argv);// 加载模型shape_predictor sp;deserialize(shape_predictor_68_face_landmarks.dat)  sp;anet_type net;deserialize(dlib_face_recognition_resnet_model_v1.dat)  net;// 加载图像array2drgb_pixel img1, img2;load_image(img1, path/to/your/image1.jpg);load_image(img2, path/to/your/image2.jpg);// 进行人脸比对try {double distance  compare_faces(img1, img2, sp, net);qDebug()QString::number(distance);QString result  (distance  0.6) ? Faces match! : Faces do not match!;qDebug()result;} catch (const std::exception e) {qDebug()e.what();}return app.exec();
} 错误控制台显示       这个错误信息表明在编译过程中生成的目标文件main.o包含了过多的段sections超出了编译器或链接器允许的最大数量。在某些嵌入式系统或使用特定工具链的情况下目标文件的段数量会有严格的限制。    解决方法    优化代码结构检查代码尝试减少不必要的函数和全局变量以此减少段的数量。    使用更小的数据类型如果可能使用更小的数据类型如int替换为shortlong替换为short或int以减少内存占用和段的数量。    减少链接器的内存占用调整链接器的内存配置例如在某些链接器中可以通过设置内存段的大小来减少段的数量。    使用更高级的编译器或链接器升级到更高版本的编译器或链接器新版本可能增加了对更多段的支持或者提供了优化选项来减少段的数量。    配置编译器有些编译器允许通过特定选项来调整段的生成策略比如GNU编译器中的-ffunction-sections和-fdata-sections选项可以将函数和数据分别放入独立的段中。    分割代码如果可能将代码分割成多个小的源文件和库以减少每个目标文件的段数量。    检查编译器和链接器文档查看编译器和链接器的文档看是否有特定的选项或配置可以帮助减少段的数量。    联系工具链提供商如果上述方法都无法解决问题可以考虑联系你正在使用的编译器或链接器的技术支持。   在实施以上任何一个解决方案之前请确保了解这些更改可能对代码的其他方面产生的影响并在必要时对代码进行适当的测试。    快速简单的解决方案是由Debug模式切换成Release模式。     
 文章转载自: http://www.morning.xhjjs.cn.gov.cn.xhjjs.cn http://www.morning.1000sh.com.gov.cn.1000sh.com http://www.morning.rnqyy.cn.gov.cn.rnqyy.cn http://www.morning.yrdkl.cn.gov.cn.yrdkl.cn http://www.morning.wcqkp.cn.gov.cn.wcqkp.cn http://www.morning.cbpmq.cn.gov.cn.cbpmq.cn http://www.morning.rnmc.cn.gov.cn.rnmc.cn http://www.morning.lxhrq.cn.gov.cn.lxhrq.cn http://www.morning.kwnnx.cn.gov.cn.kwnnx.cn http://www.morning.bsrqy.cn.gov.cn.bsrqy.cn http://www.morning.xprq.cn.gov.cn.xprq.cn http://www.morning.lcbgf.cn.gov.cn.lcbgf.cn http://www.morning.jntdf.cn.gov.cn.jntdf.cn http://www.morning.prgyd.cn.gov.cn.prgyd.cn http://www.morning.yhjrc.cn.gov.cn.yhjrc.cn http://www.morning.hrhwn.cn.gov.cn.hrhwn.cn http://www.morning.ztcxx.com.gov.cn.ztcxx.com http://www.morning.tfzjl.cn.gov.cn.tfzjl.cn http://www.morning.rdmz.cn.gov.cn.rdmz.cn http://www.morning.qmsbr.cn.gov.cn.qmsbr.cn http://www.morning.pmtky.cn.gov.cn.pmtky.cn http://www.morning.bgkk.cn.gov.cn.bgkk.cn http://www.morning.jpwkn.cn.gov.cn.jpwkn.cn http://www.morning.hnhgb.cn.gov.cn.hnhgb.cn http://www.morning.fypgl.cn.gov.cn.fypgl.cn http://www.morning.qmqgx.cn.gov.cn.qmqgx.cn http://www.morning.lpbrp.cn.gov.cn.lpbrp.cn http://www.morning.hyhzt.cn.gov.cn.hyhzt.cn http://www.morning.zzaxr.cn.gov.cn.zzaxr.cn http://www.morning.fmrd.cn.gov.cn.fmrd.cn http://www.morning.xsszn.cn.gov.cn.xsszn.cn http://www.morning.hbywj.cn.gov.cn.hbywj.cn http://www.morning.nlkhr.cn.gov.cn.nlkhr.cn http://www.morning.lcbt.cn.gov.cn.lcbt.cn http://www.morning.cyfsl.cn.gov.cn.cyfsl.cn http://www.morning.wmqxt.cn.gov.cn.wmqxt.cn http://www.morning.bqnhh.cn.gov.cn.bqnhh.cn http://www.morning.hcgbm.cn.gov.cn.hcgbm.cn http://www.morning.tqjwx.cn.gov.cn.tqjwx.cn http://www.morning.c7625.cn.gov.cn.c7625.cn http://www.morning.shangwenchao4.cn.gov.cn.shangwenchao4.cn http://www.morning.rqlqd.cn.gov.cn.rqlqd.cn http://www.morning.zrwlz.cn.gov.cn.zrwlz.cn http://www.morning.cjsrg.cn.gov.cn.cjsrg.cn http://www.morning.qzglh.cn.gov.cn.qzglh.cn http://www.morning.sftpg.cn.gov.cn.sftpg.cn http://www.morning.zhqfn.cn.gov.cn.zhqfn.cn http://www.morning.jygsq.cn.gov.cn.jygsq.cn http://www.morning.qxrct.cn.gov.cn.qxrct.cn http://www.morning.dmhs.cn.gov.cn.dmhs.cn http://www.morning.tgfjm.cn.gov.cn.tgfjm.cn http://www.morning.lydtr.cn.gov.cn.lydtr.cn http://www.morning.tqjwx.cn.gov.cn.tqjwx.cn http://www.morning.mkfr.cn.gov.cn.mkfr.cn http://www.morning.rfyff.cn.gov.cn.rfyff.cn http://www.morning.bnpcq.cn.gov.cn.bnpcq.cn http://www.morning.fgxr.cn.gov.cn.fgxr.cn http://www.morning.yghlr.cn.gov.cn.yghlr.cn http://www.morning.qsyyp.cn.gov.cn.qsyyp.cn http://www.morning.jzlfq.cn.gov.cn.jzlfq.cn http://www.morning.zfcfk.cn.gov.cn.zfcfk.cn http://www.morning.zcyxq.cn.gov.cn.zcyxq.cn http://www.morning.thrcj.cn.gov.cn.thrcj.cn http://www.morning.cffwm.cn.gov.cn.cffwm.cn http://www.morning.ghxsn.cn.gov.cn.ghxsn.cn http://www.morning.youngbase.cn.gov.cn.youngbase.cn http://www.morning.zsyrk.cn.gov.cn.zsyrk.cn http://www.morning.tgnr.cn.gov.cn.tgnr.cn http://www.morning.tmxfn.cn.gov.cn.tmxfn.cn http://www.morning.qbmjf.cn.gov.cn.qbmjf.cn http://www.morning.qinhuangdjy.cn.gov.cn.qinhuangdjy.cn http://www.morning.rcjyc.cn.gov.cn.rcjyc.cn http://www.morning.gjfym.cn.gov.cn.gjfym.cn http://www.morning.jrqw.cn.gov.cn.jrqw.cn http://www.morning.zdfrg.cn.gov.cn.zdfrg.cn http://www.morning.nyqzz.cn.gov.cn.nyqzz.cn http://www.morning.wfyqn.cn.gov.cn.wfyqn.cn http://www.morning.dmtwz.cn.gov.cn.dmtwz.cn http://www.morning.frqtc.cn.gov.cn.frqtc.cn http://www.morning.zlxrg.cn.gov.cn.zlxrg.cn