Skip to content
Snippets Groups Projects
CameraView.h 2.37 KiB
Newer Older
  • Learn to ignore specific revisions
  • pixhawk's avatar
    pixhawk committed
    /*=====================================================================
    
    pixhawk's avatar
    pixhawk committed
    PIXHAWK Micro Air Vehicle Flying Robotics Toolkit
    
    pixhawk's avatar
    pixhawk committed
    (c) 2009 PIXHAWK PROJECT  <http://pixhawk.ethz.ch>
    
    pixhawk's avatar
    pixhawk committed
    This file is part of the PIXHAWK project
    
    pixhawk's avatar
    pixhawk committed
        PIXHAWK 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 3 of the License, or
        (at your option) any later version.
    
    pixhawk's avatar
    pixhawk committed
        PIXHAWK 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.
    
    pixhawk's avatar
    pixhawk committed
        You should have received a copy of the GNU General Public License
        along with PIXHAWK. If not, see <http://www.gnu.org/licenses/>.
    
    pixhawk's avatar
    pixhawk committed
    ======================================================================*/
    
    pixhawk's avatar
    pixhawk committed
    /**
     * @file
     *   @brief Brief Description
     *
     *   @author Lorenz Meier <mavteam@student.ethz.ch>
     *
     */
    
    #ifndef CAMERAVIEW_H
    #define CAMERAVIEW_H
    
    #include <QImage>
    #include <QGLWidget>
    #include "UASInterface.h"
    
    class CameraView : public QGLWidget
    {
        Q_OBJECT
    public:
        CameraView(int width = 640, int height = 480, int depth = 8, int channels = 1, QWidget* parent = NULL);
        ~CameraView();
    
        void setImageSize(int width, int height, int depth, int channels);
        void paintGL();
        void resizeGL(int w, int h);
    
    public slots:
        void addUAS(UASInterface* uas);
        void startImage(int imgid, int width, int height, int depth, int channels);
        void setPixels(int imgid, const unsigned char* imageData, int length, unsigned int startIndex);
        void finishImage();
        void saveImage();
        void saveImage(QString fileName);
    
    protected:
        // Image buffers
        unsigned char* rawBuffer1;
        unsigned char* rawBuffer2;
        unsigned char* rawImage;
        unsigned int rawLastIndex;
        unsigned int rawExpectedBytes;
        unsigned int bytesPerLine;
        bool imageStarted;
        static const unsigned char initialColor = 0;
        QImage* image; ///< Double buffer image
        QImage glImage; ///< Displayed image
        int receivedDepth;
        int receivedChannels;
        int receivedWidth;
        int receivedHeight;
    
    pixhawk's avatar
    pixhawk committed
        QMap<int, QImage*> images; ///< Reference to the received images
        int imageId; ///< ID of the currently displayed image
    
    pixhawk's avatar
    pixhawk committed
    
        void commitRawDataToGL();
    };
    
    #endif // CAMERAVIEW_H