Mongocxx How can I access the view from the cursor faster

I have an opencv code and it needs to run very fast, faster than all loops in opencv. That’s why I added most of the processes to the database, but when everything is very fast, accessing the view from the cursor is slow, according to the opencv codes.

I want to reach the view from the cursor faster. Is there any other way around this? For example, can I write a function or something so that mongocxx returns direct view to me?

I did the following operations. I share the operations with their elapsed time. I would be very happy if you can help.

void MongoDB::SecondPointIteration(cv::KeyPoint&keypoints, SecondIterParams& secondIterParams ){

auto start1 = std::chrono::steady_clock::now(); 

    secondParams = secondIterParams;  
    mongocxx::pipeline secondIterPipeline = setSorgu();
    mongocxx::cursor cursor = features.aggregate(secondIterPipeline, mongocxx::options::aggregate{});

auto end1  = std::chrono::steady_clock::now();
auto time = std::chrono::duration_cast<std::chrono::microseconds>(end1-start1).count();
std::cout<<"2.1:   \t"<< time<<"ms"<<std::endl;
    
auto start3 = std::chrono::steady_clock::now(); 
    for(auto&& doc : cursor) {      
    auto end3  = std::chrono::steady_clock::now();
    auto time3 = std::chrono::duration_cast<std::chrono::microseconds>(end3-start3).count();
    std::cout<<"2.2.1:   \t"<< time3<<"ms"<<std::endl;

    auto start2 = std::chrono::steady_clock::now();
        ...
        keypoints.response = doc["_id"]["response"].get_double().value; 

    auto end2  = std::chrono::steady_clock::now();
    auto time2 = std::chrono::duration_cast<std::chrono::microseconds>(end2-start2).count();
    std::cout<<"2.2.2:   \t"<< time2<<"ms"<<std::endl;

    }
auto end3  = std::chrono::steady_clock::now();
auto time3 = std::chrono::duration_cast<std::chrono::microseconds>(end3-start3).count();
std::cout<<"2.2:   \t"<< time3<<"ms"<<std::endl;  


}
mongocxx::pipeline  MongoDB::setSorgu(){
    using namespace bsoncxx::builder::basic;
    mongocxx::pipeline secondIterPipeline{};

    ...

    secondIterPipeline.sort(make_document(kvp("_id.response", -1)));
    secondIterPipeline.limit(1);

    return secondIterPipeline;
}

Elapsed times are written by matching std :: cout

1: 761ms
2.1: 80ms
2.2.1: 1150ms
2.2.2: 2ms
2.2: 1158ms

The number 1 represents the time taken by opencv loops

My database contains similar data such as

[{

  "keypoint": {
    "response": 0
  }
},{
  "keypoint": {
    "response": 0.0010120292427018285
  }
},{
  "keypoint": {

    "response": 0.0017831606091931462
  }
}]