├── README.md └── caiji ├── Dis_thread.cpp ├── Dis_thread.h ├── caiji.pro ├── caiji.pro.user ├── caiji.pro.user.1.3 ├── cthread.h ├── main.cpp ├── mainwindow.cpp ├── mainwindow.h ├── mainwindow.ui ├── myapp.rc ├── play.cpp ├── play.h ├── play.ui ├── res.qrc ├── res ├── camera.ico ├── cut.png ├── down-arrow.png ├── down-arrow_unsel.png ├── exit.png ├── flame.png ├── flame_unsel.png ├── gas.png ├── gas_unsel.png ├── left-arrow.png ├── left-arrow_unsel.png ├── lightbulb.png ├── lightbulb_unsel.png ├── next.png ├── next_unsel.png ├── open.png ├── open_unsel.png ├── openfile.png ├── openfile_unsel.png ├── pause.png ├── pause_unsel.png ├── play.png ├── play_unsel.png ├── prev.png ├── prev_unsel.png ├── recoder.png ├── recoder_unsel.png ├── right-arrow.png ├── right-arrow_unsel.png ├── save.png ├── shake.png ├── shake_unsel.png ├── smoke.png ├── smoke_unsel.png ├── stop.png ├── stop_unsel.png ├── up-arrow.png └── up-arrow_unsel.png ├── ssthread.cpp └── ssthread.h /README.md: -------------------------------------------------------------------------------- 1 | # VideoMonitor 2 | Linux-Qt VideoMonitor project with USB camera 3 | 4 | 这个项目是做的基于树莓的视频监控系统,实现了: 5 | 1.视频监控画面显示 2.视频监控画面截屏 3.视频保存功能 4.保存的视频播放 5.外接的3个传感器的监测情况 6 | 7 | 需要配置openCV与phonon库 8 | 9 | 10 | -------------------------------------------------------------------------------- /caiji/Dis_thread.cpp: -------------------------------------------------------------------------------- 1 | #include"Dis_thread.h" 2 | #include 3 | 4 | 5 | Dis_thread::Dis_thread() 6 | { 7 | 8 | } 9 | 10 | void Dis_thread::run() 11 | { 12 | while(1) 13 | { 14 | emit dispaly(); 15 | msleep(150 ); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /caiji/Dis_thread.h: -------------------------------------------------------------------------------- 1 | #ifndef DIS_THREAD_H 2 | #define DIS_THREAD_H 3 | #include 4 | 5 | 6 | class Dis_thread : public QThread 7 | { 8 | Q_OBJECT 9 | 10 | 11 | public: 12 | Dis_thread(); 13 | 14 | signals: 15 | void dispaly(); 16 | // void time(QString); 17 | 18 | protected: 19 | void run(); 20 | 21 | }; 22 | 23 | #endif // DIS_THREAD_H 24 | -------------------------------------------------------------------------------- /caiji/caiji.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2015-11-06T03:23:11 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | QT += phonon 9 | 10 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 11 | 12 | TARGET = caiji 13 | TEMPLATE = app 14 | 15 | 16 | SOURCES += main.cpp\ 17 | mainwindow.cpp \ 18 | Dis_thread.cpp \ 19 | play.cpp \ 20 | ssthread.cpp 21 | 22 | HEADERS += mainwindow.h \ 23 | x264.h \ 24 | Dis_thread.h \ 25 | play.h \ 26 | ssthread.h 27 | 28 | 29 | FORMS += mainwindow.ui \ 30 | play.ui 31 | 32 | LIBS += -L. -lx264 -lpthread 33 | 34 | RESOURCES += \ 35 | res.qrc 36 | 37 | LIBS += -L/usr/lib \ 38 | -lopencv_core \ 39 | -lopencv_highgui \ 40 | -lopencv_imgproc \ 41 | 42 | LIBS += -L/usr/local/lib -lwiringPi 43 | INCLUDEPATH += /usr/include \ 44 | /usr/include/opencv \ 45 | /usr/include/opencv2\ 46 | 47 | RC_FILE = myapp.rc 48 | 49 | -------------------------------------------------------------------------------- /caiji/caiji.pro.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ProjectExplorer.Project.ActiveTarget 7 | 0 8 | 9 | 10 | ProjectExplorer.Project.EditorSettings 11 | 12 | true 13 | false 14 | true 15 | 16 | Cpp 17 | 18 | CppGlobal 19 | 20 | 21 | 22 | QmlJS 23 | 24 | QmlJSGlobal 25 | 26 | 27 | 2 28 | System 29 | false 30 | 4 31 | false 32 | true 33 | 1 34 | true 35 | 0 36 | true 37 | 0 38 | 8 39 | true 40 | 1 41 | true 42 | true 43 | true 44 | false 45 | 46 | 47 | 48 | ProjectExplorer.Project.PluginSettings 49 | 50 | 51 | 52 | ProjectExplorer.Project.Target.0 53 | 54 | Embedded Linux 55 | Embedded Linux 56 | RemoteLinux.EmbeddedLinuxTarget 57 | 0 58 | 1 59 | 1 60 | 61 | ProjectExplorer.ToolChain.Gcc:{28dda6c3-b9f6-4e43-ac0b-6791bed18760} 62 | 63 | 64 | true 65 | qmake 66 | 67 | QtProjectManager.QMakeBuildStep 68 | false 69 | true 70 | 71 | false 72 | 73 | 74 | true 75 | Make 76 | 77 | Qt4ProjectManager.MakeStep 78 | false 79 | 80 | 81 | 82 | 2 83 | 构建 84 | 85 | ProjectExplorer.BuildSteps.Build 86 | 87 | 88 | 89 | true 90 | Make 91 | 92 | Qt4ProjectManager.MakeStep 93 | true 94 | clean 95 | 96 | 97 | 1 98 | 清理 99 | 100 | ProjectExplorer.BuildSteps.Clean 101 | 102 | 2 103 | false 104 | 105 | Qt 4.8.2 in PATH (System) 发布 106 | 107 | Qt4ProjectManager.Qt4BuildConfiguration 108 | 0 109 | /home/pi/caiji2/caiji-build-embedded-Qt_4_8_2_in_PATH__System____ 110 | 1 111 | true 112 | 113 | 114 | ProjectExplorer.ToolChain.Gcc:{28dda6c3-b9f6-4e43-ac0b-6791bed18760} 115 | 116 | 117 | true 118 | qmake 119 | 120 | QtProjectManager.QMakeBuildStep 121 | false 122 | true 123 | 124 | false 125 | 126 | 127 | true 128 | Make 129 | 130 | Qt4ProjectManager.MakeStep 131 | false 132 | 133 | 134 | 135 | 2 136 | 构建 137 | 138 | ProjectExplorer.BuildSteps.Build 139 | 140 | 141 | 142 | true 143 | Make 144 | 145 | Qt4ProjectManager.MakeStep 146 | true 147 | clean 148 | 149 | 150 | 1 151 | 清理 152 | 153 | ProjectExplorer.BuildSteps.Clean 154 | 155 | 2 156 | false 157 | 158 | Qt 4.8.2 in PATH (System) 调试 159 | 160 | Qt4ProjectManager.Qt4BuildConfiguration 161 | 2 162 | /home/pi/caiji2/caiji-build-embedded-Qt_4_8_2_in_PATH__System____ 163 | 1 164 | true 165 | 166 | 2 167 | 168 | 169 | 170 | true 171 | 通过SFTP上传文件 172 | 173 | RemoteLinux.DirectUploadStep 174 | 175 | 176 | 177 | 178 | 179 | true 180 | 181 | 1 182 | 部署 183 | 184 | ProjectExplorer.BuildSteps.Deploy 185 | 186 | 1 187 | 部署到远程Linux主机 188 | 189 | DeployToGenericLinux 190 | 0 191 | 192 | 193 | 194 | 0 195 | 部署 196 | 197 | ProjectExplorer.BuildSteps.Deploy 198 | 199 | 1 200 | 当前无部署 201 | 202 | ProjectExplorer.DefaultDeployConfiguration 203 | 204 | 2 205 | 206 | true 207 | 208 | false 209 | false 210 | false 211 | false 212 | true 213 | 0.01 214 | 10 215 | true 216 | 25 217 | 218 | true 219 | valgrind 220 | 221 | 0 222 | 1 223 | 2 224 | 3 225 | 4 226 | 5 227 | 6 228 | 7 229 | 8 230 | 9 231 | 10 232 | 11 233 | 12 234 | 13 235 | 14 236 | 237 | caiji (在远端设备上) 238 | 239 | RemoteLinuxRunConfiguration 240 | 241 | 1 242 | caiji.pro 243 | 244 | 245 | false 246 | 247 | 3768 248 | true 249 | false 250 | true 251 | 252 | 253 | true 254 | 255 | false 256 | false 257 | false 258 | false 259 | true 260 | 0.01 261 | 10 262 | true 263 | 25 264 | 265 | true 266 | valgrind 267 | 268 | 0 269 | 1 270 | 2 271 | 3 272 | 4 273 | 5 274 | 6 275 | 7 276 | 8 277 | 9 278 | 10 279 | 11 280 | 12 281 | 13 282 | 14 283 | 284 | 285 | 2 286 | %{buildDir}/caiji 287 | false 288 | 289 | %{buildDir} 290 | 运行%{buildDir}/caiji 291 | 292 | ProjectExplorer.CustomExecutableRunConfiguration 293 | 3768 294 | true 295 | false 296 | true 297 | 298 | 2 299 | 300 | 301 | 302 | ProjectExplorer.Project.TargetCount 303 | 1 304 | 305 | 306 | ProjectExplorer.Project.Updater.EnvironmentId 307 | {b9dcd16f-15e2-406c-9d55-07f9cbc5b323} 308 | 309 | 310 | ProjectExplorer.Project.Updater.FileVersion 311 | 11 312 | 313 | 314 | -------------------------------------------------------------------------------- /caiji/caiji.pro.user.1.3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/caiji.pro.user.1.3 -------------------------------------------------------------------------------- /caiji/cthread.h: -------------------------------------------------------------------------------- 1 | #ifndef THREAD_H 2 | #define THREAD_H 3 | 4 | 5 | #include 6 | #include //包含opencv库头文件 7 | #include 8 | 9 | class cthread 10 | { 11 | public: 12 | cthread(); 13 | ~cthread(); 14 | 15 | public: 16 | void create_thread(); 17 | 18 | }; 19 | 20 | #endif // THREAD_H 21 | -------------------------------------------------------------------------------- /caiji/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "mainwindow.h" 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | a.setApplicationName("Video Monitor"); 8 | MainWindow w; 9 | w.show(); 10 | 11 | return a.exec(); 12 | } 13 | -------------------------------------------------------------------------------- /caiji/mainwindow.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include "ui_mainwindow.h" 3 | #include 4 | //#include"video_capture.h" 5 | #include"cthread.h" 6 | #include 7 | #include"Dis_thread.h" 8 | 9 | 10 | 11 | MainWindow::MainWindow(QWidget *parent) : 12 | QMainWindow(parent), 13 | ui(new Ui::MainWindow) 14 | { 15 | ui->setupUi(this); 16 | setWindowIcon(QIcon(":/res/camera.ico")); 17 | 18 | createActions(); 19 | createMenus(); 20 | createToolBars(); 21 | createStatusBar(); 22 | 23 | //button_init(); 24 | 25 | cam_l = NULL; 26 | imag = new QImage(); // 初始化 27 | dis_thread = new Dis_thread(); 28 | starvideomonitor(); 29 | 30 | sensorThread = new ssThread(); 31 | connect(sensorThread,SIGNAL(SENSOR_ALEART(QString)),this,SLOT(SENSOR_ALEART(QString))); 32 | 33 | sensorThread->start(); 34 | 35 | 36 | } 37 | 38 | MainWindow::~MainWindow() 39 | { 40 | delete ui; 41 | cvReleaseCapture(&cam_l); 42 | cvReleaseVideoWriter(&video); 43 | dis_thread->exit(); 44 | sensorThread->stop(); 45 | } 46 | 47 | void MainWindow::button_init() 48 | { 49 | // ui->pushButton_left->setStyleSheet( "QPushButton{border-image: url(:/res/left-arrow_unsel.png); }" 50 | // "QPushButton:pressed{border-image:url(:/res/left-arrow.png);}"); 51 | // ui->pushButton_right->setStyleSheet( "QPushButton{border-image: url(:/res/right-arrow_unsel.png); }" 52 | // "QPushButton:pressed{border-image:url(:/res/right-arrow.png);}"); 53 | // ui->pushButton_up->setStyleSheet( "QPushButton{border-image: url(:/res/up-arrow_unsel.png); }" 54 | // "QPushButton:pressed{border-image:url(:/res/up-arrow.png);}"); 55 | // ui->pushButton_down->setStyleSheet( "QPushButton{border-image: url(:/res/down-arrow_unsel.png); }" 56 | // "QPushButton:pressed{border-image:url(:/res/down-arrow.png);}"); 57 | } 58 | 59 | void MainWindow::open() 60 | { 61 | this->hide(); 62 | play.show(); 63 | play.exec(); 64 | this->show(); 65 | 66 | } 67 | 68 | void MainWindow::save() 69 | { 70 | frame = cvQueryFrame(cam_l); 71 | video = cvCreateVideoWriter("/home/pi/caiji2/save.avi" , CV_FOURCC('X' , 'V' , 'I' , 'D') , 72 | 8 , cvSize(frame->width , frame->height ) ); 73 | 74 | if(cvWriteFrame(video,frame)) 75 | { 76 | QMessageBox::information(this , "information" , "start svae video" , QMessageBox::Yes , 77 | QMessageBox::Yes); 78 | ui->pushButton_recode->setStyleSheet( "QPushButton{border-image: url(:/res/lightbulb.png);}"); 79 | } 80 | 81 | // t = new cthread(); 82 | // t.create_thread(); 83 | 84 | } 85 | 86 | void MainWindow::cut() 87 | { 88 | IplImage *frame_l = cvQueryFrame(cam_l);// 从摄像头中抓取并返回每一帧 89 | QImage image = QImage((const unsigned char*)frame_l->imageData, 90 | frame_l->width, frame_l->height, 91 | QImage::Format_RGB888).rgbSwapped(); 92 | 93 | QFile file("/home/pi/caiji2/cam.png"); 94 | if(!file.open(QIODevice::ReadWrite)) 95 | { 96 | QMessageBox::warning(this , "waring" , "open file error" , QMessageBox::Yes , 97 | QMessageBox::Yes); 98 | return; 99 | } 100 | QByteArray ba; 101 | QBuffer buffer(&ba); 102 | buffer.open(QIODevice::WriteOnly); 103 | image.save(&buffer,"png"); 104 | file.write(ba); 105 | QMessageBox::information(this , "information" , "save success" , QMessageBox::Yes, 106 | QMessageBox::Yes); 107 | } 108 | 109 | void MainWindow::whenshakerecoder() 110 | { 111 | IplImage *frame_l = cvQueryFrame(cam_l);// 从摄像头中抓取并返回每一帧 112 | QImage image = QImage((const unsigned char*)frame_l->imageData, 113 | frame_l->width, frame_l->height, 114 | QImage::Format_RGB888).rgbSwapped(); 115 | 116 | QFile file("/home/pi/caiji2/shake.png"); 117 | if(!file.open(QIODevice::ReadWrite)) 118 | { 119 | QMessageBox::warning(this , "waring" , "open file error" , QMessageBox::Yes , 120 | QMessageBox::Yes); 121 | return; 122 | } 123 | QByteArray ba; 124 | QBuffer buffer(&ba); 125 | buffer.open(QIODevice::WriteOnly); 126 | image.save(&buffer,"png"); 127 | file.write(ba); 128 | 129 | } 130 | void MainWindow::whenfirerecorder() 131 | { 132 | IplImage *frame_l = cvQueryFrame(cam_l);// 从摄像头中抓取并返回每一帧 133 | QImage image = QImage((const unsigned char*)frame_l->imageData, 134 | frame_l->width, frame_l->height, 135 | QImage::Format_RGB888).rgbSwapped(); 136 | 137 | QFile file("/home/pi/caiji2/fire.png"); 138 | if(!file.open(QIODevice::ReadWrite)) 139 | { 140 | QMessageBox::warning(this , "waring" , "open file error" , QMessageBox::Yes , 141 | QMessageBox::Yes); 142 | return; 143 | } 144 | QByteArray ba; 145 | QBuffer buffer(&ba); 146 | buffer.open(QIODevice::WriteOnly); 147 | image.save(&buffer,"png"); 148 | file.write(ba); 149 | 150 | } 151 | void MainWindow::whensmokerecoder() 152 | { 153 | IplImage *frame_l = cvQueryFrame(cam_l);// 从摄像头中抓取并返回每一帧 154 | QImage image = QImage((const unsigned char*)frame_l->imageData, 155 | frame_l->width, frame_l->height, 156 | QImage::Format_RGB888).rgbSwapped(); 157 | 158 | QFile file("/home/pi/caiji2/smoke.png"); 159 | if(!file.open(QIODevice::ReadWrite)) 160 | { 161 | QMessageBox::warning(this , "waring" , "open file error" , QMessageBox::Yes , 162 | QMessageBox::Yes); 163 | return; 164 | } 165 | QByteArray ba; 166 | QBuffer buffer(&ba); 167 | buffer.open(QIODevice::WriteOnly); 168 | image.save(&buffer,"png"); 169 | file.write(ba); 170 | } 171 | 172 | void MainWindow::exit() 173 | { 174 | delete ui; 175 | cvReleaseCapture(&cam_l); 176 | cvReleaseVideoWriter(&video); 177 | dis_thread->exit(); 178 | exit(); 179 | } 180 | 181 | void MainWindow::createActions() 182 | { 183 | openAct = new QAction( QIcon(":/res/open.png") , tr("&Open") , this); 184 | openAct->setStatusTip(tr("open video")); 185 | connect(openAct , SIGNAL(triggered()) , this , SLOT( open() ) ); 186 | 187 | saveAct = new QAction( QIcon(":/res/save.png") , tr("&Save") , this); 188 | saveAct->setStatusTip(tr("save video")); 189 | connect(saveAct , SIGNAL(triggered()) , this , SLOT( save() ) ); 190 | 191 | cutAct = new QAction( QIcon(":/res/cut.png") , tr("&Cut") , this); 192 | cutAct->setStatusTip(tr("cut a frame")); 193 | connect(cutAct , SIGNAL(triggered()) , this , SLOT( cut() ) ); 194 | 195 | exitAct = new QAction( QIcon(":/res/exit.png") , tr("&Exit") , this); 196 | exitAct->setStatusTip(tr("exit programe")); 197 | connect(exitAct , SIGNAL(triggered()) , this , SLOT( exit() ) ); 198 | 199 | } 200 | 201 | void MainWindow::createMenus() 202 | { 203 | fileMenu = menuBar()->addMenu(tr("&File")); 204 | fileMenu->addAction(openAct); 205 | fileMenu->addAction(saveAct); 206 | fileMenu->addAction(cutAct); 207 | fileMenu->addAction(exitAct); 208 | 209 | menuBar()->addSeparator(); 210 | } 211 | 212 | void MainWindow::createToolBars() 213 | { 214 | fileToolBar = addToolBar(tr("File")); 215 | fileToolBar->addAction(openAct); 216 | fileToolBar->addAction(saveAct); 217 | fileToolBar->addAction(cutAct); 218 | } 219 | 220 | void MainWindow::createStatusBar() 221 | { 222 | statusBar()->showMessage(tr("Ready")); 223 | } 224 | 225 | void MainWindow::readFrame() 226 | { 227 | frame = cvQueryFrame(cam_l);// 从摄像头中抓取并返回每一帧 228 | 229 | // 将抓取到的帧,转换为QImage格式。QImage::Format_RGB888不同的摄像头用不同的格式。 230 | QImage image = QImage((const unsigned char*)frame->imageData, frame->width, frame->height, QImage::Format_RGB888).rgbSwapped(); 231 | 232 | ui->label->setPixmap(QPixmap::fromImage(image)); // 将图片显示到label上 233 | ui->label_time->setText(QTime::currentTime().toString("hh:mm:ss.zzz")); 234 | } 235 | 236 | void MainWindow::starvideomonitor() 237 | { 238 | cam_l = cvCreateCameraCapture(0);//打开摄像头,从摄像头中获取视频 239 | connect(dis_thread , SIGNAL(dispaly()) , this , SLOT(readFrame()) ); 240 | dis_thread->start(); 241 | 242 | } 243 | 244 | void MainWindow::SENSOR_ALEART(QString sensorName) 245 | { 246 | if(sensorName=="FLAME") 247 | { 248 | qDebug()<<"FLAME"; 249 | ui->pushButton_flame->setStyleSheet( "QPushButton{border-image: url(:/res/flame.png);}"); 250 | whenfirerecorder(); 251 | } 252 | if(sensorName=="SHAKE") 253 | { 254 | qDebug()<<"SHAKE"; 255 | ui->pushButton_shake->setStyleSheet( "QPushButton{border-image: url(:/res/shake.png);}"); 256 | whenshakerecoder(); 257 | 258 | } 259 | if(sensorName=="SMOKE") 260 | { 261 | qDebug()<<"SMOKE"; 262 | ui->pushButton_smoke->setStyleSheet( "QPushButton{border-image: url(:/res/smoke.png);}"); 263 | whensmokerecoder(); 264 | } 265 | } 266 | 267 | -------------------------------------------------------------------------------- /caiji/mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | #include 6 | #include //包含opencv库头文件 7 | #include 8 | #include"play.h" 9 | 10 | #include 11 | #include 12 | 13 | 14 | 15 | namespace Ui { 16 | class MainWindow; 17 | } 18 | 19 | class Dis_thread; 20 | class cthread; 21 | 22 | class MainWindow : public QMainWindow 23 | { 24 | Q_OBJECT 25 | 26 | public: 27 | explicit MainWindow(QWidget *parent = 0); 28 | ~MainWindow(); 29 | void button_init(); 30 | 31 | private slots: 32 | // void on_pushButton_clicked(); 33 | 34 | void open(); 35 | void save(); 36 | void cut(); 37 | void exit(); 38 | 39 | void starvideomonitor(); 40 | void readFrame(); 41 | 42 | void SENSOR_ALEART(QString sensorName); 43 | 44 | private: 45 | Ui::MainWindow *ui; 46 | 47 | Play play; 48 | 49 | void createActions(); 50 | void createMenus(); 51 | void createToolBars(); 52 | void createStatusBar(); 53 | // void LoadFile(const QString &fileName); 54 | 55 | void whenshakerecoder(); 56 | void whenfirerecorder(); 57 | void whensmokerecoder(); 58 | 59 | QMenu *fileMenu; 60 | QToolBar *fileToolBar; 61 | 62 | QAction *newAct; 63 | QAction *openAct; 64 | QAction *saveAct; 65 | QAction *cutAct; 66 | QAction *exitAct; 67 | 68 | Dis_thread *dis_thread; 69 | cthread *t; 70 | ssThread *sensorThread; 71 | 72 | 73 | QTimer *timer; 74 | QImage *imag; 75 | CvCapture *cam_l;// 视频获取结构, 用来作为视频获取函数的一个参数 76 | IplImage *frame;//申请IplImage类型指针,就是申请内存空间来存放每一帧图像 77 | CvVideoWriter *video; 78 | void cvxCopyQImage(const QImage *qImage, IplImage *pIplImage); 79 | void Ipl2QImageRGB32(IplImage* iplImage,QImage* qImage); 80 | }; 81 | 82 | #endif // MAINWINDOW_H 83 | -------------------------------------------------------------------------------- /caiji/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 821 10 | 486 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 20 | 20 21 | 10 22 | 641 23 | 371 24 | 25 | 26 | 27 | TextLabel 28 | 29 | 30 | 31 | 32 | 33 | 40 34 | 50 35 | 50 36 | 16 37 | 38 | 39 | 40 | TextLabel 41 | 42 | 43 | 44 | 45 | 46 | 690 47 | 50 48 | 81 49 | 81 50 | 51 | 52 | 53 | border-image: url(:/res/lightbulb_unsel.png); 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 710 63 | 240 64 | 41 65 | 41 66 | 67 | 68 | 69 | border-image: url(:/res/flame_unsel.png); 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 710 79 | 290 80 | 41 81 | 41 82 | 83 | 84 | 85 | border-image: url(:/res/shake_unsel.png); 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 710 95 | 340 96 | 41 97 | 41 98 | 99 | 100 | 101 | border-image: url(:/res/smoke_unsel.png); 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 0 112 | 0 113 | 821 114 | 29 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /caiji/myapp.rc: -------------------------------------------------------------------------------- 1 | IDI_ICON1 ICON DISCARDABLE "camera.ico" -------------------------------------------------------------------------------- /caiji/play.cpp: -------------------------------------------------------------------------------- 1 | #include "play.h" 2 | #include "ui_play.h" 3 | 4 | 5 | Play::Play(QWidget *parent) : 6 | QDialog(parent), 7 | ui(new Ui::Play) 8 | { 9 | ui->setupUi(this); 10 | 11 | media = new Phonon::MediaObject; 12 | vwidget = new Phonon::VideoWidget(ui->VideoWidget); 13 | vwidget->resize(431,271); 14 | 15 | Phonon::createPath(media,vwidget); 16 | 17 | button_init(); 18 | 19 | } 20 | 21 | Play::~Play() 22 | { 23 | delete ui; 24 | } 25 | 26 | void Play::on_pushButton_play_clicked() 27 | { 28 | media->play(); 29 | } 30 | 31 | void Play::on_pushButton_stop_clicked() 32 | { 33 | media->stop(); 34 | } 35 | 36 | void Play::on_pushButton_pause_clicked() 37 | { 38 | media->pause(); 39 | } 40 | 41 | void Play::on_pushButton_openfile_clicked() 42 | { 43 | QString path = QFileDialog::getOpenFileName(this,tr("Open Image"),".",tr("Movie(*.avi *.rmvb *.flv);;Music(*.mp3 *.wma)")); 44 | if(path.length()!=0) 45 | { 46 | filePath = path; 47 | media->setCurrentSource(Phonon::MediaSource(filePath)); 48 | 49 | media->play(); 50 | } 51 | } 52 | 53 | void Play::button_init() 54 | { 55 | ui->pushButton_openfile->setStyleSheet( "QPushButton{border-image: url(:/res/openfile_unsel.png); }" 56 | "QPushButton:pressed{border-image:url(:/res/openfile.png);}"); 57 | ui->pushButton_play->setStyleSheet( "QPushButton{border-image: url(:/res/play_unsel.png); }" 58 | "QPushButton:pressed{border-image:url(:/res/play.png);}"); 59 | ui->pushButton_pause->setStyleSheet( "QPushButton{border-image: url(:/res/pause_unsel.png); }" 60 | "QPushButton:pressed{border-image:url(:/res/pause.png);}"); 61 | ui->pushButton_stop->setStyleSheet( "QPushButton{border-image: url(:/res/stop_unsel.png); }" 62 | "QPushButton:pressed{border-image:url(:/res/stop.png);}"); 63 | } 64 | -------------------------------------------------------------------------------- /caiji/play.h: -------------------------------------------------------------------------------- 1 | #ifndef PLAY_H 2 | #define PLAY_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace Ui { 16 | class Play; 17 | } 18 | 19 | class Play : public QDialog 20 | { 21 | Q_OBJECT 22 | 23 | public: 24 | explicit Play(QWidget *parent = 0); 25 | ~Play(); 26 | 27 | 28 | private slots: 29 | void on_pushButton_play_clicked(); 30 | 31 | void on_pushButton_stop_clicked(); 32 | 33 | void on_pushButton_pause_clicked(); 34 | 35 | 36 | void on_pushButton_openfile_clicked(); 37 | 38 | private: 39 | Ui::Play *ui; 40 | 41 | Phonon::MediaObject *media; //player widget 42 | Phonon::VideoWidget *vwidget; //video widget 43 | Phonon::AudioOutput *aOutput; 44 | Phonon::VolumeSlider *volumeSlider; 45 | Phonon::SeekSlider *seekSlider; 46 | QString filePath; 47 | 48 | QStandardItemModel *standardItemModel; 49 | 50 | public: 51 | void setPath(); 52 | void button_init(); 53 | 54 | }; 55 | 56 | #endif // PLAY_H 57 | -------------------------------------------------------------------------------- /caiji/play.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Play 4 | 5 | 6 | 7 | 0 8 | 0 9 | 453 10 | 346 11 | 12 | 13 | 14 | Dialog 15 | 16 | 17 | 18 | 19 | 200 20 | 290 21 | 51 22 | 51 23 | 24 | 25 | 26 | border-image: url(:/res/pause_unsel.png); 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 140 36 | 290 37 | 51 38 | 51 39 | 40 | 41 | 42 | border-image: url(:/res/play_unsel.png); 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 260 52 | 290 53 | 51 54 | 51 55 | 56 | 57 | 58 | border-image: url(:/res/stop_unsel.png); 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 10 68 | 300 69 | 41 70 | 41 71 | 72 | 73 | 74 | border-image: url(:/res/openfile_unsel.png); 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 10 84 | 10 85 | 431 86 | 261 87 | 88 | 89 | 90 | 91 | 92 | 93 | Phonon::VideoWidget 94 | QWidget 95 |
phonon/videowidget.h
96 |
97 |
98 | 99 | 100 |
101 | -------------------------------------------------------------------------------- /caiji/res.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | res/down-arrow.png 4 | res/down-arrow_unsel.png 5 | res/left-arrow.png 6 | res/left-arrow_unsel.png 7 | res/lightbulb.png 8 | res/lightbulb_unsel.png 9 | res/next.png 10 | res/pause.png 11 | res/play.png 12 | res/prev.png 13 | res/right-arrow.png 14 | res/right-arrow_unsel.png 15 | res/up-arrow.png 16 | res/up-arrow_unsel.png 17 | res/cut.png 18 | res/exit.png 19 | res/next_unsel.png 20 | res/open.png 21 | res/pause_unsel.png 22 | res/play_unsel.png 23 | res/prev_unsel.png 24 | res/save.png 25 | res/stop.png 26 | res/stop_unsel.png 27 | res/openfile.png 28 | res/openfile_unsel.png 29 | res/flame.png 30 | res/flame_unsel.png 31 | res/gas.png 32 | res/gas_unsel.png 33 | res/smoke.png 34 | res/smoke_unsel.png 35 | res/shake.png 36 | res/shake_unsel.png 37 | res/recoder.png 38 | res/recoder_unsel.png 39 | 40 | 41 | -------------------------------------------------------------------------------- /caiji/res/camera.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/camera.ico -------------------------------------------------------------------------------- /caiji/res/cut.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/cut.png -------------------------------------------------------------------------------- /caiji/res/down-arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/down-arrow.png -------------------------------------------------------------------------------- /caiji/res/down-arrow_unsel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/down-arrow_unsel.png -------------------------------------------------------------------------------- /caiji/res/exit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/exit.png -------------------------------------------------------------------------------- /caiji/res/flame.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/flame.png -------------------------------------------------------------------------------- /caiji/res/flame_unsel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/flame_unsel.png -------------------------------------------------------------------------------- /caiji/res/gas.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/gas.png -------------------------------------------------------------------------------- /caiji/res/gas_unsel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/gas_unsel.png -------------------------------------------------------------------------------- /caiji/res/left-arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/left-arrow.png -------------------------------------------------------------------------------- /caiji/res/left-arrow_unsel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/left-arrow_unsel.png -------------------------------------------------------------------------------- /caiji/res/lightbulb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/lightbulb.png -------------------------------------------------------------------------------- /caiji/res/lightbulb_unsel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/lightbulb_unsel.png -------------------------------------------------------------------------------- /caiji/res/next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/next.png -------------------------------------------------------------------------------- /caiji/res/next_unsel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/next_unsel.png -------------------------------------------------------------------------------- /caiji/res/open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/open.png -------------------------------------------------------------------------------- /caiji/res/open_unsel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/open_unsel.png -------------------------------------------------------------------------------- /caiji/res/openfile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/openfile.png -------------------------------------------------------------------------------- /caiji/res/openfile_unsel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/openfile_unsel.png -------------------------------------------------------------------------------- /caiji/res/pause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/pause.png -------------------------------------------------------------------------------- /caiji/res/pause_unsel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/pause_unsel.png -------------------------------------------------------------------------------- /caiji/res/play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/play.png -------------------------------------------------------------------------------- /caiji/res/play_unsel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/play_unsel.png -------------------------------------------------------------------------------- /caiji/res/prev.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/prev.png -------------------------------------------------------------------------------- /caiji/res/prev_unsel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/prev_unsel.png -------------------------------------------------------------------------------- /caiji/res/recoder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/recoder.png -------------------------------------------------------------------------------- /caiji/res/recoder_unsel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/recoder_unsel.png -------------------------------------------------------------------------------- /caiji/res/right-arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/right-arrow.png -------------------------------------------------------------------------------- /caiji/res/right-arrow_unsel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/right-arrow_unsel.png -------------------------------------------------------------------------------- /caiji/res/save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/save.png -------------------------------------------------------------------------------- /caiji/res/shake.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/shake.png -------------------------------------------------------------------------------- /caiji/res/shake_unsel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/shake_unsel.png -------------------------------------------------------------------------------- /caiji/res/smoke.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/smoke.png -------------------------------------------------------------------------------- /caiji/res/smoke_unsel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/smoke_unsel.png -------------------------------------------------------------------------------- /caiji/res/stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/stop.png -------------------------------------------------------------------------------- /caiji/res/stop_unsel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/stop_unsel.png -------------------------------------------------------------------------------- /caiji/res/up-arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/up-arrow.png -------------------------------------------------------------------------------- /caiji/res/up-arrow_unsel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yinglin1920/Video_monitor/cd3d9bda6bd1902ccc8e83ef556f12143bd0bccb/caiji/res/up-arrow_unsel.png -------------------------------------------------------------------------------- /caiji/ssthread.cpp: -------------------------------------------------------------------------------- 1 | #include "ssthread.h" 2 | #include 3 | 4 | ssThread::ssThread() 5 | { 6 | Flame =false; 7 | Shake =false; 8 | Smoke = false; 9 | isEnd = false; 10 | wiringPiSetup(); 11 | } 12 | 13 | 14 | void ssThread::checkSensor(){ 15 | int res; 16 | res = readSensor(PIN_FLAME); 17 | if (res == 0) 18 | Flame = true; 19 | res = readSensor(PIN_SHAKE); 20 | if (res == 1) 21 | Shake =true; 22 | res = readSensor(PIN_SMOKE); 23 | if (res == 1) 24 | Smoke =true; 25 | } 26 | 27 | bool ssThread::readSensor(int sensorPin){ 28 | bool res = false; 29 | res = digitalRead(sensorPin); 30 | return res; 31 | } 32 | 33 | void ssThread::stop(){ 34 | isEnd =true; 35 | } 36 | 37 | void ssThread::run(){ 38 | mutex.lock(); 39 | while(!isEnd){ 40 | checkSensor(); 41 | aleart(); 42 | delay(200); 43 | } 44 | mutex.unlock(); 45 | } 46 | 47 | void ssThread::aleart(){ 48 | if(Flame){ 49 | emit SENSOR_ALEART("FLAME"); 50 | Flame = false; 51 | } 52 | if(Shake){ 53 | emit SENSOR_ALEART("SHAKE"); 54 | Shake = false; 55 | } 56 | if(Smoke){ 57 | emit SENSOR_ALEART("SMOKE"); 58 | Smoke = false; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /caiji/ssthread.h: -------------------------------------------------------------------------------- 1 | #ifndef SSTHREAD_H 2 | #define SSTHREAD_H 3 | 4 | #define PIN_FLAME 0 5 | #define PIN_SHAKE 2 6 | #define PIN_SMOKE 3 7 | 8 | #include 9 | #include 10 | #include 11 | class ssThread : public QThread 12 | { 13 | Q_OBJECT 14 | public: 15 | ssThread(); 16 | signals: 17 | void SENSOR_ALEART(QString sensorName); 18 | public slots: 19 | 20 | 21 | private: 22 | bool Flame; 23 | bool Shake; 24 | bool Smoke; 25 | 26 | bool isEnd; 27 | void checkSensor(); 28 | bool readSensor(int sensorPin); 29 | void aleart(); 30 | 31 | public: 32 | void run(); 33 | void stop(); 34 | 35 | QMutex mutex; 36 | }; 37 | 38 | #endif // SSTHREAD_H 39 | --------------------------------------------------------------------------------