0

I am working with a real-time object detection on one of my edge evaluation boards and have a doubt regarding the usage of the priority queue in the C++ application code

Scenario:

I am using multiple threads (say 4) for reading(1), object detection(2), and displaying tasks(1). For reference, I am following the code available here object detection on multiple threads. In the code, I didn't understand how the priority queue for the display task is defined. Here is the code sample,

#include <opencv2/opencv.hpp>
#include <queue>
using namespace std;
using namespace cv;
// comparison algorithm for priority_queue

class Compare {
    public:
    bool operator()(const pair<int, Mat> &n1, const pair<int, Mat> &n2) const {
        return n1.first > n2.first;
    }
};

queue<pair<int, Mat>> read_queue;                                               // read queue
priority_queue<pair<int, Mat>, vector<pair<int, Mat>>, Compare> display_queue;  // display queue

I don't get it the usage of class compare and etc.

Thanks in advance

0 Answers0