CameraView.h 2.37 KB
Newer Older
pixhawk's avatar
pixhawk committed
1
/*=====================================================================
2

pixhawk's avatar
pixhawk committed
3
PIXHAWK Micro Air Vehicle Flying Robotics Toolkit
4

pixhawk's avatar
pixhawk committed
5
(c) 2009 PIXHAWK PROJECT  <http://pixhawk.ethz.ch>
6

pixhawk's avatar
pixhawk committed
7
This file is part of the PIXHAWK project
8

pixhawk's avatar
pixhawk committed
9 10 11 12
    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.
13

pixhawk's avatar
pixhawk committed
14 15 16 17
    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.
18

pixhawk's avatar
pixhawk committed
19 20
    You should have received a copy of the GNU General Public License
    along with PIXHAWK. If not, see <http://www.gnu.org/licenses/>.
21

pixhawk's avatar
pixhawk committed
22
======================================================================*/
23

pixhawk's avatar
pixhawk committed
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
/**
 * @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
74 75
    QMap<int, QImage*> images; ///< Reference to the received images
    int imageId; ///< ID of the currently displayed image
pixhawk's avatar
pixhawk committed
76 77 78 79 80

    void commitRawDataToGL();
};

#endif // CAMERAVIEW_H