summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-05-07 10:21:19 (UTC)
committer mickeyl <mickeyl>2003-05-07 10:21:19 (UTC)
commitb632caef8d73edb7b5cab0c1b58df723ed654410 (patch) (side-by-side diff)
tree91f25d0cf8922c2620f90bd716f7a73f29fa0cdd
parent6fc02cae4bd1fe3478e6e34575f481236ce5ede8 (diff)
downloadopie-b632caef8d73edb7b5cab0c1b58df723ed654410.zip
opie-b632caef8d73edb7b5cab0c1b58df723ed654410.tar.gz
opie-b632caef8d73edb7b5cab0c1b58df723ed654410.tar.bz2
restructure tree for inclusion of a command line application enabling the use as a webcam
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/camera/camera.pro28
-rw-r--r--noncore/multimedia/camera/cmd/.cvsignore5
-rw-r--r--noncore/multimedia/camera/cmd/capture.cpp9
-rw-r--r--noncore/multimedia/camera/cmd/cmd.pro18
-rw-r--r--noncore/multimedia/camera/gui/.cvsignore5
-rw-r--r--noncore/multimedia/camera/lib/.cvsignore5
-rw-r--r--noncore/multimedia/camera/lib/avi.c (renamed from noncore/multimedia/camera/avi.c)0
-rw-r--r--noncore/multimedia/camera/lib/avi.h142
-rw-r--r--noncore/multimedia/camera/lib/imageio.cpp55
-rw-r--r--noncore/multimedia/camera/lib/imageio.h (renamed from noncore/multimedia/camera/main.cpp)20
-rw-r--r--noncore/multimedia/camera/lib/zcameraio.cpp (renamed from noncore/multimedia/camera/zcameraio.cpp)0
-rw-r--r--noncore/multimedia/camera/lib/zcameraio.h (renamed from noncore/multimedia/camera/zcameraio.h)0
-rw-r--r--noncore/multimedia/camera/mainwindow.cpp692
-rw-r--r--noncore/multimedia/camera/mainwindow.h107
-rw-r--r--noncore/multimedia/camera/opie-camera.control4
-rw-r--r--noncore/multimedia/camera/previewwidget.cpp88
-rw-r--r--noncore/multimedia/camera/previewwidget.h50
17 files changed, 252 insertions, 976 deletions
diff --git a/noncore/multimedia/camera/camera.pro b/noncore/multimedia/camera/camera.pro
index c0e6ca8..149ed8d 100644
--- a/noncore/multimedia/camera/camera.pro
+++ b/noncore/multimedia/camera/camera.pro
@@ -1,27 +1,3 @@
-MOC_DIR = ./moc
-OBJECTS_DIR = ./obj
-DESTDIR = $(OPIEDIR)/bin
-TEMPLATE = app
-CONFIG = qt warn_on debug
-
-HEADERS = avi.h \
- imageio.h \
- zcameraio.h \
- previewwidget.h \
- mainwindow.h
-
-SOURCES = avi.c \
- imageio.cpp \
- zcameraio.cpp \
- previewwidget.cpp \
- mainwindow.cpp \
- main.cpp
-
-INCLUDEPATH += $(OPIEDIR)/include
-DEPENDPATH += $(OPIEDIR)/include
-LIBS += -lqpe -lopie -lopiecore2
-INTERFACES =
-TARGET = opiecam
-
-include ( $(OPIEDIR)/include.pro )
+TEMPLATE = subdirs
+SUBDIRS = lib gui cmd
diff --git a/noncore/multimedia/camera/cmd/.cvsignore b/noncore/multimedia/camera/cmd/.cvsignore
new file mode 100644
index 0000000..737c5b2
--- a/dev/null
+++ b/noncore/multimedia/camera/cmd/.cvsignore
@@ -0,0 +1,5 @@
+moc
+obj
+config.in
+Makefile
+
diff --git a/noncore/multimedia/camera/cmd/capture.cpp b/noncore/multimedia/camera/cmd/capture.cpp
new file mode 100644
index 0000000..e34c4e3
--- a/dev/null
+++ b/noncore/multimedia/camera/cmd/capture.cpp
@@ -0,0 +1,9 @@
+#include <stdio.h>
+
+int main( int argc, char** argv )
+{
+ printf( "Not yet implemented.\n" );
+ return 0;
+}
+
+
diff --git a/noncore/multimedia/camera/cmd/cmd.pro b/noncore/multimedia/camera/cmd/cmd.pro
new file mode 100644
index 0000000..68ee907
--- a/dev/null
+++ b/noncore/multimedia/camera/cmd/cmd.pro
@@ -0,0 +1,18 @@
+MOC_DIR = ./moc
+OBJECTS_DIR = ./obj
+DESTDIR = $(OPIEDIR)/bin
+TEMPLATE = app
+CONFIG = qt warn_on debug
+
+HEADERS =
+
+SOURCES = capture.cpp
+
+INCLUDEPATH += $(OPIEDIR)/include
+DEPENDPATH += $(OPIEDIR)/include
+LIBS += -lqpe -lopiecore2
+INTERFACES =
+TARGET = capture
+
+include ( $(OPIEDIR)/include.pro )
+
diff --git a/noncore/multimedia/camera/gui/.cvsignore b/noncore/multimedia/camera/gui/.cvsignore
new file mode 100644
index 0000000..737c5b2
--- a/dev/null
+++ b/noncore/multimedia/camera/gui/.cvsignore
@@ -0,0 +1,5 @@
+moc
+obj
+config.in
+Makefile
+
diff --git a/noncore/multimedia/camera/lib/.cvsignore b/noncore/multimedia/camera/lib/.cvsignore
new file mode 100644
index 0000000..737c5b2
--- a/dev/null
+++ b/noncore/multimedia/camera/lib/.cvsignore
@@ -0,0 +1,5 @@
+moc
+obj
+config.in
+Makefile
+
diff --git a/noncore/multimedia/camera/avi.c b/noncore/multimedia/camera/lib/avi.c
index 77aba33..77aba33 100644
--- a/noncore/multimedia/camera/avi.c
+++ b/noncore/multimedia/camera/lib/avi.c
diff --git a/noncore/multimedia/camera/lib/avi.h b/noncore/multimedia/camera/lib/avi.h
new file mode 100644
index 0000000..fbdc14a
--- a/dev/null
+++ b/noncore/multimedia/camera/lib/avi.h
@@ -0,0 +1,142 @@
+/**********************************************************************
+** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved.
+** Based on work from Andrew Tridgell and the jpegtoavi project
+**
+** This file is part of Opie Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+**********************************************************************/
+
+#ifndef AVI_H
+#define AVI_H
+
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef unsigned char u8;
+typedef unsigned short u16;
+typedef unsigned u32;
+
+// header flags
+
+const u32 AVIF_HASINDEX=0x00000010; /* index at end of file */
+const u32 AVIF_MUSTUSEINDEX=0x00000020;
+const u32 AVIF_ISINTERLEAVED=0x00000100;
+const u32 AVIF_TRUSTCKTYPE=0x00000800;
+const u32 AVIF_WASCAPTUREFILE=0x00010000;
+const u32 AVIF_COPYRIGHTED=0x00020000;
+
+// function prototypes
+
+void avi_start(int fd, int frame);
+void avi_add(int fd, u8 *buf, int size);
+void avi_end(int fd, int width, int height, int fps);
+void fprint_quartet(int fd, unsigned int i);
+
+// the following structures are ordered as they appear in a typical AVI
+
+struct riff_head {
+ char riff[4]; // chunk type = "RIFF"
+ u32 size; // chunk size
+ char avistr[4]; // avi magic = "AVI "
+};
+
+// the avih chunk contains a number of list chunks
+
+struct avi_head {
+ char avih[4]; // chunk type = "avih"
+ u32 size; // chunk size
+ u32 time; // microsec per frame == 1e6 / fps
+ u32 maxbytespersec; // = 1e6*(total size/frames)/per_usec)
+ u32 pad; // pad = 0
+ u32 flags; // e.g. AVIF_HASINDEX
+ u32 nframes; // total number of frames
+ u32 initialframes; // = 0
+ u32 numstreams; // = 1 for now (later = 2 because of audio)
+ u32 suggested_bufsize; // = 0 (no suggestion)
+ u32 width; // width
+ u32 height; // height
+ u32 reserved[4]; // reserved for future use = 0
+};
+
+
+// the LIST chunk contains a number (==#numstreams) of stream chunks
+
+struct list_head {
+ char list[4]; // chunk type = "LIST"
+ u32 size;
+ char type[4];
+};
+
+
+struct dmlh_head {
+ char dmlh[4]; // chunk type dmlh
+ u32 size; // 4
+ u32 nframes; // number of frames
+};
+
+
+struct stream_head {
+ char strh[4]; // chunk type = "strh"
+ u32 size; // chunk size
+ char vids[4]; // stream type = "vids"
+ char codec[4]; // codec name (for us, = "MJPG")
+ u32 flags; // contains AVIT_F* flags
+ u16 priority; // = 0
+ u16 language; // = 0
+ u32 initialframes; // = 0
+ u32 scale; // = usec per frame
+ u32 rate; // 1e6
+ u32 start; // = 0
+ u32 length; // number of frames
+ u32 suggested_bufsize; // = 0
+ u32 quality; // = 0 ?
+ u32 samplesize; // = 0 ?
+};
+
+
+struct db_head {
+ char db[4]; // "00db"
+ u32 size;
+};
+
+// a frame chunk contains one JPEG image
+
+struct frame_head {
+ char strf[4]; // chunk type = "strf"
+ u32 size; // sizeof chunk (big endian) ?
+ u32 size2; // sizeof chunk (little endian) ?
+ u32 width;
+ u32 height;
+ u16 planes; // 1 bitplane
+ u16 bitcount; // 24 bpl
+ char codec[4]; // MJPG (for us)
+ u32 unpackedsize; // = 3*w*h
+ u32 r1; // reserved
+ u32 r2; // reserved
+ u32 clr_used; // reserved
+ u32 clr_important; // reserved
+};
+
+struct idx1_head {
+ char idx1[4]; // chunk type = "idx1"
+ u32 size; // chunk size
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/noncore/multimedia/camera/lib/imageio.cpp b/noncore/multimedia/camera/lib/imageio.cpp
new file mode 100644
index 0000000..ed0d39f
--- a/dev/null
+++ b/noncore/multimedia/camera/lib/imageio.cpp
@@ -0,0 +1,55 @@
+/**********************************************************************
+** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
+**
+** This file is part of Opie Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+**********************************************************************/
+
+#include "imageio.h"
+
+#include <opie2/odebug.h>
+#include <qimage.h>
+
+
+void bufferToImage( int _width, int _height, unsigned char* bp, QImage* image )
+{
+ unsigned char* p;
+
+ image->create( _width, _height, 16 );
+ for ( int i = 0; i < _height; ++i )
+ {
+ p = image->scanLine( i );
+ for ( int j = 0; j < _width; j++ )
+ {
+ *p = *bp;
+ p++;
+ bp++;
+ *p = *bp;
+ p++;
+ bp++;
+ }
+ }
+}
+
+
+void imageToFile( QImage* i, const QString& name, const QString& format, int quality )
+{
+ QImage im = i->convertDepth( 32 );
+ bool result = im.save( name, format, quality );
+ if ( !result )
+ {
+ oerr << "imageio-Problem while writing to " << name << oendl;
+ }
+ else
+ {
+ odebug << format << "-image has been successfully captured" << oendl;
+ }
+}
diff --git a/noncore/multimedia/camera/main.cpp b/noncore/multimedia/camera/lib/imageio.h
index f25475c..8dba2ed 100644
--- a/noncore/multimedia/camera/main.cpp
+++ b/noncore/multimedia/camera/lib/imageio.h
@@ -13,16 +13,14 @@
**
**********************************************************************/
-#include "mainwindow.h"
-#include <opie2/oapplication.h>
+#ifndef IMAGEIO_H
+#define IMAGEIO_H
-int main( int argc, char **argv )
-{
- OApplication a( argc, argv, "Opie-Camera" );
- CameraMainWindow* w = new CameraMainWindow();
- a.showMainWidget( w );
- a.exec();
- delete w;
- return 0;
-}
+#include <qstring.h>
+class QImage;
+
+void bufferToImage( int _width, int height, unsigned char* bp, QImage* image );
+void imageToFile( QImage* i, const QString& name, const QString& format, int quality );
+
+#endif
diff --git a/noncore/multimedia/camera/zcameraio.cpp b/noncore/multimedia/camera/lib/zcameraio.cpp
index c940b45..c940b45 100644
--- a/noncore/multimedia/camera/zcameraio.cpp
+++ b/noncore/multimedia/camera/lib/zcameraio.cpp
diff --git a/noncore/multimedia/camera/zcameraio.h b/noncore/multimedia/camera/lib/zcameraio.h
index 3352a5e..3352a5e 100644
--- a/noncore/multimedia/camera/zcameraio.h
+++ b/noncore/multimedia/camera/lib/zcameraio.h
diff --git a/noncore/multimedia/camera/mainwindow.cpp b/noncore/multimedia/camera/mainwindow.cpp
deleted file mode 100644
index 49c7cbf..0000000
--- a/noncore/multimedia/camera/mainwindow.cpp
+++ b/dev/null
@@ -1,692 +0,0 @@
-/**********************************************************************
-** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
-**
-** This file is part of Opie Environment.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-**********************************************************************/
-
-#include "mainwindow.h"
-#include "previewwidget.h"
-#include "zcameraio.h"
-#include "imageio.h"
-#include "avi.h"
-
-#include <qapplication.h>
-#include <qaction.h>
-#include <qvbox.h>
-#include <qcombobox.h>
-#include <qcursor.h>
-#include <qdatastream.h>
-#include <qdir.h>
-#include <qfile.h>
-#include <qimage.h>
-#include <qlabel.h>
-#include <qlineedit.h>
-#include <qpopupmenu.h>
-#include <qprogressbar.h>
-#include <qpushbutton.h>
-#include <qmessagebox.h>
-#include <qlayout.h>
-#include <qdirectpainter_qws.h>
-#include <qpe/global.h>
-#include <qpe/resource.h>
-#include <qpe/qcopenvelope_qws.h>
-#include <opie/ofiledialog.h>
-#include <opie/odevice.h>
-using namespace Opie;
-#include <opie2/odebug.h>
-
-#include <assert.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-
-#define CAPTUREFILE "/tmp/capture.dat"
-#define OUTPUTFILE "/tmp/output.avi"
-
-#define OUTPUT_TO_CUSTOM 250
-#define OUTPUT_TO_DOCFOLDER 251
-
-CameraMainWindow::CameraMainWindow( QWidget * parent, const char * name, WFlags f )
- :QMainWindow( parent, name, f ),
- _rotation( 270 ), // FIXME: get this from current settings (ODevice?)
- _capturing( false ),
- _pics( 1 ), _videos( 1 )
-{
- #ifdef QT_NO_DEBUG
- if ( !ZCameraIO::instance()->isOpen() )
- {
- QVBox* v = new QVBox( this );
- v->setMargin( 10 );
- QLabel* l1 = new QLabel( v );
- l1->setPixmap( Resource::loadPixmap( "camera/error" ) );
- QLabel* l2 = new QLabel( v );
- l2->setText( "<b>Sorry. could not detect your camera :-(</b><p>"
- "* Is the sharpzdc_cs module loaded ?<br>"
- "* Is /dev/sharpzdc read/writable ?<p>" );
- connect( new QPushButton( "Exit", v ), SIGNAL( clicked() ), this, SLOT( close() ) );
- setCentralWidget( v );
- return;
- }
- #endif
-
- init();
-
- _rotation = 270; //TODO: grab these from the actual settings
-
- preview = new PreviewWidget( this, "camera preview widget" );
- //setCentralWidget( preview ); <--- don't do this!
- preview->resize( QSize( 240, 288 ) );
- preview->show();
-
- // construct a System Channel to receive setRotation messages
- _sysChannel = new QCopChannel( "QPE/System", this );
- connect( _sysChannel, SIGNAL( received( const QCString&, const QByteArray& ) ),
- this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) );
-
- connect( preview, SIGNAL( contextMenuRequested() ), this, SLOT( showContextMenu() ) );
-
- connect( ZCameraIO::instance(), SIGNAL( shutterClicked() ), this, SLOT( shutterClicked() ) );
-
- updateCaption();
-
-};
-
-
-CameraMainWindow::~CameraMainWindow()
-{
-}
-
-
-void CameraMainWindow::init()
-{
- // TODO: Save this stuff in config
- flip = 'A'; // auto
- quality = 50;
- zoom = 1;
- captureX = 480;
- captureY = 640;
- captureFormat = "JPEG";
- outputTo = "Documents Folder";
- prefix = "Untitled";
- appendSettings = true;
-
- resog = new QActionGroup( 0, "reso", true );
- resog->setToggleAction( true );
- new QAction( " 64 x 48", 0, 0, resog, 0, true );
- new QAction( "128 x 96", 0, 0, resog, 0, true );
- new QAction( "192 x 144", 0, 0, resog, 0, true );
- new QAction( "256 x 192", 0, 0, resog, 0, true );
- new QAction( "320 x 240", 0, 0, resog, 0, true );
- new QAction( "384 x 288", 0, 0, resog, 0, true );
- new QAction( "448 x 336", 0, 0, resog, 0, true );
- new QAction( "512 x 384", 0, 0, resog, 0, true );
- new QAction( "576 x 432", 0, 0, resog, 0, true );
- ( new QAction( "640 x 480", 0, 0, resog, 0, true ) )->setOn( true );
-
- qualityg = new QActionGroup( 0, "quality", true );
- qualityg->setToggleAction( true );
- new QAction( " 0 (&minimal)", 0, 0, qualityg, 0, true );
- new QAction( " 25 (&low)", 0, 0, qualityg, 0, true );
- ( new QAction( " 50 (&good)", 0, 0, qualityg, 0, true ) )->setOn( true );
- new QAction( " 75 (&better)", 0, 0, qualityg, 0, true );
- new QAction( "100 (bes&t)", 0, 0, qualityg, 0, true );
-
- zoomg = new QActionGroup( 0, "zoom", true );
- zoomg->setToggleAction( true );
- ( new QAction( "x 1", 0, 0, zoomg, 0, true ) )->setOn( true );
- new QAction( "x 2", 0, 0, zoomg, 0, true );
-
- flipg = new QActionGroup( 0, "flip", true );
- flipg->setToggleAction( true );
- ( new QAction( "Auto (recommended)", 0, 0, flipg, 0, true ) )->setOn( true );
- new QAction( "0 (always off)", 0, 0, flipg, 0, true );
- new QAction( "X (always horizontal)", 0, 0, flipg, 0, true );
- new QAction( "Y (always vertical)", 0, 0, flipg, 0, true );
- new QAction( "* (always both)", 0, 0, flipg, 0, true );
-
- outputTog = new QActionGroup( 0, "output", true );
- outputTog->setToggleAction( true );
- new QAction( "/tmp/", 0, 0, outputTog, 0, true );
- new QAction( "/mnt/card/", 0, 0, outputTog, 0, true );
- new QAction( "/mnt/cf/", 0, 0, outputTog, 0, true );
- docfolder = new QAction( "Documents Folder", 0, 0, outputTog, 0, true );
- docfolder->setOn( true );
- custom = new QAction( "&Custom...", 0, 0, outputTog, 0, true );
-
- outputg = new QActionGroup( 0, "output", true );
- outputg->setToggleAction( true );
- ( new QAction( "JPEG", 0, 0, outputg, 0, true ) )->setOn( true );
- new QAction( "PNG", 0, 0, outputg, 0, true );
- new QAction( "BMP", 0, 0, outputg, 0, true );
- new QAction( "AVI", 0, 0, outputg, 0, true );
-
- connect( resog, SIGNAL( selected(QAction*) ), this, SLOT( resoMenuItemClicked(QAction*) ) );
- connect( qualityg, SIGNAL( selected(QAction*) ), this, SLOT( qualityMenuItemClicked(QAction*) ) );
- connect( zoomg, SIGNAL( selected(QAction*) ), this, SLOT( zoomMenuItemClicked(QAction*) ) );
- connect( flipg, SIGNAL( selected(QAction*) ), this, SLOT( flipMenuItemClicked(QAction*) ) );
- connect( outputTog, SIGNAL( selected(QAction*) ), this, SLOT( outputToMenuItemClicked(QAction*) ) );
- connect( outputg, SIGNAL( selected(QAction*) ), this, SLOT( outputMenuItemClicked(QAction*) ) );
-
-}
-
-
-void CameraMainWindow::systemMessage( const QCString& msg, const QByteArray& data )
-{
- int _newrotation;
-
- QDataStream stream( data, IO_ReadOnly );
- odebug << "received system message: " << msg << oendl;
- if ( msg == "setCurrentRotation(int)" )
- {
- stream >> _newrotation;
- odebug << "received setCurrentRotation(" << _newrotation << ")" << oendl;
-
- switch ( _newrotation )
- {
- case 270: preview->resize( QSize( 240, 288 ) ); break;
- case 180: preview->resize( QSize( 320, 208 ) ); break;
- default: QMessageBox::warning( this, "opie-camera",
- "This rotation is not supported.\n"
- "Supported are 180° and 270°" );
- }
-
- if ( _newrotation != _rotation )
- {
- int tmp = captureX;
- captureX = captureY;
- captureY = tmp;
- _rotation = _newrotation;
- }
-
- updateCaption();
-
- }
-}
-
-
-void CameraMainWindow::changeZoom( int zoom )
-{
- int z;
- switch ( zoom )
- {
- case 0: z = 128; break;
- case 1: z = 256; break;
- case 2: z = 512; break;
- default: assert( 0 ); break;
- }
-
- ZCameraIO::instance()->setCaptureFrame( 240, 160, z );
-}
-
-
-void CameraMainWindow::showContextMenu()
-{
- QPopupMenu reso;
- reso.setCheckable( true );
- resog->addTo( &reso );
-
- QPopupMenu quality;
- quality.setCheckable( true );
- qualityg->addTo( &quality );
-
- QPopupMenu flip;
- flip.setCheckable( true );
- flipg->addTo( &flip );
-
- QPopupMenu zoom;
- zoom.setCheckable( true );
- zoomg->addTo( &zoom );
-
- QPopupMenu prefix;
- prefix.insertItem( "&Choose...", this, SLOT( prefixItemChoosen() ) );
- int id = prefix.insertItem( "&Append Settings", this, SLOT( appendSettingsChoosen() ) );
- prefix.setItemChecked( id, appendSettings );
-
- QPopupMenu outputTo;
- outputTo.setCheckable( true );
- outputTog->addTo( &outputTo );
-
- QPopupMenu output;
- output.setCheckable( true );
- outputg->addTo( &output );
-
- QPopupMenu m( this );
- m.insertItem( "&Resolution", &reso );
- m.insertItem( "&Zoom", &zoom );
- m.insertItem( "&Flip", &flip );
- m.insertItem( "&Quality", &quality );
- m.insertSeparator();
- m.insertItem( "&Prefix", &prefix );
- m.insertItem( "Output &To", &outputTo );
- m.insertItem( "&Output As", &output );
-
- #ifndef QT_NO_DEBUG
- m.insertItem( "&Debug!", this, SLOT( doSomething() ) );
- #endif
-
- m.exec( QCursor::pos() );
-}
-
-
-void CameraMainWindow::resoMenuItemClicked( QAction* a )
-{
- switch ( _rotation )
- {
- case 270:
- captureY = a->text().left(3).toInt();
- captureX = a->text().right(3).toInt();
- break;
- case 180:
- captureX = a->text().left(3).toInt();
- captureY = a->text().right(3).toInt();
- break;
- default: QMessageBox::warning( this, "opie-camera",
- "This rotation is not supported.\n"
- "Supported are 180° and 270°" );
- }
- odebug << "Capture Resolution now: " << captureX << ", " << captureY << oendl;
- updateCaption();
-}
-
-
-void CameraMainWindow::qualityMenuItemClicked( QAction* a )
-{
- quality = a->text().left(3).toInt();
- odebug << "Quality now: " << quality << oendl;
- updateCaption();
-}
-
-
-void CameraMainWindow::zoomMenuItemClicked( QAction* a )
-{
- zoom = QString( a->text().at(2) ).toInt();
- odebug << "Zoom now: " << zoom << oendl;
- ZCameraIO::instance()->setZoom( zoom );
- updateCaption();
-}
-
-
-void CameraMainWindow::flipMenuItemClicked( QAction* a )
-{
- flip = QString( a->text().at(0) );
- odebug << "Flip now: " << flip << oendl;
- if ( flip == "A" )
- ZCameraIO::instance()->setFlip( ZCameraIO::AUTOMATICFLIP );
- else if ( flip == "0" )
- ZCameraIO::instance()->setFlip( ZCameraIO::XNOFLIP | ZCameraIO::YNOFLIP );
- else if ( flip == "X" )
- ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP );
- else if ( flip == "Y" )
- ZCameraIO::instance()->setFlip( ZCameraIO::YFLIP );
- else if ( flip == "*" )
- ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP | ZCameraIO::YFLIP );
-
- updateCaption();
-}
-
-
-void CameraMainWindow::outputToMenuItemClicked( QAction* a )
-{
- if ( a->text() == "&Custom..." )
- {
- QMap<QString, QStringList> map;
- map.insert( tr("All"), QStringList() );
- QStringList text;
- text << "text/*";
- map.insert(tr("Text"), text );
- text << "*";
- map.insert(tr("All"), text );
-
- QString str;
- str = OFileDialog::getSaveFileName( 2, "/", QString::null, map );
- if ( str.isEmpty() || !QFileInfo(str).isDir() )
- {
- docfolder->setOn( true );
- outputTo = "Documents Folder";
- }
- else
- {
- outputTo = str;
- }
- }
- else
- {
- outputTo = a->text();
- }
- odebug << "Output to now: " << outputTo << oendl;
-}
-
-
-void CameraMainWindow::outputMenuItemClicked( QAction* a )
-{
- captureFormat = a->text();
- odebug << "Output format now: " << captureFormat << oendl;
- updateCaption();
-}
-
-
-void CameraMainWindow::prefixItemChoosen()
-{
- QDialog* d = new QDialog( this, "dialog", true );
- d->setCaption( "Enter Prefix..." );
- QVBoxLayout* v = new QVBoxLayout( d );
- QLineEdit* le = new QLineEdit( prefix, d );
- v->addWidget( le );
- le->setFixedWidth( 150 ); //FIXME: 'tis a bit dirty
- if ( d->exec() == QDialog::Accepted )
- prefix = le->text();
- odebug << "Prefix now: " << prefix << oendl;
-}
-
-
-void CameraMainWindow::appendSettingsChoosen()
-{
- appendSettings = !appendSettings;
- odebug << "appendSettings now: " << appendSettings << oendl;
-}
-
-
-void CameraMainWindow::shutterClicked()
-{
- if ( captureFormat != "AVI" ) // capture one photo per shutterClick
- {
- Global::statusMessage( "CAPTURING..." );
- qApp->processEvents();
-
- odebug << "Shutter has been pressed" << oendl;
- ODevice::inst()->touchSound();
-
- performCapture( captureFormat );
- }
- else // capture video! start with one shutter click and stop with the next
- {
- !_capturing ? startVideoCapture() : stopVideoCapture();
- }
-}
-
-
-void CameraMainWindow::performCapture( const QString& format )
-{
- QString name;
-
- if ( outputTo == "Documents Folder" )
- {
- name.sprintf( "%s/Documents/image/%s/", (const char*) QDir::homeDirPath(), (const char*) captureFormat.lower() );
- if ( !QDir( name ).exists() )
- {
- odebug << "creating directory " << name << oendl;
- QString msg = "mkdir -p " + name;
- system( msg.latin1() );
- }
- }
- else
- name = outputTo;
-
- name.append( prefix );
- if ( appendSettings )
- {
- name.append( QString().sprintf( "_%d_%d_q%d", captureX, captureY, quality ) );
- }
- name.append( QString().sprintf( "-%d.%s", _pics++, (const char*) captureFormat.lower() ) );
-
- QImage i;
- ZCameraIO::instance()->captureFrame( captureX, captureY, zoom, &i );
- QImage im = i.convertDepth( 32 );
- bool result = im.save( name, format, quality );
- if ( !result )
- {
- oerr << "imageio-Problem while writing." << oendl;
- Global::statusMessage( "Error!" );
- }
- else
- {
- odebug << captureFormat << "-image has been successfully captured" << oendl;
- Global::statusMessage( "Ok." );
- }
-}
-
-
-void CameraMainWindow::startVideoCapture()
-{
- //ODevice::inst()->touchSound();
- ODevice::inst()->setLedState( Led_Mail, Led_BlinkSlow );
-
- _capturefd = ::open( CAPTUREFILE, O_WRONLY | O_CREAT | O_TRUNC );
- if ( _capturefd == -1 )
- {
- owarn << "can't open capture file: " << strerror(errno) << oendl;
- return;
- }
-
- _capturebuf = new unsigned char[captureX*captureY*2];
- _capturing = true;
- _videopics = 0;
- _framerate = 0;
- updateCaption();
- _time.start();
- preview->setRefreshingRate( 1000 );
- startTimer( 100 ); // too fast but that is ok
-}
-
-
-void CameraMainWindow::timerEvent( QTimerEvent* )
-{
- if ( !_capturing )
- {
- odebug << "timer event in CameraMainWindow without capturing video ?" << oendl;
- return;
- }
-
- odebug << "timer event during video - now capturing frame #" << _videopics+1 << oendl;
-
- ZCameraIO::instance()->captureFrame( captureX, captureY, zoom, _capturebuf );
- _videopics++;
- ::write( _capturefd, _capturebuf, captureX*captureY*2 );
- setCaption( QString().sprintf( "Capturing %dx%d @ %.2f fps %d",
- captureX, captureY, 1000.0 / (_time.elapsed()/_videopics), _videopics ) );
-}
-
-
-void CameraMainWindow::stopVideoCapture()
-{
- killTimers();
- //ODevice::inst()->touchSound();
- ODevice::inst()->setLedState( Led_Mail, Led_Off );
- _capturing = false;
- updateCaption();
- ::close( _capturefd );
- _framerate = 1000.0 / (_time.elapsed()/_videopics);
-
- QString name;
- if ( outputTo == "Documents Folder" )
- {
- name.sprintf( "%s/Documents/video/%s/", (const char*) QDir::homeDirPath(), (const char*) captureFormat.lower() );
- if ( !QDir( name ).exists() )
- {
- odebug << "creating directory " << name << oendl;
- QString msg = "mkdir -p " + name;
- system( msg.latin1() );
- }
- }
- else
- name = outputTo;
-
- name.append( "/" ); // sure is sure and safe is safe ;-)
- name.append( prefix );
- if ( appendSettings )
- name.append( QString().sprintf( "_%d_%d_q%d_%dfps", captureX, captureY, quality, _framerate ) );
- name.append( QString().sprintf( "-%d.%s", _videos++, (const char*) captureFormat.lower() ) );
- postProcessVideo( CAPTUREFILE, name );
-
- #ifndef QT_NO_DEBUG
- preview->setRefreshingRate( 1500 );
- #else
- preview->setRefreshingRate( 200 );
- #endif
-
- //delete[] _capturebuf; //FIXME: close memory leak
-}
-
-void CameraMainWindow::postProcessVideo( const QString& infile, const QString& outfile )
-{
- odebug << "post processing " << infile << " --> " << outfile << oendl;
-
- preview->setRefreshingRate( 0 );
-
- /*
- unsigned char buf[153600];
-
- int fd = ::open( "/var/compile/opie/noncore/multimedia/camera/capture-320x240.dat", O_RDONLY );
- ::read( fd, &buf, 153600 );
- QImage i;
- bufferToImage( 240, 320, (unsigned char*) &buf, &i );
- QPixmap p;
- p.convertFromImage( i );
- preview->setPixmap( p );
- imageToFile( &i, "/tmp/tmpfile", "JPEG", 100 );
- return;
- */
-
- QDialog* fr = new QDialog( this, "splash", false, QWidget::WStyle_StaysOnTop ); //, false, QWidget::WStyle_NoBorder | QWidget::WStyle_Customize );
- fr->setCaption( "Please wait..." );
- QVBoxLayout* box = new QVBoxLayout( fr, 2, 2 );
- QProgressBar* bar = new QProgressBar( fr );
- bar->setCenterIndicator( true );
- bar->setTotalSteps( _videopics-1 );
- QLabel* label = new QLabel( "Post processing frame bla/bla", fr );
- box->addWidget( bar );
- box->addWidget( label );
- fr->show();
- label->show();
- bar->show();
- fr->repaint();
- qApp->processEvents();
-
- // open files
-
- int infd = ::open( (const char*) infile, O_RDONLY );
- if ( infd == -1 )
- {
- owarn << "couldn't open capture file: " << strerror(errno) << oendl;
- return;
- }
-
- int outfd = ::open( (const char*) outfile, O_CREAT | O_WRONLY | O_TRUNC, 0644 );
- if ( outfd == -1 )
- {
- owarn << "couldn't open output file: " << strerror(errno) << oendl;
- return;
- }
-
- int framesize = captureX*captureY*2;
-
- unsigned char* inbuffer = new unsigned char[ framesize ];
- QImage image;
-
- avi_start( outfd, _videopics ); // write preambel
-
- // post process
-
- for ( int i = 0; i < _videopics; ++i )
- {
- odebug << "processing frame " << i << oendl;
-
- // <gui>
- label->setText( QString().sprintf( "Post processing frame %d / %d", i+1, _videopics ) );
- bar->setProgress( i );
- bar->repaint();
- qApp->processEvents();
- // </gui>
-
- int read = ::read( infd, inbuffer, framesize );
- odebug << "read " << read << " bytes" << oendl;
- bufferToImage( captureX, captureY, inbuffer, &image );
-
- QPixmap p;
- p.convertFromImage( image );
- preview->setPixmap( p );
- preview->repaint();
- qApp->processEvents();
-
- #ifdef CAMERA_EXTRA_DEBUG
- QString tmpfilename;
- tmpfilename.sprintf( "/tmp/test/%04d.jpg", i );
- #else
- QString tmpfilename( "/tmp/tempfile" );
- #endif
-
- imageToFile( &image, tmpfilename, "JPEG", quality );
-
- QFile framefile( tmpfilename );
- if ( !framefile.open( IO_ReadOnly ) )
- {
- oerr << "can't process file: %s" << strerror(errno) << oendl;
- return; // TODO: clean up temp ressources
- }
-
- int filesize = framefile.size();
- odebug << "filesize for frame " << i << " = " << filesize << oendl;
-
- unsigned char* tempbuffer = new unsigned char[ filesize ];
- framefile.readBlock( (char*) tempbuffer, filesize );
- avi_add( outfd, tempbuffer, filesize );
- delete tempbuffer;
- framefile.close();
-
- }
-
- avi_end( outfd, captureX, captureY, _framerate );
- ::close( outfd );
- ::close( infd );
-
- label->setText( "deleting temp files..." );
- qApp->processEvents();
- odebug << "deleting temporary capturefile " << infile << oendl;
- QFile::remove( infile );
-
- fr->hide();
- delete fr;
-
- updateCaption();
-
-}
-
-
-void CameraMainWindow::updateCaption()
-{
- if ( !_capturing )
- setCaption( QString().sprintf( "Opie-Camera: %dx%d %s q%d z%d (%s)", captureX, captureY, (const char*) captureFormat.lower(), quality, zoom, (const char*) flip ) );
- else
- setCaption( "Opie-Camera: => CAPTURING <=" );
- qApp->processEvents();
-}
-
-
-#ifndef QT_NO_DEBUG
-void CameraMainWindow::doSomething()
-{
- captureX = 240;
- captureY = 320;
- _videopics = 50;
- _framerate = 5;
- postProcessVideo( "/var/compile/opie/noncore/multimedia/camera/capture.dat",
- "/tmp/output.avi" );
-}
-#else
-void CameraMainWindow::doSomething()
-{
-}
-#endif
-
diff --git a/noncore/multimedia/camera/mainwindow.h b/noncore/multimedia/camera/mainwindow.h
deleted file mode 100644
index 451ad5f..0000000
--- a/noncore/multimedia/camera/mainwindow.h
+++ b/dev/null
@@ -1,107 +0,0 @@
-/**********************************************************************
-** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved.
-**
-** This file is part of Opie Environment.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-**********************************************************************/
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <qmainwindow.h>
-#include <qdatetime.h>
-#include <qimage.h>
-#include <qpixmap.h>
-#include <qdatetime.h>
-
-class QAction;
-class QActionGroup;
-class QIconSet;
-class QTimerEvent;
-class QToolButton;
-class QLabel;
-class MainWindowBase;
-class QCopChannel;
-class PreviewWidget;
-
-class CameraMainWindow: public QMainWindow
-{
- Q_OBJECT
-
- public:
- CameraMainWindow( QWidget * parent = 0, const char * name = "mainwindow", WFlags f = 0 );
- virtual ~CameraMainWindow();
-
- public slots:
- void changeZoom( int );
- void systemMessage( const QCString&, const QByteArray& );
- void showContextMenu();
- void resoMenuItemClicked( QAction* );
- void qualityMenuItemClicked( QAction* );
- void zoomMenuItemClicked( QAction* );
- void flipMenuItemClicked( QAction* );
- void outputToMenuItemClicked( QAction* );
- void outputMenuItemClicked( QAction* );
- void prefixItemChoosen();
- void appendSettingsChoosen();
- void shutterClicked();
-
- void updateCaption();
-
- protected:
- void init();
- void startVideoCapture();
- void stopVideoCapture();
- void postProcessVideo( const QString&, const QString& );
- void performCapture( const QString& );
-
- virtual void timerEvent( QTimerEvent* );
-
- protected slots:
- void doSomething(); // solely for debugging purposes
-
- private:
- PreviewWidget* preview;
- int _rotation;
- QCopChannel* _sysChannel;
-
- QActionGroup* resog;
- QActionGroup* qualityg;
- QActionGroup* zoomg;
- QActionGroup* flipg;
- QActionGroup* outputTog;
- QAction* custom;
- QAction* docfolder;
- QActionGroup* outputg;
-
- QString flip;
- int quality;
- int zoom;
- int captureX;
- int captureY;
- QString captureFormat;
-
- QString outputTo;
- QString prefix;
- bool appendSettings;
-
- bool _capturing;
- int _pics;
- int _videos;
-
- QTime _time;
- int _videopics;
- int _capturefd;
- int _framerate;
- unsigned char* _capturebuf;
-};
-
-#endif
diff --git a/noncore/multimedia/camera/opie-camera.control b/noncore/multimedia/camera/opie-camera.control
index 1731ad2..3769901 100644
--- a/noncore/multimedia/camera/opie-camera.control
+++ b/noncore/multimedia/camera/opie-camera.control
@@ -1,10 +1,10 @@
Package: opie-camera
-Files: bin/opiecam pics/camera apps/Applications/camera.desktop
+Files: bin/opiecam bin/capture pics/camera apps/Applications/camera.desktop
Priority: optional
Section: opie/applications
Maintainer: Michael 'Mickey' Lauer <mickeyl@handhelds.org>
Architecture: arm
-Version: 1.0
+Version: 1.0.1-$SUB_VERSION
Depends: task-opie-minimal, libopie2 (1.8.1)
Description: A Camera Application
A Camera Application to use with the Sharp CE-AG06.
diff --git a/noncore/multimedia/camera/previewwidget.cpp b/noncore/multimedia/camera/previewwidget.cpp
deleted file mode 100644
index 08330d0..0000000
--- a/noncore/multimedia/camera/previewwidget.cpp
+++ b/dev/null
@@ -1,88 +0,0 @@
-/**********************************************************************
-** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
-**
-** This file is part of Opie Environment.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-**********************************************************************/
-
-#include "previewwidget.h"
-#include "zcameraio.h"
-
-#include <opie2/odebug.h>
-
-#include <assert.h>
-
-PreviewWidget::PreviewWidget( QWidget * parent, const char * name, WFlags f )
- :QLabel( parent, name, f )
-{
- #ifndef QT_NO_DEBUG
- setBackgroundColor( QColor( 255, 0, 0 ) );
- #else
- setBackgroundMode( NoBackground );
- #endif
-
- #ifndef QT_NO_DEBUG
- if ( ZCameraIO::instance()->isOpen() ) startTimer( 1500 );
- #else
- if ( ZCameraIO::instance()->isOpen() ) startTimer( 200 );
- #endif
-};
-
-
-PreviewWidget::~PreviewWidget()
-{
-}
-
-
-void PreviewWidget::resizeEvent( QResizeEvent* e )
-{
- QLabel::resizeEvent( e );
- int w = e->size().width();
- int h = e->size().height();
- ZCameraIO::instance()->setCaptureFrame( e->size().width(),
- e->size().height(),
- 256,
- w < h );
-}
-
-
-void PreviewWidget::timerEvent( QTimerEvent* )
-{
- //QDirectPainter fb( this );
- //ZCameraIO::instance()->snapshot( fb.frameBuffer() );
-
- if ( ZCameraIO::instance()->snapshot( &i ) )
- {
- p.convertFromImage( i );
- setPixmap( p );
- }
-}
-
-
-void PreviewWidget::mousePressEvent( QMouseEvent* )
-{
- emit contextMenuRequested();
-}
-
-
-void PreviewWidget::setRefreshingRate( int ms )
-{
- killTimers();
- if ( ms )
- startTimer( ms );
-}
-
-
-void PreviewWidget::refresh()
-{
- QTimerEvent t( 10 ); // event id is meaningless in this case
- timerEvent( &t );
-}
diff --git a/noncore/multimedia/camera/previewwidget.h b/noncore/multimedia/camera/previewwidget.h
deleted file mode 100644
index d37f80f..0000000
--- a/noncore/multimedia/camera/previewwidget.h
+++ b/dev/null
@@ -1,50 +0,0 @@
-/**********************************************************************
-** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved.
-**
-** This file is part of Opie Environment.
-**
-** This file may be distributed and/or modified under the terms of the
-** GNU General Public License version 2 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.
-**
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
-** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-**
-**********************************************************************/
-
-#ifndef PREVIEWWIDGET_H
-#define PREVIEWWIDGET_H
-
-#include <qlabel.h>
-#include <qimage.h>
-#include <qpixmap.h>
-
-class QTimerEvent;
-class QResizeEvent;
-
-class PreviewWidget: public QLabel
-{
- Q_OBJECT
-
- public:
- PreviewWidget( QWidget * parent = 0, const char * name = 0, WFlags f = 0 );
- virtual ~PreviewWidget();
-
- void setRefreshingRate( int ms );
- void refresh();
-
- protected:
- virtual void timerEvent( QTimerEvent* );
- virtual void resizeEvent( QResizeEvent* );
- virtual void mousePressEvent( QMouseEvent* );
-
- signals:
- void contextMenuRequested();
-
- private:
- QPixmap p;
- QImage i;
-};
-
-#endif