[89] | 1 | /*********************************************************************
|
---|
| 2 | // created: 2006/06/08 - 21:45
|
---|
| 3 | // filename: Camera1394.h
|
---|
| 4 | //
|
---|
| 5 | // author: Gerald Dherbomez
|
---|
| 6 | //
|
---|
| 7 | // version: $Id: Camera1394.h 1199 2012-08-01 08:51:24Z kurdejma $
|
---|
| 8 | //
|
---|
| 9 | // purpose: Interface with the CMU driver
|
---|
| 10 | //
|
---|
| 11 | //
|
---|
| 12 | // Below are the format, mode and framerate supported by the driver:
|
---|
| 13 | //
|
---|
| 14 | // -----------------------------------------
|
---|
| 15 | // Format Mode Image Size Color Format
|
---|
| 16 | // -----------------------------------------
|
---|
| 17 | // 0 0 160x120 YUV(4:4:4)
|
---|
| 18 | // 1 320x240 YUV(4:2:2)
|
---|
| 19 | // 2 640x480 YUV(4:1:1)
|
---|
| 20 | // 3 640x480 YUV(4:2:2)
|
---|
| 21 | // 4 640x480 RGB
|
---|
| 22 | // 5 640x480 Mono (8-bit)
|
---|
| 23 | // 6 640x480 Mono (16-bit)
|
---|
| 24 | // -----------------------------------------
|
---|
| 25 | // 1 0 800x600 YUV(4:2:2)
|
---|
| 26 | // 1 800x600 RGB
|
---|
| 27 | // 2 800x600 Mono (8-bit)
|
---|
| 28 | // 3 1024x768 YUV(4:2:2)
|
---|
| 29 | // 4 1024x768 RGB
|
---|
| 30 | // 5 1024x768 Mono (8-bit)
|
---|
| 31 | // 6 800x600 Mono (16-bit)
|
---|
| 32 | // 7 1024x768 Mono (16-bit)
|
---|
| 33 | // -----------------------------------------
|
---|
| 34 | // 2 0 1280x960 YUV(4:2:2)
|
---|
| 35 | // 1 1280x960 RGB
|
---|
| 36 | // 2 1280x960 Mono (8-bit)
|
---|
| 37 | // 3 1600x1200 YUV(4:2:2)
|
---|
| 38 | // 4 1600x1200 RGB
|
---|
| 39 | // 5 1600x1200 Mono (8-bit)
|
---|
| 40 | // 6 1280x960 Mono (16-bit)
|
---|
| 41 | // 7 1600x1200 Mono (16-bit)
|
---|
| 42 | // -----------------------------------------
|
---|
| 43 | // 7 0-7 Partial Scan Selectable
|
---|
| 44 | // -----------------------------------------
|
---|
| 45 | //
|
---|
| 46 | //
|
---|
| 47 | // ------------------
|
---|
| 48 | // Code Rate (fps)
|
---|
| 49 | // ------------------
|
---|
| 50 | // 0 1.875
|
---|
| 51 | // 1 3.75
|
---|
| 52 | // 2 7.5
|
---|
| 53 | // 3 15
|
---|
| 54 | // 4 30
|
---|
| 55 | // 5 60
|
---|
| 56 | // ------------------
|
---|
| 57 | //
|
---|
| 58 | //
|
---|
| 59 | *********************************************************************/
|
---|
| 60 |
|
---|
| 61 | #ifndef _CAMERA1394_H_
|
---|
| 62 | #define _CAMERA1394_H_
|
---|
| 63 |
|
---|
| 64 | //# include "../../include/VisualMemoryManager/struct.h"
|
---|
| 65 |
|
---|
| 66 | #include <qthread.h>
|
---|
| 67 | #include <qimage.h>
|
---|
| 68 | #include <qmutex.h>
|
---|
| 69 |
|
---|
| 70 | #include "kernel/ComponentBase.h"
|
---|
| 71 | #include "kernel/DbiteFile.h"
|
---|
[94] | 72 | //#include "../DbtPlyPluginVision/ImageViewer.h"
|
---|
[89] | 73 |
|
---|
| 74 | #ifdef WIN32
|
---|
[94] | 75 | # define NOMINMAX
|
---|
[89] | 76 | # include <windows.h>
|
---|
| 77 | # include "C1394Camera/1394Camera.h"
|
---|
| 78 | #endif
|
---|
| 79 |
|
---|
| 80 | namespace pacpus {
|
---|
| 81 |
|
---|
| 82 | #define MAX_CHAR_PICTURE_NAME 64
|
---|
| 83 | #define MAX_CHAR_DIRECTORY_NAME 64
|
---|
| 84 |
|
---|
| 85 | class Camera1394
|
---|
| 86 | : public QThread
|
---|
| 87 | , public ComponentBase
|
---|
| 88 | {
|
---|
| 89 | Q_OBJECT
|
---|
| 90 |
|
---|
| 91 | public:
|
---|
| 92 | Camera1394(QString name);
|
---|
| 93 | ~Camera1394();
|
---|
| 94 | void run();
|
---|
| 95 |
|
---|
| 96 | bool fillRGB32Image(unsigned char * buffer);
|
---|
| 97 | void YUV444toRGB32(unsigned char* buffer);
|
---|
| 98 | void YUV422toRGB32(unsigned char *buffer);
|
---|
| 99 | void YUV411toRGB32(unsigned char* buffer);
|
---|
| 100 | void YtoRGB32(unsigned char * buffer);
|
---|
| 101 | void Y16toRGB32(unsigned char * buffer); // not tested, no camera with this mode available
|
---|
| 102 | void RGB16toRGB32(unsigned char * buffer); // not tested, no camera with this mode available
|
---|
| 103 | void RGB24toRGB32(unsigned char * buffer);
|
---|
| 104 |
|
---|
| 105 | inline void startAcquiring() { acquiring_ = TRUE; };
|
---|
| 106 | inline void stopAcquiring() { acquiring_ = FALSE; };
|
---|
| 107 | inline void startRecording() { recording_ = TRUE; };
|
---|
| 108 | inline void stopRecording() { recording_ = FALSE; };
|
---|
| 109 |
|
---|
| 110 | virtual void stopActivity(); /*!< to stop the processing thread */
|
---|
| 111 | virtual void startActivity(); /*!< to start the processing thread */
|
---|
| 112 | virtual ComponentBase::COMPONENT_CONFIGURATION configureComponent(XmlComponentConfig config);
|
---|
| 113 |
|
---|
| 114 | // return the period in µs corresponding to the framerate parameter
|
---|
| 115 | double getPeriod();
|
---|
| 116 | bool recordImage(QString format);
|
---|
| 117 |
|
---|
| 118 | Q_SIGNALS:
|
---|
| 119 | void newImage(QImage*);
|
---|
| 120 | void corruptedImage();
|
---|
| 121 |
|
---|
| 122 | protected:
|
---|
| 123 | C1394Camera * theCamera;
|
---|
| 124 | unsigned char * image_;
|
---|
| 125 | QImage * qimage_;
|
---|
| 126 |
|
---|
| 127 | private:
|
---|
| 128 | // Initialize the camera
|
---|
| 129 | bool initCamera();
|
---|
| 130 |
|
---|
| 131 | // return true if the period T (µs) corresponds to the framerate (at +/-20%)
|
---|
| 132 | bool isPeriodGood(int T);
|
---|
| 133 |
|
---|
| 134 | // properties
|
---|
| 135 | int cameraNode_;
|
---|
| 136 | int videoFormat_;
|
---|
| 137 | int videoMode_;
|
---|
| 138 | int frameRate_;
|
---|
| 139 | bool reverseImage_;
|
---|
| 140 | bool acquiring_;
|
---|
| 141 | bool displaying_;
|
---|
| 142 | bool recording_;
|
---|
| 143 | int zoom_;
|
---|
| 144 |
|
---|
| 145 | int imageCounter_;
|
---|
| 146 | QString recordFormat_;
|
---|
| 147 |
|
---|
| 148 | char imageName_[MAX_CHAR_PICTURE_NAME+MAX_CHAR_DIRECTORY_NAME];
|
---|
| 149 | QMutex* imageMutex_;
|
---|
| 150 |
|
---|
| 151 | road_time_t time_;
|
---|
| 152 | road_time_t prevTime_;
|
---|
| 153 | road_timerange_t tr_;
|
---|
| 154 |
|
---|
| 155 | pacpus::DbiteFile file_;
|
---|
| 156 |
|
---|
[94] | 157 | // ImageViewer * viewer_;
|
---|
[89] | 158 |
|
---|
| 159 | };
|
---|
| 160 |
|
---|
| 161 | } // namespace pacpus
|
---|
| 162 |
|
---|
| 163 | #endif // _CAMERA1394_H_
|
---|