• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

温度+USBカメラ画像 ロガー


Commit MetaInfo

Revision7552607fc8c340fdbea904251c98120b675fe012 (tree)
Zeit2013-03-16 13:03:43
Autoralucky4416 <alucky4416@user...>
Commiteralucky4416

Log Message

CHG: overlay text Timestamp and Tempr, Humid to SaveImage

Ändern Zusammenfassung

Diff

--- a/ImageView.cpp
+++ b/ImageView.cpp
@@ -8,6 +8,12 @@ ImageView::ImageView( QWidget *parent ) : QGraphicsView( parent )
88 pixmapItem = NULL;
99 captureInterval = 0.1; // 0.1 is 100ms
1010 scaleValue = 1.0;
11+
12+ float hscale = 0.5f;
13+ float vscale = 0.5f;
14+ float italicscale = 0.0f;
15+ int thickness = 1;
16+ cvInitFont (&dfont, CV_FONT_HERSHEY_SIMPLEX , hscale, vscale, italicscale, thickness);
1117 }
1218 // ------------------------------------------------------------------------------------------------
1319
@@ -120,11 +126,19 @@ void ImageView::scaleXY( double d )
120126 }
121127 // ------------------------------------------------------------------------------------------------
122128 // 最新画像をファイルへ保存
123-void ImageView::saveCurrentImage(QString filepath)
129+void ImageView::saveCurrentImage(QString filepath, QString overlay_text)
124130 {
125131 if (imageCapture==NULL ) return;
126132 if (filepath.isEmpty()) return;
127133
128- QByteArray tmp = filepath.toLocal8Bit();
129- cvSaveImage(tmp.constData(), imageCapture->GetCurrentIplImage());
134+ if (overlay_text.isEmpty()) {
135+ ;
136+ } else {
137+ QByteArray msg = overlay_text.toLocal8Bit();
138+ // Overley text
139+ cvPutText(imageCapture->GetCurrentIplImage(), msg.constData(), cvPoint(20, 20), &dfont, CV_RGB(0, 255, 0));
140+ }
141+
142+ QByteArray tmppath = filepath.toLocal8Bit();
143+ cvSaveImage(tmppath.constData(), imageCapture->GetCurrentIplImage());
130144 }
--- a/ImageView.h
+++ b/ImageView.h
@@ -8,6 +8,7 @@
88 #include <QtGui/QGraphicsPixmapItem>
99 #include <QtGui/QFileDialog>
1010 #include <QTimer>
11+
1112 #include "ImageCapture.h"
1213 // #include "OtToolBar.h"
1314
@@ -28,7 +29,7 @@ public:
2829 double scaleValue;
2930
3031 void setCapture( ImageCapture* _capture );
31- void saveCurrentImage(QString filepath);
32+ void saveCurrentImage(QString filepath, QString overlay_text);
3233
3334 #if 0
3435 OtToolBar* getToolBar( QWidget* parent );
@@ -46,6 +47,8 @@ public slots:
4647 private:
4748 void showQImage( QImage* qimage );
4849 void scaleXY( double d );
50+
51+ CvFont dfont;
4952 };
5053 // ------------------------------------------------------------------------------------------------
5154
--- a/daqthread.cpp
+++ b/daqthread.cpp
@@ -23,8 +23,8 @@ DAQThread::DAQThread(QObject *parent) :
2323 this, SLOT(slotLogEnded(int)));
2424 connect(logTh, SIGNAL(ChangeLogFilename(QString)),
2525 this, SIGNAL(ChangeLogFilename(QString)));
26- connect(logTh, SIGNAL(SaveCurrentImage(QString)),
27- this, SIGNAL(SaveCurrentImage(QString)));
26+ connect(logTh, SIGNAL(SaveCurrentImage(QString, QString)),
27+ this, SIGNAL(SaveCurrentImage(QString, QString)));
2828
2929 // logTh start
3030 logTh->start();
--- a/daqthread.h
+++ b/daqthread.h
@@ -19,7 +19,7 @@ signals:
1919 void LogStop();
2020 void GetData(QDateTime timestamp, double tmpr, double humid);
2121 void ChangeLogFilename(QString filename);
22- void SaveCurrentImage(QString imgfilepath);
22+ void SaveCurrentImage(QString imgfilepath, QString overlay_text);
2323 void LogStarted();
2424 void LogEnded(int status); // status 0 is success, !0 is Fail
2525
--- a/logthread.cpp
+++ b/logthread.cpp
@@ -137,7 +137,8 @@ void LogThread::run()
137137 // qDebug() << "timestamp: " << timestamp.toString("yyyy/MM/dd hh:mm:ss") << "," << "tmpr = " << event.tmpr << ", humid = " << event.humid;
138138 out << timestamp.toString("yyyy/MM/dd hh:mm") << ", " << event.tmpr << ", " << event.humid << endl;
139139 imgfilepath = logsavefolderpath + QDir::separator() + "USBRHLog_" + timestamp.toString("yyyyMMddhhmm") + ".JPG";
140- emit SaveCurrentImage(imgfilepath);
140+ QString text = timestamp.toString("yyyy/MM/dd hh:mm ") + QString("Tempr = %1 'C, Humid = %2 %").arg(event.tmpr, 0, 'f', 2).arg(event.humid, 0, 'f', 2);
141+ emit SaveCurrentImage(imgfilepath, text);
141142 prev_Minute = timestamp.time().minute();
142143 }
143144 }
--- a/logthread.h
+++ b/logthread.h
@@ -27,7 +27,7 @@ signals:
2727 void LogStarted();
2828 void LogEnded(int status); // status 0 is success, !0 is Fail
2929 void ChangeLogFilename(QString filename);
30- void SaveCurrentImage(QString imgfilepath);
30+ void SaveCurrentImage(QString imgfilepath, QString overlay_text);
3131
3232 public slots:
3333 void slotLogStart(QString logfolderpath);
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -55,8 +55,8 @@ MainWindow::MainWindow(QWidget *parent) :
5555 connect(daqTh, SIGNAL(ChangeLogFilename(QString)),
5656 this, SLOT(slotChangeLogFilename(QString)));
5757
58- connect(daqTh, SIGNAL(SaveCurrentImage(QString)),
59- this, SLOT(slotSaveCurrentImage(QString)));
58+ connect(daqTh, SIGNAL(SaveCurrentImage(QString, QString)),
59+ this, SLOT(slotSaveCurrentImage(QString, QString)));
6060
6161 imageCapture = new ImageCapture( 0, 640, 480 );
6262 ui->ImgView->setCapture( imageCapture );
@@ -122,9 +122,9 @@ void MainWindow::slotChangeLogFilename(QString filename)
122122 label_statusbar->setText(QString(tr("logfile: %1")).arg(filename));
123123 }
124124
125-void MainWindow::slotSaveCurrentImage(QString imgfilepath)
125+void MainWindow::slotSaveCurrentImage(QString imgfilepath, QString overlay_text)
126126 {
127- ui->ImgView->saveCurrentImage(imgfilepath);
127+ ui->ImgView->saveCurrentImage(imgfilepath, overlay_text);
128128 }
129129
130130 void MainWindow::slotLogStarted()
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -29,7 +29,7 @@ signals:
2929 private slots:
3030 void slotGetData(QDateTime, double, double);
3131 void slotChangeLogFilename(QString);
32- void slotSaveCurrentImage(QString imgfilepath);
32+ void slotSaveCurrentImage(QString imgfilepath, QString overlay_text);
3333 void slotLogStarted();
3434 void slotLogEnded(int status);
3535
--- a/mainwindow.ui
+++ b/mainwindow.ui
@@ -7,7 +7,7 @@
77 <x>0</x>
88 <y>0</y>
99 <width>675</width>
10- <height>646</height>
10+ <height>681</height>
1111 </rect>
1212 </property>
1313 <property name="windowTitle">
@@ -215,7 +215,7 @@
215215 <x>10</x>
216216 <y>140</y>
217217 <width>651</width>
218- <height>461</height>
218+ <height>481</height>
219219 </rect>
220220 </property>
221221 </widget>