author | mickeyl <mickeyl> | 2003-04-06 14:38:18 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-04-06 14:38:18 (UTC) |
commit | 0b985ce87d6ce6d4110a50d5be48831d34794cd2 (patch) (side-by-side diff) | |
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 @@ #include <qimage.h> +#include <qdatetime.h> @@ -29,2 +30,4 @@ +#define SHARPZDC "/dev/sharp_zdc" + ZCameraIO* ZCameraIO::_instance = 0; @@ -45,3 +48,3 @@ ZCameraIO::ZCameraIO() { - _driver = ::open( "/dev/sharp_zdc", O_RDWR ); + _driver = ::open( SHARPZDC, O_RDWR ); if ( _driver == -1 ) @@ -67,3 +70,6 @@ ZCameraIO::~ZCameraIO() if ( _driver != -1 ) + { + setReadMode( 0 ); ::close( _driver ); + } } @@ -109,3 +115,3 @@ bool ZCameraIO::setCaptureFrame( int width, int height, int zoom, bool rot ) _width = width; - _height = _height; + _height = height; _zoom = zoom; @@ -121,3 +127,3 @@ void ZCameraIO::setReadMode( int mode ) { - char b[4]; + char b[10]; sprintf( b, "M=%d", mode ); @@ -138,4 +144,16 @@ bool ZCameraIO::read( char* b, int len ) { + #ifndef NO_TIMING + QTime t; + t.start(); + #endif int rlen = ::read( _driver, b, len ); - odebug << "read " << rlen << " from driver." << oendl; + #ifndef NO_TIMING + int time = t.elapsed(); + #else + int time = -1; + #endif + if ( rlen ) + odebug << "read " << rlen << " ('" << b[0] << b[1] << b[2] << b[3] << "') [" << time << " ms] from driver." << oendl; + else + odebug << "read nothing from driver." << oendl; return rlen == len; @@ -157,23 +175,8 @@ bool ZCameraIO::snapshot( QImage* image ) { - /* - + setReadMode( IMAGE | XFLIP | YFLIP ); char buf[76800]; - - write( _driver, "M=13", 4 ); - write( _driver, "R=240,160,256,480", 17 ); - write( _driver, "M=12", 4 ); - - int result = read( _driver, &buf, sizeof buf ); - - return result == sizeof buf; - - */ - - unsigned char buf[76800]; - unsigned char* bp = buf; + char* bp = buf; unsigned char* p; - int fd = open( "/tmp/cam", O_RDONLY ); - if ( ::read( fd, buf, sizeof buf ) != sizeof buf ) - owarn << "Couldn't read image from /dev/sharp_zdc" << oendl; + read( bp, _readlen ); @@ -197,7 +200,14 @@ bool ZCameraIO::snapshot( QImage* image ) -bool ZCameraIO::snapshot( uchar* buf ) +bool ZCameraIO::snapshot( unsigned char* buf ) { + setReadMode( IMAGE | XFLIP | YFLIP ); + + read( (char*) buf, _readlen ); + + /* //TESTCODE int fd = open( "/tmp/cam", O_RDONLY ); - if ( ::read( fd, buf, 76800 ) != 76800 ) + if ( ::read( fd, (char*) buf, 76800 ) != 76800 ) owarn << "Couldn't read image from /dev/sharp_zdc" << oendl; + // TESTCODE */ + |