00001
00002
00003
00004 #include "obstDet.h"
00005 #include <qwt_plot.h>
00006
00007 obstDet::obstDet(QWidget *parent)
00008 {
00009 mf.setupUi(&w);
00010
00011 QObject::connect(mf.action_Open_File, SIGNAL( activated() ), this, SLOT( openFile() ) );
00012 QObject::connect(mf.action_About, SIGNAL( activated() ), this, SLOT( about() ) );
00013 QObject::connect(mf.intervalBox, SIGNAL( valueChanged(int) ), this, SLOT( updateCaptureInt(int) ) );
00014 QObject::connect(mf.captureBool, SIGNAL( stateChanged(int) ), this, SLOT( toggleCapture(int) ) );
00015 QObject::connect(&fs, SIGNAL( frameReady(QImage*) ), mf.video1, SLOT( displayImage(QImage*) ) );
00016 QObject::connect(mf.algCheck, SIGNAL( stateChanged(int) ), this, SLOT( algToggle(int) ) );
00017 QObject::connect(mf.playButton, SIGNAL( clicked() ), this, SLOT( togglePause() ) );
00018
00019
00020 fs.setCaptureRate(mf.intervalBox->value());
00021 w.showMaximized();
00022 w.show();
00023
00024
00025 mf.algSelector->addItem(tsAlg.getName());
00026
00027
00028
00029
00030 test();
00031 }
00032 void obstDet::openFile()
00033 {
00034 QString s = QFileDialog::getOpenFileName( this,"Choose a video file","/home","Videos (*.avi *.mpg *.mpeg)");
00035 if ( !s.isNull() )
00036 {
00037 if ( fs.attachSource(&s) )
00038 {
00039 QMessageBox::warning(this, "VisualODF",
00040 "Could not open the specified video source.\n");
00041 }
00042 else
00043 {
00044 mf.captureBool->setEnabled(true);
00045 mf.algCheck->setEnabled(true);
00046 fs.togglePause();
00047 }
00048
00049 }
00050
00051
00052 }
00053 void obstDet::togglePause()
00054 {
00055 fs.togglePause();
00056 }
00057
00058 void obstDet::about()
00059 {
00060 QMessageBox::about( this, "About...","Contributors:\nRob Russell (robbie _-dot-_ russell _-at-_ gmail _-dot_- com)" );
00061 }
00062 void obstDet::test()
00063 {
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074 unsigned long mkey;
00075
00076
00077
00078
00079
00080
00081
00082 }
00083
00084 void obstDet::addVideoMessage(QString *str)
00085 {
00086 mf.vidMsgTxt->append(*str);
00087 }
00088
00089 void obstDet::addTcasMessage(QString *str)
00090 {
00091 mf.tcasMsgTxt->append(*str);
00092 }
00093
00094 void obstDet::updateCaptureInt(int i)
00095 {
00096 fs.setCaptureRate(i);
00097 QString str = "Updated capture interval to every ";
00098 str.append(QString::number(i));
00099 str.append("ms");
00100 addVideoMessage(&str);
00101
00102 }
00103
00104 void obstDet::toggleCapture(int i)
00105 {
00106 QString str;
00107 if ( i == Qt::Checked )
00108 {
00109 fs.startCapture();
00110 str="Capture started.";
00111 }
00112 else if ( i == Qt::Unchecked )
00113 {
00114 fs.stopCapture();
00115 str="Capture stopped.";
00116 }
00117 addVideoMessage(&str);
00118
00119 }
00120
00121 void obstDet::algToggle(int i)
00122 {
00123 QString str;
00124 QString tmpstr = mf.algSelector->currentText();
00125 if ( i == Qt::Checked )
00126 {
00134
00135 mf.algSelector->setEnabled(false);
00136 if (tmpstr == tsAlg.getName())
00137 {
00138
00139 QObject::connect(&fs, SIGNAL( frameReady(QImage*) ), &tsAlg, SLOT( processFrame(QImage*) ) );
00140
00141 QObject::connect(&tsAlg, SIGNAL( imageReady(QImage*) ), mf.video2, SLOT( displayImage(QImage*) ) );
00142
00143 QObject::connect(&tsAlg, SIGNAL(foundObstacle(threatType, trendDir, int , int , int, unsigned long& ) ), mf.tcas, SLOT( addThreat(threatType, trendDir, int, int, int, unsigned long&)) );
00144 QObject::connect(&tsAlg, SIGNAL(foundObstacle(threatType, trendDir, int , int , int, unsigned long& ) ), mf.pieDisp, SLOT( addThreat(threatType, trendDir, int, int, int, unsigned long&)) );
00145
00146 QObject::connect(&tsAlg, SIGNAL( displayMessage(QString*) ), this, SLOT( addTcasMessage(QString*) ) );
00147
00148
00149 }
00150 else if (tmpstr == "Pretend Second Algorithm Goes Here")
00151 {}
00152
00153 str="Algorithm enabled.";
00154 }
00155 else if ( i == Qt::Unchecked )
00156 {
00161
00162 mf.algSelector->setEnabled(true);
00163
00164 if (tmpstr == tsAlg.getName())
00165 {
00166 QObject::disconnect(&fs, SIGNAL( frameReady(QImage*) ), &tsAlg, SLOT( processFrame(QImage*) ) );
00167 QObject::disconnect(&tsAlg, SIGNAL( imageReady(QImage*) ), mf.video2, SLOT( displayImage(QImage*) ) );
00168 QObject::disconnect(&tsAlg, SIGNAL(foundObstacle(threatType, trendDir, int , int , int, unsigned long& ) ), mf.tcas, SLOT( addThreat(threatType, trendDir, int, int, int,unsigned long&) ));
00169 QObject::disconnect(&tsAlg, SIGNAL( displayMessage(QString*) ), this, SLOT( addTcasMessage(QString*) ) );
00170 QObject::disconnect(&tsAlg, SIGNAL(foundObstacle(threatType, trendDir, int , int , int, unsigned long& ) ), mf.pieDisp, SLOT( addThreat(threatType, trendDir, int, int, int, unsigned long&)) );
00171 }
00172 else if (tmpstr == "Pretend Second Algorithm Goes Here")
00173 {}
00174 str="Algorithm disabled.";
00175 }
00176 addVideoMessage(&str);
00177 }