summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-02-13 13:38:06 (UTC)
committer mickeyl <mickeyl>2004-02-13 13:38:06 (UTC)
commit97bdea970b2fb017eef7d3b03d7a316eb216266b (patch) (side-by-side diff)
tree21e9eb8986829cde04447a2018ba745a64640386
parentdba46ffd80c121aee412ec45f9bd6d0b9be5058e (diff)
downloadopie-97bdea970b2fb017eef7d3b03d7a316eb216266b.zip
opie-97bdea970b2fb017eef7d3b03d7a316eb216266b.tar.gz
opie-97bdea970b2fb017eef7d3b03d7a316eb216266b.tar.bz2
opie-camera no longer needs libopie1
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/camera/cmd/cmd.pro2
-rw-r--r--noncore/multimedia/camera/config.in6
-rw-r--r--noncore/multimedia/camera/gui/gui.pro4
-rw-r--r--noncore/multimedia/camera/gui/mainwindow.cpp28
-rw-r--r--noncore/multimedia/camera/lib/lib.pro4
5 files changed, 21 insertions, 23 deletions
diff --git a/noncore/multimedia/camera/cmd/cmd.pro b/noncore/multimedia/camera/cmd/cmd.pro
index 7981e82..b90289b 100644
--- a/noncore/multimedia/camera/cmd/cmd.pro
+++ b/noncore/multimedia/camera/cmd/cmd.pro
@@ -1,18 +1,16 @@
-MOC_DIR = ./moc
-OBJECTS_DIR = ./obj
DESTDIR = $(OPIEDIR)/bin
TEMPLATE = app
CONFIG += qt warn_on debug
HEADERS = capture.h
SOURCES = capture.cpp
INCLUDEPATH += $(OPIEDIR)/include ../lib
DEPENDPATH += $(OPIEDIR)/include ../lib
LIBS += -lqpe -lopiecore2 -lopiecam
INTERFACES =
TARGET = capture
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/multimedia/camera/config.in b/noncore/multimedia/camera/config.in
index 861abcb..cfd71ad 100644
--- a/noncore/multimedia/camera/config.in
+++ b/noncore/multimedia/camera/config.in
@@ -1,7 +1,7 @@
config CAMERA
boolean "opie-camera (camera app to use with the Sharp CE-AG06)"
default "n"
- depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE && LIBOPIE2CORE
- comment "opie-camera needs a libqpe, libopie and libopie2core"
- depends !(( LIBQPE || LIBQPE-X11 ) && LIBOPIE && LIBOPIE2CORE)
+ depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE
+ comment "opie-camera needs a libqpe, libopie2core"
+ depends !(( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE)
diff --git a/noncore/multimedia/camera/gui/gui.pro b/noncore/multimedia/camera/gui/gui.pro
index f587b57..d74f4b6 100644
--- a/noncore/multimedia/camera/gui/gui.pro
+++ b/noncore/multimedia/camera/gui/gui.pro
@@ -1,21 +1,19 @@
-MOC_DIR = ./moc
-OBJECTS_DIR = ./obj
DESTDIR = $(OPIEDIR)/bin
TEMPLATE = app
CONFIG += qt warn_on debug
HEADERS = previewwidget.h \
mainwindow.h
SOURCES = previewwidget.cpp \
mainwindow.cpp \
main.cpp
INCLUDEPATH += $(OPIEDIR)/include ../lib
DEPENDPATH += $(OPIEDIR)/include ../lib
-LIBS += -lqpe -lopie -lopiecore2 -lopiecam
+LIBS += -lopiecore2 -lopieui2 -lopiecam
INTERFACES =
TARGET = opiecam
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/multimedia/camera/gui/mainwindow.cpp b/noncore/multimedia/camera/gui/mainwindow.cpp
index 5da3757..2f42049 100644
--- a/noncore/multimedia/camera/gui/mainwindow.cpp
+++ b/noncore/multimedia/camera/gui/mainwindow.cpp
@@ -1,144 +1,148 @@
/**********************************************************************
** 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"
+/* OPIE */
+#include <opie2/ofiledialog.h>
+#include <opie2/odevice.h>
+#include <opie2/oapplication.h>
+#include <opie2/oconfig.h>
+#include <opie2/odebug.h>
+#include <qpe/global.h>
+#include <qpe/resource.h>
+#include <qpe/qcopenvelope_qws.h>
+using namespace Opie;
+
+/* QT */
#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/oapplication.h>
-#include <opie2/oconfig.h>
-#include <opie2/odebug.h>
+/* STD */
#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()
{
// write back configuration
OConfigGroupSaver cgs( oApp->config(), "General" );
cgs.config()->writeEntry( "flip", flip );
cgs.config()->writeEntry( "quality", quality );
cgs.config()->writeEntry( "zoom", zoom );
cgs.config()->writeEntry( "captureX", captureX );
cgs.config()->writeEntry( "captureY", captureY );
cgs.config()->writeEntry( "captureFormat", captureFormat );
cgs.config()->writeEntry( "outputTo", outputTo );
cgs.config()->writeEntry( "prefix", prefix );
cgs.config()->writeEntry( "appendSettings", appendSettings );
}
void CameraMainWindow::init()
{
// get values from configuration
OConfigGroupSaver cgs( oApp->config(), "General" );
flip = cgs.config()->readEntry( "flip", "A" );
quality = cgs.config()->readNumEntry( "quality", 50 );
zoom = cgs.config()->readNumEntry( "zoom", 1 );
captureX = cgs.config()->readNumEntry( "captureX", 480 );
captureY = cgs.config()->readNumEntry( "captureY", 640 );
captureFormat = cgs.config()->readEntry( "captureFormat", "JPEG" );
outputTo = cgs.config()->readEntry( "outputTo", "Documents Folder" );
prefix = cgs.config()->readEntry( "prefix", "Untitled" );
appendSettings = cgs.config()->readBoolEntry( "appendSettings", true );
// create action groups
QAction* a;
resog = new QActionGroup( 0, "reso", true );
resog->setToggleAction( true );
new QAction( " 64 x 48", 0, 0, resog, "64x48", true );
new QAction( "128 x 96", 0, 0, resog, "128x96", true );
@@ -345,289 +349,289 @@ 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();
+ ODevice::inst()->playTouchSound();
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()->playTouchSound();
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()->playTouchSound();
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
diff --git a/noncore/multimedia/camera/lib/lib.pro b/noncore/multimedia/camera/lib/lib.pro
index 3d2c59b..1e7346f 100644
--- a/noncore/multimedia/camera/lib/lib.pro
+++ b/noncore/multimedia/camera/lib/lib.pro
@@ -1,24 +1,22 @@
-MOC_DIR = ./moc
-OBJECTS_DIR = ./obj
DESTDIR = $(OPIEDIR)/lib
TEMPLATE = lib
CONFIG += qt warn_on debug
HEADERS = avi.h \
imageio.h \
zcameraio.h \
SOURCES = avi.c \
imageio.cpp \
zcameraio.cpp \
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
-LIBS += -lqpe -lopie -lopiecore2
+LIBS += -lopiecore2
INTERFACES =
VERSION = 1.0.0
TARGET = opiecam
include ( $(OPIEDIR)/include.pro )