summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-04-24 15:42:37 (UTC)
committer mickeyl <mickeyl>2003-04-24 15:42:37 (UTC)
commitc57a19971e2f43b3a5cdfe525d755ac6603c3676 (patch) (unidiff)
tree346e52e769471a7a61c52aaa2ddbb899c883f196
parent9671975e21266e3bfa6f3c793a3278b67cea34b7 (diff)
downloadopie-c57a19971e2f43b3a5cdfe525d755ac6603c3676.zip
opie-c57a19971e2f43b3a5cdfe525d755ac6603c3676.tar.gz
opie-c57a19971e2f43b3a5cdfe525d755ac6603c3676.tar.bz2
slight bugfixes, even more debugging output (only in debugging mode), version = 1.0
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/camera/imageio.cpp4
-rw-r--r--noncore/multimedia/camera/mainwindow.cpp46
-rw-r--r--noncore/multimedia/camera/opie-camera.control2
3 files changed, 40 insertions, 12 deletions
diff --git a/noncore/multimedia/camera/imageio.cpp b/noncore/multimedia/camera/imageio.cpp
index f8f5dd0..ed0d39f 100644
--- a/noncore/multimedia/camera/imageio.cpp
+++ b/noncore/multimedia/camera/imageio.cpp
@@ -37,19 +37,19 @@ void bufferToImage( int _width, int _height, unsigned char* bp, QImage* image )
37 bp++; 37 bp++;
38 } 38 }
39 } 39 }
40} 40}
41 41
42 42
43void imageToFile( QImage* i, const QString& name, const QString& format, int quality ) 43void imageToFile( QImage* i, const QString& name, const QString& format, int quality )
44{ 44{
45 QImage im = i->convertDepth( 32 ); 45 QImage im = i->convertDepth( 32 );
46 bool result = im.save( name, format, quality ); 46 bool result = im.save( name, format, quality );
47 if ( !result ) 47 if ( !result )
48 { 48 {
49 oerr << "imageio-Problem while writing." << oendl; 49 oerr << "imageio-Problem while writing to " << name << oendl;
50 } 50 }
51 else 51 else
52 { 52 {
53 odebug << format << "-image has been successfully captured" << oendl; 53 odebug << format << "-image has been successfully captured" << oendl;
54 } 54 }
55} \ No newline at end of file 55}
diff --git a/noncore/multimedia/camera/mainwindow.cpp b/noncore/multimedia/camera/mainwindow.cpp
index 16ee8bc..49c7cbf 100644
--- a/noncore/multimedia/camera/mainwindow.cpp
+++ b/noncore/multimedia/camera/mainwindow.cpp
@@ -149,27 +149,27 @@ void CameraMainWindow::init()
149 new QAction( "x 2", 0, 0, zoomg, 0, true ); 149 new QAction( "x 2", 0, 0, zoomg, 0, true );
150 150
151 flipg = new QActionGroup( 0, "flip", true ); 151 flipg = new QActionGroup( 0, "flip", true );
152 flipg->setToggleAction( true ); 152 flipg->setToggleAction( true );
153 ( new QAction( "Auto (recommended)", 0, 0, flipg, 0, true ) )->setOn( true ); 153 ( new QAction( "Auto (recommended)", 0, 0, flipg, 0, true ) )->setOn( true );
154 new QAction( "0 (always off)", 0, 0, flipg, 0, true ); 154 new QAction( "0 (always off)", 0, 0, flipg, 0, true );
155 new QAction( "X (always horizontal)", 0, 0, flipg, 0, true ); 155 new QAction( "X (always horizontal)", 0, 0, flipg, 0, true );
156 new QAction( "Y (always vertical)", 0, 0, flipg, 0, true ); 156 new QAction( "Y (always vertical)", 0, 0, flipg, 0, true );
157 new QAction( "* (always both)", 0, 0, flipg, 0, true ); 157 new QAction( "* (always both)", 0, 0, flipg, 0, true );
158 158
159 outputTog = new QActionGroup( 0, "output", true ); 159 outputTog = new QActionGroup( 0, "output", true );
160 outputTog->setToggleAction( true ); 160 outputTog->setToggleAction( true );
161 new QAction( "/tmp", 0, 0, outputTog, 0, true ); 161 new QAction( "/tmp/", 0, 0, outputTog, 0, true );
162 new QAction( "/mnt/card/", 0, 0, outputTog, 0, true ); 162 new QAction( "/mnt/card/", 0, 0, outputTog, 0, true );
163 new QAction( "/mnt/sd/", 0, 0, outputTog, 0, true ); 163 new QAction( "/mnt/cf/", 0, 0, outputTog, 0, true );
164 docfolder = new QAction( "Documents Folder", 0, 0, outputTog, 0, true ); 164 docfolder = new QAction( "Documents Folder", 0, 0, outputTog, 0, true );
165 docfolder->setOn( true ); 165 docfolder->setOn( true );
166 custom = new QAction( "&Custom...", 0, 0, outputTog, 0, true ); 166 custom = new QAction( "&Custom...", 0, 0, outputTog, 0, true );
167 167
168 outputg = new QActionGroup( 0, "output", true ); 168 outputg = new QActionGroup( 0, "output", true );
169 outputg->setToggleAction( true ); 169 outputg->setToggleAction( true );
170 ( new QAction( "JPEG", 0, 0, outputg, 0, true ) )->setOn( true ); 170 ( new QAction( "JPEG", 0, 0, outputg, 0, true ) )->setOn( true );
171 new QAction( "PNG", 0, 0, outputg, 0, true ); 171 new QAction( "PNG", 0, 0, outputg, 0, true );
172 new QAction( "BMP", 0, 0, outputg, 0, true ); 172 new QAction( "BMP", 0, 0, outputg, 0, true );
173 new QAction( "AVI", 0, 0, outputg, 0, true ); 173 new QAction( "AVI", 0, 0, outputg, 0, true );
174 174
175 connect( resog, SIGNAL( selected(QAction*) ), this, SLOT( resoMenuItemClicked(QAction*) ) ); 175 connect( resog, SIGNAL( selected(QAction*) ), this, SLOT( resoMenuItemClicked(QAction*) ) );
@@ -413,25 +413,33 @@ void CameraMainWindow::shutterClicked()
413 else // capture video! start with one shutter click and stop with the next 413 else // capture video! start with one shutter click and stop with the next
414 { 414 {
415 !_capturing ? startVideoCapture() : stopVideoCapture(); 415 !_capturing ? startVideoCapture() : stopVideoCapture();
416 } 416 }
417} 417}
418 418
419 419
420void CameraMainWindow::performCapture( const QString& format ) 420void CameraMainWindow::performCapture( const QString& format )
421{ 421{
422 QString name; 422 QString name;
423 423
424 if ( outputTo == "Documents Folder" ) 424 if ( outputTo == "Documents Folder" )
425 name.sprintf( "%s/Documents/image/%s/", (const char*) QDir::homeDirPath(), (const char*) captureFormat.lower() ); 425 {
426 name.sprintf( "%s/Documents/image/%s/", (const char*) QDir::homeDirPath(), (const char*) captureFormat.lower() );
427 if ( !QDir( name ).exists() )
428 {
429 odebug << "creating directory " << name << oendl;
430 QString msg = "mkdir -p " + name;
431 system( msg.latin1() );
432 }
433 }
426 else 434 else
427 name = outputTo; 435 name = outputTo;
428 436
429 name.append( prefix ); 437 name.append( prefix );
430 if ( appendSettings ) 438 if ( appendSettings )
431 { 439 {
432 name.append( QString().sprintf( "_%d_%d_q%d", captureX, captureY, quality ) ); 440 name.append( QString().sprintf( "_%d_%d_q%d", captureX, captureY, quality ) );
433 } 441 }
434 name.append( QString().sprintf( "-%d.%s", _pics++, (const char*) captureFormat.lower() ) ); 442 name.append( QString().sprintf( "-%d.%s", _pics++, (const char*) captureFormat.lower() ) );
435 443
436 QImage i; 444 QImage i;
437 ZCameraIO::instance()->captureFrame( captureX, captureY, zoom, &i ); 445 ZCameraIO::instance()->captureFrame( captureX, captureY, zoom, &i );
@@ -492,42 +500,58 @@ void CameraMainWindow::timerEvent( QTimerEvent* )
492 500
493 501
494void CameraMainWindow::stopVideoCapture() 502void CameraMainWindow::stopVideoCapture()
495{ 503{
496 killTimers(); 504 killTimers();
497 //ODevice::inst()->touchSound(); 505 //ODevice::inst()->touchSound();
498 ODevice::inst()->setLedState( Led_Mail, Led_Off ); 506 ODevice::inst()->setLedState( Led_Mail, Led_Off );
499 _capturing = false; 507 _capturing = false;
500 updateCaption(); 508 updateCaption();
501 ::close( _capturefd ); 509 ::close( _capturefd );
502 _framerate = 1000.0 / (_time.elapsed()/_videopics); 510 _framerate = 1000.0 / (_time.elapsed()/_videopics);
503 511
504 QString name( outputTo ); 512 QString name;
505 name.append( "/prefix" ); 513 if ( outputTo == "Documents Folder" )
514 {
515 name.sprintf( "%s/Documents/video/%s/", (const char*) QDir::homeDirPath(), (const char*) captureFormat.lower() );
516 if ( !QDir( name ).exists() )
517 {
518 odebug << "creating directory " << name << oendl;
519 QString msg = "mkdir -p " + name;
520 system( msg.latin1() );
521 }
522 }
523 else
524 name = outputTo;
525
526 name.append( "/" ); // sure is sure and safe is safe ;-)
527 name.append( prefix );
506 if ( appendSettings ) 528 if ( appendSettings )
507 name.append( QString().sprintf( "_%d_%d_q%d_%dfps", captureX, captureY, quality, _framerate ) ); 529 name.append( QString().sprintf( "_%d_%d_q%d_%dfps", captureX, captureY, quality, _framerate ) );
508 name.append( QString().sprintf( "-%d.%s", _videos++, (const char*) captureFormat.lower() ) ); 530 name.append( QString().sprintf( "-%d.%s", _videos++, (const char*) captureFormat.lower() ) );
509 postProcessVideo( CAPTUREFILE, name ); 531 postProcessVideo( CAPTUREFILE, name );
510 532
511 #ifndef QT_NO_DEBUG 533 #ifndef QT_NO_DEBUG
512 preview->setRefreshingRate( 1500 ); 534 preview->setRefreshingRate( 1500 );
513 #else 535 #else
514 preview->setRefreshingRate( 200 ); 536 preview->setRefreshingRate( 200 );
515 #endif 537 #endif
516 538
517 //delete[] _capturebuf; //FIXME: close memory leak 539 //delete[] _capturebuf; //FIXME: close memory leak
518} 540}
519 541
520void CameraMainWindow::postProcessVideo( const QString& infile, const QString& outfile ) 542void CameraMainWindow::postProcessVideo( const QString& infile, const QString& outfile )
521{ 543{
544 odebug << "post processing " << infile << " --> " << outfile << oendl;
545
522 preview->setRefreshingRate( 0 ); 546 preview->setRefreshingRate( 0 );
523 547
524 /* 548 /*
525 unsigned char buf[153600]; 549 unsigned char buf[153600];
526 550
527 int fd = ::open( "/var/compile/opie/noncore/multimedia/camera/capture-320x240.dat", O_RDONLY ); 551 int fd = ::open( "/var/compile/opie/noncore/multimedia/camera/capture-320x240.dat", O_RDONLY );
528 ::read( fd, &buf, 153600 ); 552 ::read( fd, &buf, 153600 );
529 QImage i; 553 QImage i;
530 bufferToImage( 240, 320, (unsigned char*) &buf, &i ); 554 bufferToImage( 240, 320, (unsigned char*) &buf, &i );
531 QPixmap p; 555 QPixmap p;
532 p.convertFromImage( i ); 556 p.convertFromImage( i );
533 preview->setPixmap( p ); 557 preview->setPixmap( p );
@@ -587,71 +611,75 @@ void CameraMainWindow::postProcessVideo( const QString& infile, const QString& o
587 // </gui> 611 // </gui>
588 612
589 int read = ::read( infd, inbuffer, framesize ); 613 int read = ::read( infd, inbuffer, framesize );
590 odebug << "read " << read << " bytes" << oendl; 614 odebug << "read " << read << " bytes" << oendl;
591 bufferToImage( captureX, captureY, inbuffer, &image ); 615 bufferToImage( captureX, captureY, inbuffer, &image );
592 616
593 QPixmap p; 617 QPixmap p;
594 p.convertFromImage( image ); 618 p.convertFromImage( image );
595 preview->setPixmap( p ); 619 preview->setPixmap( p );
596 preview->repaint(); 620 preview->repaint();
597 qApp->processEvents(); 621 qApp->processEvents();
598 622
599 #ifndef QT_NO_DEBUG 623 #ifdef CAMERA_EXTRA_DEBUG
600 QString tmpfilename; 624 QString tmpfilename;
601 tmpfilename.sprintf( "/tmp/test/%04d.jpg", i ); 625 tmpfilename.sprintf( "/tmp/test/%04d.jpg", i );
602 #else 626 #else
603 QString tmpfilename( "/tmp/tempfile" ); 627 QString tmpfilename( "/tmp/tempfile" );
604 #endif 628 #endif
605 629
606 imageToFile( &image, tmpfilename, "JPEG", quality ); 630 imageToFile( &image, tmpfilename, "JPEG", quality );
607 631
608 QFile framefile( tmpfilename ); 632 QFile framefile( tmpfilename );
609 if ( !framefile.open( IO_ReadOnly ) ) 633 if ( !framefile.open( IO_ReadOnly ) )
610 { 634 {
611 oerr << "can't process file: %s" << strerror(errno) << oendl; 635 oerr << "can't process file: %s" << strerror(errno) << oendl;
612 return; // TODO: clean up temp ressources 636 return; // TODO: clean up temp ressources
613 } 637 }
614 638
615 int filesize = framefile.size(); 639 int filesize = framefile.size();
616 odebug << "filesize for frame " << i << " = " << filesize << oendl; 640 odebug << "filesize for frame " << i << " = " << filesize << oendl;
617 641
618 unsigned char* tempbuffer = new unsigned char[ filesize ]; 642 unsigned char* tempbuffer = new unsigned char[ filesize ];
619 framefile.readBlock( (char*) tempbuffer, filesize ); 643 framefile.readBlock( (char*) tempbuffer, filesize );
620 avi_add( outfd, tempbuffer, filesize ); 644 avi_add( outfd, tempbuffer, filesize );
621 delete tempbuffer; 645 delete tempbuffer;
622 framefile.close(); 646 framefile.close();
623 647
624 odebug << "deleting temporary capturefile " << infile << oendl;
625 ::close( infd );
626 QFile::remove( infile );
627 } 648 }
628 649
629 avi_end( outfd, captureX, captureY, _framerate ); 650 avi_end( outfd, captureX, captureY, _framerate );
630 ::close( outfd ); 651 ::close( outfd );
652 ::close( infd );
653
654 label->setText( "deleting temp files..." );
655 qApp->processEvents();
656 odebug << "deleting temporary capturefile " << infile << oendl;
657 QFile::remove( infile );
631 658
632 fr->hide(); 659 fr->hide();
633 delete fr; 660 delete fr;
634 661
635 updateCaption(); 662 updateCaption();
636 663
637} 664}
638 665
639 666
640void CameraMainWindow::updateCaption() 667void CameraMainWindow::updateCaption()
641{ 668{
642 if ( !_capturing ) 669 if ( !_capturing )
643 setCaption( QString().sprintf( "Opie-Camera: %dx%d %s q%d z%d (%s)", captureX, captureY, (const char*) captureFormat.lower(), quality, zoom, (const char*) flip ) ); 670 setCaption( QString().sprintf( "Opie-Camera: %dx%d %s q%d z%d (%s)", captureX, captureY, (const char*) captureFormat.lower(), quality, zoom, (const char*) flip ) );
644 else 671 else
645 setCaption( "Opie-Camera: => CAPTURING <=" ); 672 setCaption( "Opie-Camera: => CAPTURING <=" );
673 qApp->processEvents();
646} 674}
647 675
648 676
649#ifndef QT_NO_DEBUG 677#ifndef QT_NO_DEBUG
650void CameraMainWindow::doSomething() 678void CameraMainWindow::doSomething()
651{ 679{
652 captureX = 240; 680 captureX = 240;
653 captureY = 320; 681 captureY = 320;
654 _videopics = 50; 682 _videopics = 50;
655 _framerate = 5; 683 _framerate = 5;
656 postProcessVideo( "/var/compile/opie/noncore/multimedia/camera/capture.dat", 684 postProcessVideo( "/var/compile/opie/noncore/multimedia/camera/capture.dat",
657 "/tmp/output.avi" ); 685 "/tmp/output.avi" );
diff --git a/noncore/multimedia/camera/opie-camera.control b/noncore/multimedia/camera/opie-camera.control
index a33de38..1731ad2 100644
--- a/noncore/multimedia/camera/opie-camera.control
+++ b/noncore/multimedia/camera/opie-camera.control
@@ -1,10 +1,10 @@
1Package: opie-camera 1Package: opie-camera
2Files: bin/opiecam pics/camera apps/Applications/camera.desktop 2Files: bin/opiecam pics/camera apps/Applications/camera.desktop
3Priority: optional 3Priority: optional
4Section: opie/applications 4Section: opie/applications
5Maintainer: Michael 'Mickey' Lauer <mickeyl@handhelds.org> 5Maintainer: Michael 'Mickey' Lauer <mickeyl@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION 7Version: 1.0
8Depends: task-opie-minimal, libopie2 (1.8.1) 8Depends: task-opie-minimal, libopie2 (1.8.1)
9Description: A Camera Application 9Description: A Camera Application
10 A Camera Application to use with the Sharp CE-AG06. 10 A Camera Application to use with the Sharp CE-AG06.