Hello
I have a project that through yolo   libtorch c++ I can identify the bounding box of an object that is personal. Now I want to crop and save the image of each bounding box so that I can pass this image to a function of the face recognition dll in C ++ that can return each person’s name.
Thank you very much for your help on how I can write this code.
I use the following code.

  

      github.com
  

  
    Nebula4869/YOLOv5-LibTorch/blob/master/src/YOLOv5LibTorch.cpp 1


    #include <opencv2/opencv.hpp>
#include <torch/script.h>
#include <algorithm>
#include <iostream>
#include <time.h>


std::vector<torch::Tensor> non_max_suppression(torch::Tensor preds, float score_thresh=0.5, float iou_thresh=0.5)
{
        std::vector<torch::Tensor> output;
        for (size_t i=0; i < preds.sizes()[0]; ++i)
        {
            torch::Tensor pred = preds.select(0, i);
            
            // Filter by scores
            torch::Tensor scores = pred.select(1, 4) * std::get<0>( torch::max(pred.slice(1, 5, pred.sizes()[1]), 1));
            pred = torch::index_select(pred, 0, torch::nonzero(scores > score_thresh).select(1, 0));
            if (pred.sizes()[0] == 0) continue;

            // (center_x, center_y, w, h) to (left, top, right, bottom)



  This file has been truncated. show original

  

  
    
    
  

  


This is the code I added, but I do not know exactly how to crop the bounding box and recognize its face.

importFunction ProcessFrame1;

   std::vector<std::string> result;

   HINSTANCE hinstLib;

   hinstLib = LoadLibrary(L"D:\\c++\\Project4\\x64\\Debug\\detect-camera-demo.dll");

   if (hinstLib == NULL) {
       printf("ERROR: unable to load DLL\n");
       return 1;
   }

   // Get function pointer
   ProcessFrame1 = (importFunction)GetProcAddress((hinstLib), "ProcessFrame");

   if (ProcessFrame1 == NULL) {
       printf("ERROR: unable to find DLL function\n");
       FreeLibrary(hinstLib);
       return 1;
   }

    

  //   Call function.
        result = ProcessFrame1(testcrop);


        for (size_t i = 0; i < result.size(); i++)
        {
            std::cout << " reslut name is : " << result[i] << "\n";
        }

        // Unload DLL file 
        FreeLibrary(hinstLib);
        
       

        cv::imwrite(" test_image.jpg", frame);

        /*if (cv::waitKey(1) == 27) break;*/
        
        cv::waitKey(10);
        system("pause");
    //}

    return 0;
}