#ifndef _CIGARETTE_JD_ng
#define _CIGARETTE_JD_ng

#include <opencv2/opencv.hpp>
#include <opencv2/dnn.hpp>
#include <opencv2/dnn/shape_utils.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>
#include <fstream>
#include "common.h"
class AlgJd_ng
{
	public:
		bool init_ng(QString model_path, QString model_name);
		bool test_detect_ng();
		bool test_detect_batcht_ng(int shoot);
		int detect_ng(cv::Mat& in, cv::Mat &draw_frame, cv::Mat &out, std::vector<std::pair<int, cv::Rect>> &results);
		int detect_ng(cv::Mat& in, cv::Mat &out, std::vector<std::pair<int, cv::Rect> > &results);
		// Remove the bounding boxes with low confidence using non-maxima suppression
		void post_process_ng(cv::Mat& frame, std::vector<cv::Mat>& outs, std::vector<std::pair<int, cv::Rect>> &results);
		void CircleImagePro_ng(cv::Mat src, cv::Mat dst, std::vector<float> radius);
		void detect_batch_ng(std::vector<cv::Mat>& vec_in, std::vector<cv::Mat> &vec_out, std::vector<std::vector<std::pair<int, cv::Rect> > > &vec_results);
		void detect_batch_ng(std::vector<cv::Mat>& vec_in, std::vector<cv::Mat> &transits, std::vector<cv::Mat> &vec_out, std::vector<std::vector<std::pair<int, cv::Rect>>> &vec_results);
		// Remove the bounding boxes with low confidence using non-maxima suppression
		void post_process_batch_ng(std::vector<cv::Mat>& vec_frame, std::vector<cv::Mat>& outs, std::vector<std::vector<std::pair<int, cv::Rect>>> &vec_results);
		void analyse_ng(cv::Mat vec_in, std::vector<std::pair<int, cv::Rect> > & vec_results);
		// Get the names of the output layers
		std::vector<cv::String> getOutputsNames_ng(const cv::dnn::Net& net);
		// Draw the predicted bounding box
		void drawPred_ng(int classId, float conf, int left, int top, int right, int bottom, cv::Mat& frame);
	private:
		cv::dnn::Net net_ng;
		std::vector<std::string> classes_ng;
};
//jinhuan+
bool sort_rect_by_x_center_ng(cv::Rect r1, cv::Rect r2);
bool sort_rect_by_y_center_ng(cv::Rect r1, cv::Rect r2);
bool sort_rect_by_height_ng(cv::Rect r1, cv::Rect r2);
bool sort_rect_by_width_ng(cv::Rect r1, cv::Rect r2);
//jinhuan-
#endif  //end of _CIGARETTE_JD
