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