#ifndef _QCam_hpp_ #define _QCam_hpp_ #include #include #include #include #include #include class QWidget; class QPushButton; class QHBox; class QImage; class QLabel; class QCamRadioBox; class QCam : public QObject { Q_OBJECT public: QCam(); /** return the frame in yuv 420P format. it is the native format used by any algo. */ virtual const uchar * yuvFrame() const=0; virtual const QSize & size() const =0; virtual void resize(const QSize & s)=0; virtual ~QCam(); const QImage & frame() const; void setSnapshotFile(const string & file); void setCaptureFile(const string & file); bool isGray() const {return grayMode_;} void setGray(bool val); void center(const QPoint & ctr) { center_=ctr;} const QPoint & center() const { return center_;} static QWidget * getAllRemoteCTRL(); int getY(int x, int y) { return yuvFrame()[x+size().width()*y]; } int getU(int x, int y) { return yuvFrame()[size().width()*size().height() +x/2+size().width()*y/4]; } int getV(int x, int y) { return yuvFrame()[size().width()*size().height()*3/2 +x/2+size().width()*y/4]; } public slots: void snapshot() const; void setCapture(bool doCapture) const; bool capture() const {return doCapture_;} protected: /** Must be called when a new YUV frame is avaible. It is used by frame() to opimize conversion from YUV to QImage. */ void newFrameAvaible(); bool saveFrame(const string& file) const; QWidget * remoteCTRL_; void setRemoteCTRLcaption(QString label); string getFileName() const; private: mutable uchar * rgbBuffer_; mutable QImage * qFrameRgb_; mutable QImage * qFrameGray_; mutable string seqenceFileName_; bool grayMode_; mutable bool newFrameAvaible_; mutable bool doCapture_; string captureFile_; string snapshotFile_; /* for remote control */ void initRemoteControl(); const char* getSaveFormat() const; const char ** fileFormatList_; int fileFormatCurrent_; QCamRadioBox * imgFormatBox_; QLabel * label_; QPushButton * snapshot_; QPushButton * capture_; QHBox * buttons_; QPoint center_; mutable string oldFileName_; mutable int fileSeqenceNumber_; signals: virtual void newFrame(); private slots: void updateFileFormat(int value) {fileFormatCurrent_=value;} }; #endif