QCam.hpp

00001 #ifndef _QCam_hpp_
00002 #define _QCam_hpp_
00003 
00004 #include <qobject.h>
00005 
00006 #include <string>
00007 
00008 #include <stdio.h>
00009 #include <stdlib.h>
00010 //#include <linux/types.h>
00011 //#include <linux/videodev.h>
00012 
00013 #include <map>
00014 
00015 #include "QCamFrame.hpp"
00016 #include "Vector2D.hpp"
00017 
00018 #include "../config.h"
00019 
00020 class QWidget;
00021 class QPushButton;
00022 class QHBox;
00023 class QImage;
00024 class QLabel;
00025 class QCamComboBox;
00026 class QLCDNumber;
00027 class QLineEdit;
00028 class QTimer;
00029 class QDirectoryChooser;
00030 class QCamDisplay;
00031 class CamHistogram;
00032 class QGridBox;
00033 class QCamMovie;
00034 
00035 using namespace std;
00036 
00039 class QCam : public QObject {
00040    Q_OBJECT
00041 public:
00042    QCam();
00046    virtual QCamFrame yuvFrame() const = 0;
00048    virtual const QSize & size() const =0;
00052    virtual void resize(const QSize & s)=0;
00056    virtual const QSize * getAllowedSize() const =0;
00057    virtual ~QCam();
00058    int getY(int x, int y) const {
00059       return yuvFrame().Y()[x+size().width()*y];
00060    }
00061    int getU(int x, int y) const {
00062       return yuvFrame().U()[x/2+size().width()*y/4];
00063    }
00064    int getV(int x, int y) const {
00065       return yuvFrame().V()[x/2+size().width()*y/4];
00066    }
00067 
00072    void setProperty(const string & prop, const string & val,
00073                     bool resetCapture=false);
00074    void setProperty(const string & prop, int val,
00075                     bool resetCapture=false);
00076    void setProperty(const string & prop, double val,
00077                     bool resetCapture=false);
00080    string getProperty(const string & prop) const;
00082    void importProperties(const QCam & other);
00084    void exportProperties( map<string,string>& dest) const;
00086    const map<string,string> & getProperties() const;
00088    virtual QWidget* buildGUI(QWidget * parent);
00090    bool guiBuild() const { return remoteCTRL_ != NULL; }
00091    QWidget * gui() { return remoteCTRL_;}
00092    const QString & label() const;
00094    void writeProperties(const string & fileName) const;
00096    bool saveFrame(const string& file) const;
00098    void annotate(const Vector2D & pos) const;
00099 public slots:
00100    void snapshot() const;
00101    void setCapture(bool doCapture) const;
00102    void setPauseCapture(bool capturePaused) const;
00103    void displayFrames(bool display);
00104    void displayHistogram(bool display);
00105    bool capture() const {return doCapture_;}
00106    bool capturePaused() const {  return doCapture_ && capturePaused_;}
00107    void setCaptureFile(const QString & file);
00108 protected:
00113    void newFrameAvaible();
00114    void label(QString label);
00115    string getFileName() const;
00117    void setTime();
00118 private:
00119    QWidget * remoteCTRL_;
00120    void resetCaptureDir() const;
00121    mutable string seqenceFileName_;
00122    mutable bool doCapture_;
00123    mutable bool capturePaused_;
00124    string captureFile_;
00125    const char* getSaveFormat() const;
00126    const char ** fileFormatList_;
00127    int fileFormatCurrent_;
00128    int maxCaptureInSequence_;
00129    QGridBox * buttonBox_;
00130    QPushButton * displayFramesButton_;
00131    QCamDisplay * displayWindow_;
00132    QPushButton * displayHistogramButton_;
00133    CamHistogram * displayHistogramWindow_;
00134    QDirectoryChooser * dirChooser_;
00135    QCamComboBox * imgFormatBox_;
00136    QPushButton * snapshot_;
00137    QPushButton * pauseCapture_;
00138    QPushButton * capture_;
00139    QLCDNumber * capturedFrame_;
00140    QLineEdit * fileNameW_;
00141    QLineEdit * maxCaptureInSequenceW_;
00142    QCamComboBox * periodicCaptureW_;
00143    int timebetweenCapture_;
00144    QLineEdit * timebetweenCaptureW_;
00145    QTimer * periodicCaptureT_;
00146    QHBox * buttons_;
00147    mutable string oldFileName_;
00148    mutable int fileSeqenceNumber_;
00149    string directory_;
00150    map<string,string> properties_;
00151    QString label_;
00152    mutable QCamMovie * movieWritter_;
00153    QCamMovie * movieWritterSeq_;
00154 #if HAVE_AVIFILE_H
00155    QCamMovie * movieWritterAvi_;
00156 #endif
00157  public:
00158    mutable Vector2D annotationPos_;
00159    mutable bool annotationEnabled_;
00160  signals:
00161    void newFrame();
00162  private slots:
00163    void updateFileFormat(int value) {fileFormatCurrent_=value;}
00164    void maxCaptureInSequenceUpdated(const QString&);
00165    void timebetweenCaptureUpdated(const QString&);
00166    void periodicCapture(int mode);
00167    void timebetweenCaptureTimeout();
00168    void setDirectory(const QString & dir);
00169    void setSizeFromAllowed(int index) { resize(getAllowedSize()[index]);}
00170 };
00171 
00172 #endif
00173 
00174 

Generated on Sat Oct 27 09:21:03 2007 for QastroCam by  doxygen 1.5.1