Visual Studio: C2027 Использование ошибки «неопределенный тип» при использовании concurrent_vector> в асинхронной функции - PullRequest
0 голосов
/ 08 июля 2019

Я создал несколько асинхронных функций, которые использовали библиотеку DLIB, используя std :: future; чтобы я мог напрямую вызывать эти функции с моего сервера Socket. Но Visual Studio 2019 приводит к ошибкам компиляции.

Проблемный код из 'scan_fhog_pyramid.h'

if (feats.size() > 1)
            {
                typedef typename image_traits<image_type>::pixel_type pixel_type;
                array2d<pixel_type> temp1, temp2;
                pyr(img, temp1);
                fe(temp1, feats[1], cell_size,filter_rows_padding,filter_cols_padding);
                swap(temp1,temp2);

                for (unsigned long i = 2; i < feats.size(); ++i)
                {
                    pyr(temp2, temp1);
                    fe(temp1, feats[i], cell_size,filter_rows_padding,filter_cols_padding);
                    swap(temp1,temp2);
                }
            }

Моя асинхронная функция

 std::future<Mat> getProcessedFrame_task = std::async([&]()
            {
                VideoCapture vid_cap(0, CAP_DSHOW);
                Mat frame;
                if (!vid_cap.isOpened())
                {
                    cout << "Video capture device could not be initalised." << endl;
                    cout << "Empty vector will be returned." << endl;
                    return Mat();
                }
                //Grab Frame from video capture device
                vid_cap >> frame;

                //Convert OpenCv frame to DLIB frame
                dlib::cv_image<rgb_pixel> dlib_frame(frame);

                //Vector to store Cropped Face Images
                concurrent_vector<matrix<rgb_pixel>>croped_faces;
                //Vector to store X Y Coordinates
                concurrent_vector<pair<int, int>>xy_coords;
                //Vector to store width-height  data
                concurrent_vector < pair<int, int>> width_height;

                //Run the Face Detector on dlib frame
                auto detected_faces = this->f_detector(croped_faces);

                //Process all detected faces
                dlib::parallel_for(0, detected_faces.size(), [&](long i)
                    {
                        //Get individual face from detected faces
                        auto face = detected_faces[i];

                        //Get the Shape details from the face
                        packaged_task < dlib::full_object_detection()>sd_task(bind(sp, dlib_frame, face));
                        auto sd_task_res = sd_task.get_future();
                        sd_task();

                        //Extract Face Image from frame
                        matrix<rgb_pixel> face_img;
                        extract_image_chip(dlib_frame, get_face_chip_details(sd_task_res.get(), 150, 0.25), face_img);
                        croped_faces.push_back(face_img);

                        //Add Corrdinates to vector
                        xy_coords.push_back(pair<int, int>(face.left(), face.top()));
                        //Add width-Height to vector
                        width_height.push_back(pair<int, int>(face.width(), face.height()));
                    });

                //Vector to Store Face Descriptors
                std::vector<matrix<float, 0, 1>> face_descriptors;

                //Only run if faces are found
                if (croped_faces.size() > 0)
                {
                    //Get Face Descriptors for all cropped faces.
                    face_descriptors = net(croped_faces);

                    //Process each Face Descriptor
                    dlib::parallel_for(0, face_descriptors.size(), [&](long i)
                        {
                            //Get individual descriptor
                            auto f_descriptor = face_descriptors[i];
                            //Get String Label for face descriptor
                            string face_name = m_trainer.Get_Face_Label(label_faceDescriptor, f_descriptor);

                            //TODO: Add overlays to the Open CV Frame

                            //Add Time Stamp to Frame
                            putText(frame, this->Get_Current_Date_Time(),
                                Point(50, vid_cap.get(4) - 10),
                                FONT_HERSHEY_COMPLEX,
                                1.0,
                                CV_RGB(0, 255, 0),
                                2);

                            //Add Face Name to Frame
                            putText(frame, //target image
                                face_name, //text
                                cv::Point(xy_coords[i].first, xy_coords[i].second + 25), //top-left position
                                cv::FONT_HERSHEY_DUPLEX,
                                1.0,
                                CV_RGB(0, 255, 0), //font color
                                2);

                        });

                }

                return frame;
            });
        return getProcessedFrame_task.get();
C2027 : undefined type 'dlib::image_traits<image_type>'
C4430: missing type specifier 
C2146: Syntax error missing ';' before identifier 'pixel_type'
...