赞
踩
NCNN就不描述了,这里采用NCNN最新的发布版ncnn-20200727,buildroot中的mk文件如下
-
- NCNN_VERSION = 20200727
- NCNN_SITE = $(call github,Tencent,ncnn,$(NCNN_VERSION))
- NCNN_INSTALL_STAGING = YES
- NCNN_LICENSE = BSD-2-Clause or GPL-2.0+
- NCNN_LICENSE_FILES = LICENSE
- NCNN_CONF_OPTS += -DNCNN_ARM82=OFF
-
- $(eval $(cmake-package))
NCNN_ARM82这个要稍微注意下,这里用不到的,但是编译的时候再cmakelists中,检测到arm之后就默认开启了,这里会编译出错.
这里就直接采用NCNN历程中的retinaface.cpp了,基本都可以直接使用,模型文件在另外的仓库上https://github.com/nihui/ncnn-assets/tree/master/models
- QSmartNcnn::QSmartNcnn()
- {
- retinaface.opt.use_vulkan_compute = true;
- retinaface.opt.num_threads = 6;
- // model is converted from
- // https://github.com/deepinsight/insightface/tree/master/RetinaFace#retinaface-pretrained-models
- // https://github.com/deepinsight/insightface/issues/669
- // the ncnn model https://github.com/nihui/ncnn-assets/tree/master/models
- // retinaface.load_param("retinaface-R50.param");
- // retinaface.load_model("retinaface-R50.bin");
- int ret = retinaface.load_param("/root/ncnn-assets/models/mnet.25-opt.param");
- qDebug() << "load param " << ret;
- ret = retinaface.load_model("/root/ncnn-assets/models/mnet.25-opt.bin");
- qDebug() << "load bin " << ret;
- }
-
- QSmartNcnn::~QSmartNcnn()
- {
-
- }
-
- int QSmartNcnn::detect_face(const cv::Mat &image, QVector<QRect> &rect)
- {
- std::vector<FaceObject> faceobjects;
- qDebug() << "need do detect";
- if(detect_retinaface(image, faceobjects) < 0)
- return -1;
- qDebug() << faceobjects.size();
- for(auto &item : faceobjects)
- {
- rect.append(QRect(item.rect.x,item.rect.y,
- item.rect.width,item.rect.height));
- }
- return rect.size();
- }
-
- int QSmartNcnn::extract_feature(const cv::Mat &image, const QRect &rect, QByteArray &feature)
- {
-
- }
-
-
-
-
- void QSmartNcnn::qsort_descent_inplace(std::vector<FaceObject>& faceobjects, int left, int right)
- {
- int i = left;
- int j = right;
- float p = faceobjects[(left + right) / 2].prob;
-
- while (i <= j)
- {
- while (faceobjects[i].prob > p)
- i++;
-
- while (faceobjects[j].prob < p)
- j--;
-
- if (i <= j)
- {
- // swap
- std::swap(faceobjects[i], faceobjects[j]);
-
- i++;
- j--;
- }
- }
-
- #pragma omp parallel sections
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。