当前位置:   article > 正文

firefly-rk3399 开发记录8-NCNN检测_rk3399 vulkan

rk3399 vulkan

1.NCNN编译

NCNN就不描述了,这里采用NCNN最新的发布版ncnn-20200727,buildroot中的mk文件如下

  1. NCNN_VERSION = 20200727
  2. NCNN_SITE = $(call github,Tencent,ncnn,$(NCNN_VERSION))
  3. NCNN_INSTALL_STAGING = YES
  4. NCNN_LICENSE = BSD-2-Clause or GPL-2.0+
  5. NCNN_LICENSE_FILES = LICENSE
  6. NCNN_CONF_OPTS += -DNCNN_ARM82=OFF
  7. $(eval $(cmake-package))

NCNN_ARM82这个要稍微注意下,这里用不到的,但是编译的时候再cmakelists中,检测到arm之后就默认开启了,这里会编译出错.

2.retinaface

这里就直接采用NCNN历程中的retinaface.cpp了,基本都可以直接使用,模型文件在另外的仓库上https://github.com/nihui/ncnn-assets/tree/master/models

  1. QSmartNcnn::QSmartNcnn()
  2. {
  3. retinaface.opt.use_vulkan_compute = true;
  4. retinaface.opt.num_threads = 6;
  5. // model is converted from
  6. // https://github.com/deepinsight/insightface/tree/master/RetinaFace#retinaface-pretrained-models
  7. // https://github.com/deepinsight/insightface/issues/669
  8. // the ncnn model https://github.com/nihui/ncnn-assets/tree/master/models
  9. // retinaface.load_param("retinaface-R50.param");
  10. // retinaface.load_model("retinaface-R50.bin");
  11. int ret = retinaface.load_param("/root/ncnn-assets/models/mnet.25-opt.param");
  12. qDebug() << "load param " << ret;
  13. ret = retinaface.load_model("/root/ncnn-assets/models/mnet.25-opt.bin");
  14. qDebug() << "load bin " << ret;
  15. }
  16. QSmartNcnn::~QSmartNcnn()
  17. {
  18. }
  19. int QSmartNcnn::detect_face(const cv::Mat &image, QVector<QRect> &rect)
  20. {
  21. std::vector<FaceObject> faceobjects;
  22. qDebug() << "need do detect";
  23. if(detect_retinaface(image, faceobjects) < 0)
  24. return -1;
  25. qDebug() << faceobjects.size();
  26. for(auto &item : faceobjects)
  27. {
  28. rect.append(QRect(item.rect.x,item.rect.y,
  29. item.rect.width,item.rect.height));
  30. }
  31. return rect.size();
  32. }
  33. int QSmartNcnn::extract_feature(const cv::Mat &image, const QRect &rect, QByteArray &feature)
  34. {
  35. }
  36. void QSmartNcnn::qsort_descent_inplace(std::vector<FaceObject>& faceobjects, int left, int right)
  37. {
  38. int i = left;
  39. int j = right;
  40. float p = faceobjects[(left + right) / 2].prob;
  41. while (i <= j)
  42. {
  43. while (faceobjects[i].prob > p)
  44. i++;
  45. while (faceobjects[j].prob < p)
  46. j--;
  47. if (i <= j)
  48. {
  49. // swap
  50. std::swap(faceobjects[i], faceobjects[j]);
  51. i++;
  52. j--;
  53. }
  54. }
  55. #pragma omp parallel sections
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/284973
推荐阅读
相关标签
  

闽ICP备14008679号