/*
* This file is part of the KALEngine project.
* Copyright (C) 2007 Laurent Gomila <laurent.gom@gmail.com>
* Copyright (C) 2009 Sacha Schutz <istdasklar@free.fr>
* Copyright (C) 2009 Guillaume Martres <smarter@ubuntu.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING.  If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KCAMWIDGET_H
#define KCAMWIDGET_H

#include <QWidget>
#include <QTimer>
#include <QPixmap>
#include <KDebug>
#include <cv.h>
#include <highgui.h>
#include <QPainter>
#include <QPaintEvent>
#include <QMouseEvent>

#include <solid/devicenotifier.h>
 #include <solid/device.h>
#include <solid/deviceinterface.h>



class KCamWidget : public QWidget
{
    Q_OBJECT
public:
    KCamWidget(QWidget * parent=0);
    ~KCamWidget();
    static QImage *Ipl2QImage(const IplImage *img);
    void paintEvent ( QPaintEvent * event );

public slots:
    void captureLoop();

    void takeShoot();
    QSize resolution(){return m_size;}
private:

    QTimer  *m_timer;
    IplImage* m_image;
    QImage *  m_qimage;
    CvCapture* m_capture;
    QSize  m_size;
    double m_fps;
    bool m_error;

};

#endif // KCAMWIDGET_H
