00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00024
00025 #ifndef QVVIDEOREADER_H
00026 #define QVVIDEOREADER_H
00027
00028 #include <QString>
00029 #include <QVImage>
00030
00031 class QVBaseReader;
00032
00164 class QVVideoReader : public QObject
00165 {
00166 Q_OBJECT
00167 public:
00171 enum OpenOption {
00173 Default = 0x0,
00176 RealTime = 0x1,
00178 Deinterlaced = 0x2,
00180 NoLoop = 0x4
00181 };
00184 typedef QFlags<OpenOption> OpenOptions;
00185
00186
00188 typedef enum {
00190 YUVMode= 0,
00192 RGBMode = 1,
00194 GrayOnlyMode = 2
00195 } TSourceMode;
00196
00198 QVVideoReader();
00199
00201 ~QVVideoReader();
00202
00224 bool open( const QString & url_string,
00225 unsigned int & suggested_cols,
00226 unsigned int & suggested_rows,
00227 unsigned int & suggested_fps,
00228 OpenOptions & opts,
00229 TSourceMode & source_mode);
00230
00239 bool open(const QString & url_string)
00240 {
00241 unsigned int suggested_cols = 0, suggested_rows = 0, suggested_fps = 0;
00242 OpenOptions suggested_opts = Default;
00243 TSourceMode source_mode = YUVMode;
00244 return open(url_string,suggested_cols,suggested_rows,suggested_fps,suggested_opts,source_mode);
00245 }
00246
00254 bool grab();
00255
00262 void getGrayImage(QVImage<uChar> &imageGray);
00263
00270 void getRGBImage(QVImage<uChar,3> & imageRGB);
00271
00280 void getRGBImage(QVImage<uChar> &imageR, QVImage<uChar> &imageG, QVImage<uChar> &imageB);
00281
00292 void getYUVImage(QVImage<uChar> &imageY, QVImage<uChar> &imageU, QVImage<uChar> &imageV);
00293
00299 int getLength() const;
00300
00306 int getPos() const;
00307
00308 public slots:
00312 bool close();
00313
00314
00320 bool seek(int pos);
00321
00322 signals:
00324 void sourceOpened();
00325
00327 void sourceClosed();
00328
00330 void newGrab();
00331
00332 public:
00336 const QString getURL() const { return url; };
00337
00341 const QString getScheme() const { return scheme; };
00342
00346 unsigned int getCols() const { return cols; };
00347
00351 unsigned int getRows() const { return rows; };
00352
00356 unsigned int getFPS() const { return fps; };
00357
00358 private:
00359 QString url, scheme;
00360 bool changing_size;
00361 unsigned int cols, rows, fps, frames_grabbed;
00362 bool camera_opened, live_camera, end_of_video;
00363 bool availableGray,availableRGB3,availableYUV,availableRGB;
00364
00365 QVImage<uChar> imgGray;
00366 QVImage<uChar, 3> imgRGB;
00367 QVImage<uChar> imgY, imgU, imgV;
00368 QVImage<uChar> imgR, imgG, imgB;
00369
00370 OpenOptions open_options;
00371 TSourceMode source_mode;
00372 QVBaseReader *base_reader;
00373 };
00374
00375
00376 Q_DECLARE_OPERATORS_FOR_FLAGS(QVVideoReader::OpenOptions);
00377
00378 #endif //QVVIDEOREADER