author | mickeyl <mickeyl> | 2003-04-06 14:38:18 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-04-06 14:38:18 (UTC) |
commit | 0b985ce87d6ce6d4110a50d5be48831d34794cd2 (patch) (unidiff) | |
tree | da19d8dc2cd2b37d15220783940652e8e91f3843 /noncore/multimedia/camera/zcameraio.cpp | |
parent | 91d65a97c956963a24f418fadd7cd69f6a52f5d5 (diff) | |
download | opie-0b985ce87d6ce6d4110a50d5be48831d34794cd2.zip opie-0b985ce87d6ce6d4110a50d5be48831d34794cd2.tar.gz opie-0b985ce87d6ce6d4110a50d5be48831d34794cd2.tar.bz2 |
- add realtime preview widget with zoom control
The camera driver is damn slow. For a 240x160x16 image, it takes ~100ms. That gives approx. 10fps which is too slow for doing video. :(
Diffstat (limited to 'noncore/multimedia/camera/zcameraio.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/camera/zcameraio.cpp | 58 |
1 files changed, 34 insertions, 24 deletions
diff --git a/noncore/multimedia/camera/zcameraio.cpp b/noncore/multimedia/camera/zcameraio.cpp index 7343dca..56b2e13 100644 --- a/noncore/multimedia/camera/zcameraio.cpp +++ b/noncore/multimedia/camera/zcameraio.cpp | |||
@@ -26,2 +26,3 @@ | |||
26 | #include <qimage.h> | 26 | #include <qimage.h> |
27 | #include <qdatetime.h> | ||
27 | 28 | ||
@@ -29,2 +30,4 @@ | |||
29 | 30 | ||
31 | #define SHARPZDC "/dev/sharp_zdc" | ||
32 | |||
30 | ZCameraIO* ZCameraIO::_instance = 0; | 33 | ZCameraIO* ZCameraIO::_instance = 0; |
@@ -45,3 +48,3 @@ ZCameraIO::ZCameraIO() | |||
45 | { | 48 | { |
46 | _driver = ::open( "/dev/sharp_zdc", O_RDWR ); | 49 | _driver = ::open( SHARPZDC, O_RDWR ); |
47 | if ( _driver == -1 ) | 50 | if ( _driver == -1 ) |
@@ -67,3 +70,6 @@ ZCameraIO::~ZCameraIO() | |||
67 | if ( _driver != -1 ) | 70 | if ( _driver != -1 ) |
71 | { | ||
72 | setReadMode( 0 ); | ||
68 | ::close( _driver ); | 73 | ::close( _driver ); |
74 | } | ||
69 | } | 75 | } |
@@ -109,3 +115,3 @@ bool ZCameraIO::setCaptureFrame( int width, int height, int zoom, bool rot ) | |||
109 | _width = width; | 115 | _width = width; |
110 | _height = _height; | 116 | _height = height; |
111 | _zoom = zoom; | 117 | _zoom = zoom; |
@@ -121,3 +127,3 @@ void ZCameraIO::setReadMode( int mode ) | |||
121 | { | 127 | { |
122 | char b[4]; | 128 | char b[10]; |
123 | sprintf( b, "M=%d", mode ); | 129 | sprintf( b, "M=%d", mode ); |
@@ -138,4 +144,16 @@ bool ZCameraIO::read( char* b, int len ) | |||
138 | { | 144 | { |
145 | #ifndef NO_TIMING | ||
146 | QTime t; | ||
147 | t.start(); | ||
148 | #endif | ||
139 | int rlen = ::read( _driver, b, len ); | 149 | int rlen = ::read( _driver, b, len ); |
140 | odebug << "read " << rlen << " from driver." << oendl; | 150 | #ifndef NO_TIMING |
151 | int time = t.elapsed(); | ||
152 | #else | ||
153 | int time = -1; | ||
154 | #endif | ||
155 | if ( rlen ) | ||
156 | odebug << "read " << rlen << " ('" << b[0] << b[1] << b[2] << b[3] << "') [" << time << " ms] from driver." << oendl; | ||
157 | else | ||
158 | odebug << "read nothing from driver." << oendl; | ||
141 | return rlen == len; | 159 | return rlen == len; |
@@ -157,23 +175,8 @@ bool ZCameraIO::snapshot( QImage* image ) | |||
157 | { | 175 | { |
158 | /* | 176 | setReadMode( IMAGE | XFLIP | YFLIP ); |
159 | |||
160 | char buf[76800]; | 177 | char buf[76800]; |
161 | 178 | char* bp = buf; | |
162 | write( _driver, "M=13", 4 ); | ||
163 | write( _driver, "R=240,160,256,480", 17 ); | ||
164 | write( _driver, "M=12", 4 ); | ||
165 | |||
166 | int result = read( _driver, &buf, sizeof buf ); | ||
167 | |||
168 | return result == sizeof buf; | ||
169 | |||
170 | */ | ||
171 | |||
172 | unsigned char buf[76800]; | ||
173 | unsigned char* bp = buf; | ||
174 | unsigned char* p; | 179 | unsigned char* p; |
175 | 180 | ||
176 | int fd = open( "/tmp/cam", O_RDONLY ); | 181 | read( bp, _readlen ); |
177 | if ( ::read( fd, buf, sizeof buf ) != sizeof buf ) | ||
178 | owarn << "Couldn't read image from /dev/sharp_zdc" << oendl; | ||
179 | 182 | ||
@@ -197,7 +200,14 @@ bool ZCameraIO::snapshot( QImage* image ) | |||
197 | 200 | ||
198 | bool ZCameraIO::snapshot( uchar* buf ) | 201 | bool ZCameraIO::snapshot( unsigned char* buf ) |
199 | { | 202 | { |
203 | setReadMode( IMAGE | XFLIP | YFLIP ); | ||
204 | |||
205 | read( (char*) buf, _readlen ); | ||
206 | |||
207 | /* //TESTCODE | ||
200 | int fd = open( "/tmp/cam", O_RDONLY ); | 208 | int fd = open( "/tmp/cam", O_RDONLY ); |
201 | if ( ::read( fd, buf, 76800 ) != 76800 ) | 209 | if ( ::read( fd, (char*) buf, 76800 ) != 76800 ) |
202 | owarn << "Couldn't read image from /dev/sharp_zdc" << oendl; | 210 | owarn << "Couldn't read image from /dev/sharp_zdc" << oendl; |
211 | // TESTCODE */ | ||
212 | |||
203 | 213 | ||