title: Visual Studio: C2027 Use of 'undefined-type' error when using concurrent_vector<matrix<rgb_pixel>> in an async function
body: <p>I created some async functions, that used the DLIB library,using std::future; so that I can have these functions directly called from my Socket server. But Visual Studio 2019 comes up with compile errors. </p>
  
  <p>Problematic Code from 'scan_fhog_pyramid.h'</p>
  
  <pre><code>if (feats.size() &gt; 1)
              {
                  typedef typename image_traits&lt;image_type&gt;::pixel_type pixel_type;
                  array2d&lt;pixel_type&gt; 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 &lt; feats.size(); ++i)
                  {
                      pyr(temp2, temp1);
                      fe(temp1, feats[i], cell_size,filter_rows_padding,filter_cols_padding);
                      swap(temp1,temp2);
                  }
              }
  </code></pre>
  
  <p>My async function</p>
  
  <pre><code> std::future&lt;Mat&gt; getProcessedFrame_task = std::async([&amp;]()
              {
                  VideoCapture vid_cap(0, CAP_DSHOW);
                  Mat frame;
                  if (!vid_cap.isOpened())
                  {
                      cout &lt;&lt; "Video capture device could not be initalised." &lt;&lt; endl;
                      cout &lt;&lt; "Empty vector will be returned." &lt;&lt; endl;
                      return Mat();
                  }
                  //Grab Frame from video capture device
                  vid_cap &gt;&gt; frame;
  
                  //Convert OpenCv frame to DLIB frame
                  dlib::cv_image&lt;rgb_pixel&gt; dlib_frame(frame);
  
                  //Vector to store Cropped Face Images
                  concurrent_vector&lt;matrix&lt;rgb_pixel&gt;&gt;croped_faces;
                  //Vector to store X Y Coordinates
                  concurrent_vector&lt;pair&lt;int, int&gt;&gt;xy_coords;
                  //Vector to store width-height  data
                  concurrent_vector &lt; pair&lt;int, int&gt;&gt; width_height;
  
                  //Run the Face Detector on dlib frame
                  auto detected_faces = this-&gt;f_detector(croped_faces);
  
                  //Process all detected faces
                  dlib::parallel_for(0, detected_faces.size(), [&amp;](long i)
                      {
                          //Get individual face from detected faces
                          auto face = detected_faces[i];
  
                          //Get the Shape details from the face
                          packaged_task &lt; dlib::full_object_detection()&gt;sd_task(bind(sp, dlib_frame, face));
                          auto sd_task_res = sd_task.get_future();
                          sd_task();
  
                          //Extract Face Image from frame
                          matrix&lt;rgb_pixel&gt; 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&lt;int, int&gt;(face.left(), face.top()));
                          //Add width-Height to vector
                          width_height.push_back(pair&lt;int, int&gt;(face.width(), face.height()));
                      });
  
                  //Vector to Store Face Descriptors
                  std::vector&lt;matrix&lt;float, 0, 1&gt;&gt; face_descriptors;
  
                  //Only run if faces are found
                  if (croped_faces.size() &gt; 0)
                  {
                      //Get Face Descriptors for all cropped faces.
                      face_descriptors = net(croped_faces);
  
                      //Process each Face Descriptor
                      dlib::parallel_for(0, face_descriptors.size(), [&amp;](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-&gt;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();
  </code></pre>
  
  <blockquote>
  <pre><code>C2027 : undefined type 'dlib::image_traits&lt;image_type&gt;'
  C4430: missing type specifier 
  C2146: Syntax error missing ';' before identifier 'pixel_type'
  </code></pre>
  </blockquote>