باسلام
من یک کدی به زبان سی پلاس پلاس نوشتم حالا میخواهم یک تابعی رو extern کنم که بعدا بتونم از این تابع در سی شارپ استفاده کنم تا اونجایی که میدونم سی شارپ وکتور متوجه نمیشه میخواستم راهنمایی ام کنید چطوری میتونم این کد را تغییر بدهم بتونم در سی شارپ فراخوانی کنم و ازش استفادهکنم


extern "C" __declspec(dllexport) std::vector<std::vector<double>> __cdecl PrepareFaceBank(std::string Path);



تابعی که قصد دارم در سی شارپ استفاده کنم اینه :




std::vector<std::vector<double>> PrepareFaceBank(std::string Path)
{
try
{
//load model (if it has been loaded any where else just comment it)
FaceModule = torch::jit::load(FaceModulePath);


std::cout << "Model loaded successfully" << std::endl;
//Disable grad for high performance beacuase this is pretrained model
torch::NoGradGuard no_grad;
//an array to save all persons tensor in it
std::vector<torch::Tensor> embeddings;
//itterate through facebank directory
for (const auto& name : get_folderPath(Path))
{
std::cout << "name :" << name.filename() << ": " << '\n';


//array to save all of the photos of each person
std::vector<torch::Tensor> embs;
//clear befor itterate through all photos of each person
embs.clear();
//int a = 0;
for (const auto& fileName : get_filenames(name))
{
//std::cout <<'\t' << fileName << std::endl;


Mat image = imread(fileName);


/* Display if needed:
cv::namedWindow("Display window");// Create a window for display.
cv::imshow("Display window", image);
cv::waitKey(0);
*/


embs.push_back(ProcessFrame(image));
//empty cache
image.release();
//how many photos each person have
//std::cout << '\t' << a++ << std::endl;
}


//number of photos in data base for this person
//std::cout << "embs size: " << embs.size() << "\n";
//convert vector to tensorlist and the calculate the Mean value for all of the photos of each person
torch::Tensor embedding; // 1*512
torch::TensorList tensor_list{ embs };
embedding = torch::mean(torch::cat(tensor_list), 0);


embeddings.push_back(embedding);
}
std::vector<double> EachPersonVec;
std::vector<std::vector<double> > retValue;
for (const auto& n : embeddings)
{


EachPersonVec.clear();
for (int i = 0; i < 512; i++)
{
EachPersonVec.push_back(n[i].item().to<double>());
}


retValue.push_back(EachPersonVec);
}
//number of persons in database
std::cout << "embeddings size : " << embeddings.size() << "\n";


return retValue;
}
catch (const std::exception& e)
{
std::cout << e.what() << std::endl;


}




}