MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QSize s = QApplication::desktop()->size(); this->setGeometry((s.width()*0.5)-320,(s.height()*0.5)-264,640,527); mylabel = new MyQLabel(this); mylabel->setText("<font size='50' color='gray'>Not connected to camera</font>"); this->setCentralWidget(mylabel); camera_thread = new camera(this); connect(camera_thread,SIGNAL(send_UIupdate(QImage)),this,SLOT(updateUI(QImage))); connect(camera_thread,SIGNAL(saveImg(cv::Mat)),this,SLOT(capture(cv::Mat))); i = 0; // count for the image auto name dirName = "images"; // directory name for saving images createActions(); createMenus(); this->layout()->setSizeConstraint(QLayout::SetFixedSize); //fr = new FaceRecognition(this); //connect(fr,SIGNAL(emitFace(QImage)),&sfd,SLOT(setFace(QImage))); }
const QPixmap Bubble::converToPixmap(const QDBusArgument &value) { // use plasma notify source code to conver photo, solving encoded question. const QImage &img = decodeNotificationSpecImageHint(value); saveImg(img); return QPixmap::fromImage(img).scaled(m_icon->width(), m_icon->height(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); }
void MainWindow::createActions() { //////////////////////////////////////////////////////////////////////////// // akcje menu File newAction = new QAction(tr("&New *.turtle"), this); newAction->setIcon(QIcon(":/images/new.png")); newAction->setShortcut(QKeySequence::New); newAction->setStatusTip(tr("Create a new turtle file")); connect(newAction, SIGNAL(triggered()), this, SLOT(newFile())); openAction = new QAction(tr("&Open *.turtle"), this); openAction->setIcon(QIcon(":/images/open.png")); openAction->setShortcut(QKeySequence::Open); openAction->setStatusTip(tr("Open an existing turtle command file")); connect(openAction, SIGNAL(triggered()), this, SLOT(open())); saveCmdAction = new QAction(tr("&Save *.turtle"), this); saveCmdAction->setIcon(QIcon(":/images/save.png")); saveCmdAction->setShortcut(QKeySequence::Save); saveCmdAction->setStatusTip(tr("Save turtle commands to file")); connect(saveCmdAction, SIGNAL(triggered()), this, SLOT(saveCmd())); saveImgAction = new QAction(tr("Save *.jpg"), this); saveImgAction->setStatusTip(tr("Save board as JPG file")); connect(saveImgAction, SIGNAL(triggered()), this, SLOT(saveImg())); exitAction = new QAction(tr("E&xit"), this); exitAction->setShortcut(tr("Ctrl+Q")); exitAction->setStatusTip(tr("Exit the application")); connect(exitAction, SIGNAL(triggered()), this, SLOT(close())); //////////////////////////////////////////////////////////////////////////// // akcje menu Edit clearBoardAction = new QAction(tr("Clear board"), this); clearBoardAction->setStatusTip(tr("Clears drawing board")); connect(clearBoardAction, SIGNAL(triggered()), this, SLOT(clearAll())); drawHistoryAction = new QAction(tr("Draw history"), this); drawHistoryAction->setStatusTip(tr("Draws commands history")); connect(drawHistoryAction, SIGNAL(triggered()), this, SLOT(drawHistory())); //////////////////////////////////////////////////////////////////////////// // akcje menu Help //////////////////////////////////////////////////////////////////////////// // zad 2: aboutAction = new QAction(tr("&Commands"), this); aboutAction->setStatusTip(tr("Show the application's About box")); connect(aboutAction, SIGNAL(triggered()), this, SLOT(about())); aboutQtAction = new QAction(tr("About &Qt"), this); aboutQtAction->setStatusTip(tr("Show the Qt library's About box")); connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); this->vid = new Video(); this->vid->init(); this->img = new ImageFactory(this); QObject::connect(ui->buttonStart, SIGNAL(clicked()), this, SLOT(startVideo())); QObject::connect(ui->buttonStop, SIGNAL(clicked()), this, SLOT(stopVideo())); QObject::connect(ui->buttonExport, SIGNAL(clicked()), this, SLOT(exportImg())); QObject::connect(ui->listImg, SIGNAL(currentTextChanged(QString)), this, SLOT(setFileSelected(QString))); QObject::connect(ui->buttonSave, SIGNAL(clicked()), this, SLOT(saveImg())); }
//-------------------------------------------------------------- void testApp::keyPressed(int key){ if (key == '0') { state = 0; newPic = true; } if (key == '1') { if (newPic) { saveImg(); newPic = false; } state = 1; } if (key == '2') state = 2; if (key == '3') state = 3; if (key == '4') state = 4; if (key == '5') state = 5; }
void CharacterCut::secondCut(Mat src,int ave){ int min=ave*0.8; int max=ave*1.3; if(src.cols<max&&src.cols>min){ saveImg(src); return; } //cout<<"src.cols min max "<<src.cols<<" "<<min<<" "<<max<<endl; Mat paintx=Mat::ones(src.size(),src.type()); vector<Mat> res; int *v=new int[src.cols]; memset(v,0,src.cols*4); //垂直方向投影 int x,y; for(x=0;x<src.cols;x++) { for(y=0;y<src.rows;y++) { uchar temp=src.at<uchar>(y,x); if(temp==0) v[x]++; } } Rect r; r.y=0; r.height=src.rows; Mat img; int flag=1; r.x=0; int i=0; while(i<src.cols-1){ if(flag==0){ if(v[i]==0){ if(v[i+1]==0) { i++; continue; } else{ r.x=i; flag=1; } } }else if(flag==1){ if(v[i+1]==0){ r.width=i+2-r.x; if(r.width<min) { i++; continue; } else if(r.width>max){ r.width=ave+1; //printf("%d:r.width>max\n",i+1); img=src(r); res.push_back(img); //flag=1; i=r.x+ave+1; r.x=i+1; }else{ img=src(r); res.push_back(img); flag=0; } } } i++; } saveImg(res); paintx.release(); img.release(); delete[] v; }
//-------------------------------------------------------------- void testApp::mousePressed(int x, int y, int button){ saveImg(); }
void LabelToolPlugin::pushSaveCurrentImgButton() { saveImg(current_index_); }