//警报显示 void dlpy_main::alertFrame() { Mat roi_alert,roi_alert_tmp,roi_temp; if(times_alert>0) { if(times_alert%2==0) { if(last_alert==1){roi_temp=img_temp(roi_l);roi_alert_tmp = img_alert_1(roi_l);} if(last_alert==2){roi_temp=img_temp(roi_r);roi_alert_tmp = img_alert_1(roi_r);} if(last_alert==3){roi_temp=img_temp(roi_l);roi_alert_tmp = img_alert_2(roi_l);} if(last_alert==4){roi_temp=img_temp(roi_r);roi_alert_tmp = img_alert_2(roi_r);} roi_alert_tmp.copyTo(roi_temp); }else{ img_alert.copyTo(img_temp); } times_alert--; //控制闪烁 QGraphicsScene *scene = new QGraphicsScene; QImage *qimg=new QImage; *qimg=mat2qimage(img_temp); scene->addPixmap(QPixmap::fromImage(*qimg)); ui->graphicsView->setScene(scene); ui->graphicsView->resize(qimg->width() + 10, qimg->height() + 10); ui->graphicsView->show(); }else{ } }
QImage WebCam::getImage() { return mat2qimage(current_frame); }
dlpy_main::dlpy_main(int state,string filename,QWidget *parent) : QMainWindow(parent), ui(new Ui::dlpy_main) { ui->setupUi(this); setGeometry(697, 50, 220, 480); wid = new widget(); wid->setWindowFlags(Qt::FramelessWindowHint); wid->show(); frame = new dlpy_frames(state,filename); frame->setWindowFlags(Qt::FramelessWindowHint); //隐藏标题栏 frame->show(); connect(this,SIGNAL(setparasignal(int,int,int,int,int)),frame,SLOT(setparaslot(int,int,int,int,int))); connect(frame,SIGNAL(setalertsignal(int)),this,SLOT(setalertslot(int))); //每一帧图像信号槽初始化警报参数 connect(this,SIGNAL(setlinesignal(int)),frame,SLOT(setlineslot(int))); ///////////////////////////////////////////////////////////////////////////////////////////// //img_alert: 显示所有 //img_alert_1: 红色警报 //img_alert_3: 无警报 //img_temp:所有 //img:所有 //////////////////////////////////////////////////////////////////////////////////////////// img_alert = cv::imread("/home/hugo/code/bin/alert.bmp"); img_alert_1 = cv::imread("/home/hugo/code/bin/alert_2.bmp"); img_alert_2 = cv::imread("/home/hugo/code/bin/alert_3.bmp"); img_temp = cv::imread("/home/hugo/code/bin/alert.bmp"); roi_l=Rect(0, 0, (img_alert.cols-1)/2, img_alert.rows-1); roi_r=Rect((img_alert.cols-1)/2, 0, (img_alert.cols-1)/2, img_alert.rows-1); QGraphicsScene *scene = new QGraphicsScene; QImage img; img.load("/home/hugo/code/bin/alert.bmp"); QPixmap mp; mp=mp.fromImage(img); times_alert=0; last_alert=0; w0=weatherobj(10,20,30,40,50); w1=weatherobj(60,70,80,90,100); w2=weatherobj(100,110,120,130,140); w3=weatherobj(10,60,0,42,100); w4=weatherobj(150,160,170,180,190); w5=weatherobj(200,210,220,230,240); w6=weatherobj(10,25,10,32,90); w7=weatherobj(200,240,220,250,123); QImage *qimg=new QImage; *qimg=mat2qimage(img_temp); /*cvtColor(img_temp, img_temp, CV_BGR2RGB); qimg = new QImage((unsigned char*)img_temp.data, // uchar* data img_temp.cols, img_temp.rows, // width height img_temp.step, //bytesPerLine QImage::Format_RGB888); //format*/ scene->addPixmap(QPixmap::fromImage(*qimg)); ui->graphicsView->setScene(scene); ui->graphicsView->resize(qimg->width() + 10, qimg->height() + 10); ui->graphicsView->show(); timer = new QTimer(this); timer->setInterval(30); connect(timer,SIGNAL(timeout()),this,SLOT(alertFrame())); //每隔30s读取一次报警图片 timer->start(); }