Commit 26243a88 authored by wanghailong's avatar wanghailong

增加配置版抛撒初始化,测试抛撒和yolo共存没结果的问题

parent ad865bfd
......@@ -39,7 +39,26 @@ bool DetectAnomaly::detectAnomaly(cv::Mat img, vector<vector<int>>* resultLocati
/************************************************************************/
/* abandoned object detection algorithm */
/************************************************************************/
obj_left = _objleft.process(myimg1,yolo_test,resultLocation);
obj_left = _objleft.process(myimg1,resultLocation);
return obj_left;
}
bool DetectAnomaly::detectAnomaly(config cfg, cv::Mat img, vector<vector<int>>* resultLocation)
{
//cv::Rect rect(0,610,2400,910);
cv::Rect rect(0,img.rows - cfg.image_height,cfg.image_width,cfg.image_height);
img = img(rect);
//cv::resize(img, img,cv::Size(2400*0.25, 910*0.25), cv::INTER_CUBIC);
cv::resize(img, img,cv::Size(cfg.image_width * cfg.input_resize, cfg.image_height * cfg.input_resize), cv::INTER_CUBIC);
img.copyTo(myimg);
medianBlur(mat_myimg, mat_myimg, 3);
opencv_2_myImage(myimg, myimg1); //transfer opencv data to myimage data
/************************************************************************/
/* abandoned object detection algorithm */
/************************************************************************/
obj_left = _objleft.process(myimg1,resultLocation);
return obj_left;
}
......@@ -236,7 +255,7 @@ DetectAnomaly::DetectAnomaly(config cfg) : cfgAnomaly(cfg)
opencv_2_myImage(mask, mymask);
#ifdef DEBUG
cv::imwrite("mask.jpg", Image1);
//cv::imwrite("mask.jpg", Image1);
cv::waitKey(1);
//cvReleaseImage(&Image1);
#endif
......
......@@ -10,18 +10,18 @@
typedef struct ConfigAnomaly
{
int owner_search_roi;
int owner_search_roi = 10;
int gmm_learn_frame; //frame number for GMM initialization
int max_sfg;
int min_sfg;
int max_fg;
int min_fg;
int max_sfg = 15625;
int min_sfg = 15;
int max_fg = 75000;
int min_fg = 50;
int buffer_length;
int image_height;
int image_width;
double gmm_long_learn_rate;
double gmm_short_learn_rate;
double input_resize;
double gmm_long_learn_rate = 0.0001;
double gmm_short_learn_rate = 0.002;
double input_resize = 0.25;
int top_left_x;
int top_left_y;
......@@ -58,6 +58,7 @@ private:
int arr[1];
public:
bool detectAnomaly(config cfg, cv::Mat img, vector<vector<int>>* resultLocation);
bool detectAnomaly(cv::Mat img, vector<vector<int>>* resultLocation);
DetectAnomaly();
DetectAnomaly(config cfg);
......
......@@ -90,7 +90,7 @@ void ObjLeftDetect::initialize()
}
bool ObjLeftDetect::process(myImage * input, cv::Mat show_pic, vector<vector<int>>* resultLocation)
bool ObjLeftDetect::process(myImage * input, vector<vector<int>>* resultLocation)
{
cv::Mat test;
test = cv::Mat(cv::Size(new_width, new_height),CV_8UC3);
......
......@@ -28,7 +28,7 @@ public:
ObjLeftDetect();
ObjLeftDetect(myImage *input, int set_MOG_LearnFrame, int set_min_area, int set_buffer_len, myImage *mask);
~ObjLeftDetect();
bool process(myImage * input,cv::Mat show_pic, vector<vector<int>>* resultLocation);
bool process(myImage * input, vector<vector<int>>* resultLocation);
CBM_model *_CBM_model;
//cv::VideoWriter _writer1, _writer2;
cv::Mat A, B;
......
......@@ -27,20 +27,21 @@ int main()
cv::Mat qImg;
//抛洒物
// config opt;
// opt.image_height = 910;
// opt.image_width = 2400;
// opt.buffer_length = 200;
// opt.gmm_learn_frame = 600;
// opt.top_left_x = 1136;
// opt.top_left_y = 3;
// opt.top_right_x = 1340;
// opt.top_right_y = 10;
// opt.bottom_left_x = 198;
// opt.bottom_left_y = 853;
// opt.bottom_right_x = 2168;
// opt.bottom_right_y = 842;
DetectAnomaly detect;
config opt;
opt.image_height = 910;
opt.image_width = 2400;
opt.buffer_length = 200;
opt.gmm_learn_frame = 600;
opt.top_left_x = 1136;
opt.top_left_y = 3;
opt.top_right_x = 1340;
opt.top_right_y = 10;
opt.bottom_left_x = 198;
opt.bottom_left_y = 853;
opt.bottom_right_x = 2168;
opt.bottom_right_y = 842;
//DetectAnomaly* detect = new DetectAnomaly(opt);
DetectAnomaly* detect = new DetectAnomaly();
int pic_num = 0;
#ifdef DEBUG
//cv::VideoWriter _writer;
......@@ -64,19 +65,20 @@ int main()
// continue;
// }
obj_left = detect.detectAnomaly(qImg,&resultLocation);
//obj_left = detect->detectAnomaly(opt,qImg,&resultLocation);
obj_left = detect->detectAnomaly(qImg,&resultLocation);
//yolo_infer
// vector<cv::Mat>* input_mats = new vector<cv::Mat>;
// input_mats->push_back(qImg.clone());
// std::map<int,Results*> results_map;
// Results* results = new Results;
// results_map.insert(std::make_pair(0,results));
// inference(&results_map,input_mats);
// delete results_map[0];
// delete input_mats;
// //yolo_infer
vector<cv::Mat>* input_mats = new vector<cv::Mat>;
input_mats->push_back(qImg.clone());
std::map<int,Results*> results_map;
Results* results = new Results;
results_map.insert(std::make_pair(0,results));
inference(&results_map,input_mats);
delete results_map[0];
delete input_mats;
#ifdef DEBUG
// if (obj_left == true)
// {
......@@ -85,9 +87,9 @@ int main()
// for(int i = 0; i < resultLocation.size();i++){
// int x0 = resultLocation[i][0] * 4;
// int y0 = resultLocation[i][1] * 4 + 750;
// int y0 = resultLocation[i][1] * 4 + 610;
// int x1 = resultLocation[i][2] * 4;
// int y1 = resultLocation[i][3] * 4 + 750;
// int y1 = resultLocation[i][3] * 4 + 610;
// cv::Point p1(x0, y0);
// cv::Point p2(x1, y1);
......@@ -95,7 +97,7 @@ int main()
// }
// stringstream ss1;
// string outFile;
// ss1 << "yolov3_"
// ss1 << "abanoned_"
// << "show"
// << count
// << ".jpg";
......@@ -109,12 +111,12 @@ int main()
gettimeofday(&end, NULL);
time = (1000000 * (end.tv_sec - start.tv_sec) + end.tv_usec - start.tv_usec) /
(1000.0);
cout << "total time = " << time << "ms" << endl;
//cout << "total time = " << time << "ms" << endl;
#ifdef DEBUG
printf("Finished detec, then release ...\n");
#endif
delete detect;
//system("pause");
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment