1 Star 0 Fork 0

NJUPT-B523/Intelligent Traffic Violation Detection

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
line_pressured.cpp 2.65 KB
一键复制 编辑 原始数据 按行查看 历史
江斌 提交于 2021-08-22 15:41 . YDS 2019
/*********************************
* 压线违章类
* @ZZH
* date:2019/9/23
* *******************************/
#include "line_pressured.h"
line_pressured::line_pressured()
{
}
//压线ROI区域储存函数
std::vector<cv::Rect> line_pressured::line_pressured_ROI(cv::Rect roi_1st)
{
std::vector<cv::Rect>ROI_AREA;
ROI_AREA.push_back(roi_1st);
return ROI_AREA;
}
//判断压线函数
std::vector<float> line_pressured::rules(std::vector<cv::Rect> roi, std::vector<std::vector<float> > car, const cv::Mat &img)
{
illegal_process pre;
extern cv::Mat line_pressured_license;
extern cv::Mat no;
//压线判断1个ROI即可
for (int i=0;i<(int)car.size();i+=1){
for (int j=0;j<(int)car[i].size();j+=2){
if (pre.roi_judge(car[i][j],car[i][j+1],roi[0])){
target.push_back(i);
target.push_back(j);
target.push_back(0);
if (second_time){
img.copyTo(break1);
cv::rectangle(break1, cv::Rect(car[i][j]-200,car[i][j+1]-200,400,400),cv::Scalar(0,0,255),3,8,0);
car_br = pre.slice(break1,cv::Rect(car[i][j]-100,car[i][j+1]-100,200,200));
cv::resize(break1,break1,cv::Size(1080,720));
//违章证据保存
x = snprintf(pic_name,sizeof(pic_name),"press_line_car%d_evid.jpg",num);
cv::imwrite(pic_name,break1);
//违章车辆保存
z = snprintf(pic_name,sizeof(pic_name),"press_line_car%d.jpg",num);
cv::imwrite(pic_name,car_br);
car_br_e=cv::imread(pic_name);
car_license= car_lic.detection(car_br_e);
//违章车牌保存
e = snprintf(pic_name,sizeof(pic_name),"press_line_car%d_license.jpg",num);
cv::imwrite(pic_name,car_license);
line_pressured_license = cv::imread(pic_name);
if(line_pressured_license.empty())
{
line_pressured_license = no;
}
cv::resize(line_pressured_license,line_pressured_license,cv::Size(52,16));
cv::cvtColor(line_pressured_license,line_pressured_license,COLOR_BGR2RGB);
second_time = false;
num+=1;
}
return target;
}
}
}
//次数核查
//std::cout<<"_line_pressured_"<<std::endl;
return target;
}
//资源释放函数
void line_pressured::line_pressured_release()
{
target.clear();
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/njupt-b523/intelligent-traffic-violation-detection.git
git@gitee.com:njupt-b523/intelligent-traffic-violation-detection.git
njupt-b523
intelligent-traffic-violation-detection
Intelligent Traffic Violation Detection
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385