Tencent / ncnn

ncnn is a high-performance neural network inference framework optimized for the mobile platform
Other
20.2k stars 4.15k forks source link

mobilenetssd, 做视频目标检测速度很慢 #1698

Open liulai opened 4 years ago

liulai commented 4 years ago

设备: cpu:Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz 2.71GHz GPU:inter(R) HD graphics 620 参考mobilenetssd.cpp代码 结构如下: static int detect_net(ncnn::Net& mobilenet, const cv::Mat& bgr, std::vector& objects) { //略 ncnn::Extractor ex = mobilenet.create_extractor(); ex.input("data", in); ncnn::Mat out; ex.extract("detection_out", out); //略}

int main() { //略

if NCNN_VULKAN

ncnn::create_gpu_instance();

endif // NCNN_VULKAN

ncnn::Net mobilenet = mobilenet_load();
ncnn::Extractor ex = mobilenet.create_extractor();
while (1) {
    lasttime = clock();
    cap.read(frame);
    if (frame.empty()) {
        cout << "the source is over." << endl;
        break;
    }
    cv::resize(frame, dst, cv::Size(frame.cols / 2, frame.rows / 2));
    std::vector<Object> objects;
    //detect_mobilenet(dst, objects);
    detect_net(mobilenet, dst, objects);
    draw_objects(dst, objects);
    if (cv::waitKey(1) >= 0) {
        break;
    }
    currtime = clock();
    int fps = static_cast<int>(1.f / (currtime - lasttime) * 1000);
    cout << "fps " << fps << endl;
}

if NCNN_VULKAN

ncnn::destroy_gpu_instance();

endif // NCNN_VULKAN

//略 }

实际结果fps:大概为4-6

maxuehao commented 4 years ago

https://github.com/dog-qiuqiu/MobileNetv2-YOLOV3 华为MATE30 可以跑33ms每帧