-rw-r--r-- | noncore/multimedia/camera/gui/mainwindow.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/multimedia/camera/gui/mainwindow.cpp b/noncore/multimedia/camera/gui/mainwindow.cpp index 49c7cbf..0854f0d 100644 --- a/noncore/multimedia/camera/gui/mainwindow.cpp +++ b/noncore/multimedia/camera/gui/mainwindow.cpp | |||
@@ -415,139 +415,139 @@ void CameraMainWindow::shutterClicked() | |||
415 | !_capturing ? startVideoCapture() : stopVideoCapture(); | 415 | !_capturing ? startVideoCapture() : stopVideoCapture(); |
416 | } | 416 | } |
417 | } | 417 | } |
418 | 418 | ||
419 | 419 | ||
420 | void CameraMainWindow::performCapture( const QString& format ) | 420 | void 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 | { | 425 | { |
426 | name.sprintf( "%s/Documents/image/%s/", (const char*) QDir::homeDirPath(), (const char*) captureFormat.lower() ); | 426 | name.sprintf( "%s/Documents/image/%s/", (const char*) QDir::homeDirPath(), (const char*) captureFormat.lower() ); |
427 | if ( !QDir( name ).exists() ) | 427 | if ( !QDir( name ).exists() ) |
428 | { | 428 | { |
429 | odebug << "creating directory " << name << oendl; | 429 | odebug << "creating directory " << name << oendl; |
430 | QString msg = "mkdir -p " + name; | 430 | QString msg = "mkdir -p " + name; |
431 | system( msg.latin1() ); | 431 | system( msg.latin1() ); |
432 | } | 432 | } |
433 | } | 433 | } |
434 | else | 434 | else |
435 | name = outputTo; | 435 | name = outputTo; |
436 | 436 | ||
437 | name.append( prefix ); | 437 | name.append( prefix ); |
438 | if ( appendSettings ) | 438 | if ( appendSettings ) |
439 | { | 439 | { |
440 | name.append( QString().sprintf( "_%d_%d_q%d", captureX, captureY, quality ) ); | 440 | name.append( QString().sprintf( "_%d_%d_q%d", captureX, captureY, quality ) ); |
441 | } | 441 | } |
442 | name.append( QString().sprintf( "-%d.%s", _pics++, (const char*) captureFormat.lower() ) ); | 442 | name.append( QString().sprintf( "-%d.%s", _pics++, (const char*) captureFormat.lower() ) ); |
443 | 443 | ||
444 | QImage i; | 444 | QImage i; |
445 | ZCameraIO::instance()->captureFrame( captureX, captureY, zoom, &i ); | 445 | ZCameraIO::instance()->captureFrame( captureX, captureY, zoom, &i ); |
446 | QImage im = i.convertDepth( 32 ); | 446 | QImage im = i.convertDepth( 32 ); |
447 | bool result = im.save( name, format, quality ); | 447 | bool result = im.save( name, format, quality ); |
448 | if ( !result ) | 448 | if ( !result ) |
449 | { | 449 | { |
450 | oerr << "imageio-Problem while writing." << oendl; | 450 | oerr << "imageio-Problem while writing." << oendl; |
451 | Global::statusMessage( "Error!" ); | 451 | Global::statusMessage( "Error!" ); |
452 | } | 452 | } |
453 | else | 453 | else |
454 | { | 454 | { |
455 | odebug << captureFormat << "-image has been successfully captured" << oendl; | 455 | odebug << captureFormat << "-image has been successfully captured" << oendl; |
456 | Global::statusMessage( "Ok." ); | 456 | Global::statusMessage( "Ok." ); |
457 | } | 457 | } |
458 | } | 458 | } |
459 | 459 | ||
460 | 460 | ||
461 | void CameraMainWindow::startVideoCapture() | 461 | void CameraMainWindow::startVideoCapture() |
462 | { | 462 | { |
463 | //ODevice::inst()->touchSound(); | 463 | ODevice::inst()->touchSound(); |
464 | ODevice::inst()->setLedState( Led_Mail, Led_BlinkSlow ); | 464 | ODevice::inst()->setLedState( Led_Mail, Led_BlinkSlow ); |
465 | 465 | ||
466 | _capturefd = ::open( CAPTUREFILE, O_WRONLY | O_CREAT | O_TRUNC ); | 466 | _capturefd = ::open( CAPTUREFILE, O_WRONLY | O_CREAT | O_TRUNC ); |
467 | if ( _capturefd == -1 ) | 467 | if ( _capturefd == -1 ) |
468 | { | 468 | { |
469 | owarn << "can't open capture file: " << strerror(errno) << oendl; | 469 | owarn << "can't open capture file: " << strerror(errno) << oendl; |
470 | return; | 470 | return; |
471 | } | 471 | } |
472 | 472 | ||
473 | _capturebuf = new unsigned char[captureX*captureY*2]; | 473 | _capturebuf = new unsigned char[captureX*captureY*2]; |
474 | _capturing = true; | 474 | _capturing = true; |
475 | _videopics = 0; | 475 | _videopics = 0; |
476 | _framerate = 0; | 476 | _framerate = 0; |
477 | updateCaption(); | 477 | updateCaption(); |
478 | _time.start(); | 478 | _time.start(); |
479 | preview->setRefreshingRate( 1000 ); | 479 | preview->setRefreshingRate( 1000 ); |
480 | startTimer( 100 ); // too fast but that is ok | 480 | startTimer( 100 ); // too fast but that is ok |
481 | } | 481 | } |
482 | 482 | ||
483 | 483 | ||
484 | void CameraMainWindow::timerEvent( QTimerEvent* ) | 484 | void CameraMainWindow::timerEvent( QTimerEvent* ) |
485 | { | 485 | { |
486 | if ( !_capturing ) | 486 | if ( !_capturing ) |
487 | { | 487 | { |
488 | odebug << "timer event in CameraMainWindow without capturing video ?" << oendl; | 488 | odebug << "timer event in CameraMainWindow without capturing video ?" << oendl; |
489 | return; | 489 | return; |
490 | } | 490 | } |
491 | 491 | ||
492 | odebug << "timer event during video - now capturing frame #" << _videopics+1 << oendl; | 492 | odebug << "timer event during video - now capturing frame #" << _videopics+1 << oendl; |
493 | 493 | ||
494 | ZCameraIO::instance()->captureFrame( captureX, captureY, zoom, _capturebuf ); | 494 | ZCameraIO::instance()->captureFrame( captureX, captureY, zoom, _capturebuf ); |
495 | _videopics++; | 495 | _videopics++; |
496 | ::write( _capturefd, _capturebuf, captureX*captureY*2 ); | 496 | ::write( _capturefd, _capturebuf, captureX*captureY*2 ); |
497 | setCaption( QString().sprintf( "Capturing %dx%d @ %.2f fps %d", | 497 | setCaption( QString().sprintf( "Capturing %dx%d @ %.2f fps %d", |
498 | captureX, captureY, 1000.0 / (_time.elapsed()/_videopics), _videopics ) ); | 498 | captureX, captureY, 1000.0 / (_time.elapsed()/_videopics), _videopics ) ); |
499 | } | 499 | } |
500 | 500 | ||
501 | 501 | ||
502 | void CameraMainWindow::stopVideoCapture() | 502 | void CameraMainWindow::stopVideoCapture() |
503 | { | 503 | { |
504 | killTimers(); | 504 | killTimers(); |
505 | //ODevice::inst()->touchSound(); | 505 | ODevice::inst()->touchSound(); |
506 | ODevice::inst()->setLedState( Led_Mail, Led_Off ); | 506 | ODevice::inst()->setLedState( Led_Mail, Led_Off ); |
507 | _capturing = false; | 507 | _capturing = false; |
508 | updateCaption(); | 508 | updateCaption(); |
509 | ::close( _capturefd ); | 509 | ::close( _capturefd ); |
510 | _framerate = 1000.0 / (_time.elapsed()/_videopics); | 510 | _framerate = 1000.0 / (_time.elapsed()/_videopics); |
511 | 511 | ||
512 | QString name; | 512 | QString name; |
513 | if ( outputTo == "Documents Folder" ) | 513 | if ( outputTo == "Documents Folder" ) |
514 | { | 514 | { |
515 | name.sprintf( "%s/Documents/video/%s/", (const char*) QDir::homeDirPath(), (const char*) captureFormat.lower() ); | 515 | name.sprintf( "%s/Documents/video/%s/", (const char*) QDir::homeDirPath(), (const char*) captureFormat.lower() ); |
516 | if ( !QDir( name ).exists() ) | 516 | if ( !QDir( name ).exists() ) |
517 | { | 517 | { |
518 | odebug << "creating directory " << name << oendl; | 518 | odebug << "creating directory " << name << oendl; |
519 | QString msg = "mkdir -p " + name; | 519 | QString msg = "mkdir -p " + name; |
520 | system( msg.latin1() ); | 520 | system( msg.latin1() ); |
521 | } | 521 | } |
522 | } | 522 | } |
523 | else | 523 | else |
524 | name = outputTo; | 524 | name = outputTo; |
525 | 525 | ||
526 | name.append( "/" ); // sure is sure and safe is safe ;-) | 526 | name.append( "/" ); // sure is sure and safe is safe ;-) |
527 | name.append( prefix ); | 527 | name.append( prefix ); |
528 | if ( appendSettings ) | 528 | if ( appendSettings ) |
529 | 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 ) ); |
530 | name.append( QString().sprintf( "-%d.%s", _videos++, (const char*) captureFormat.lower() ) ); | 530 | name.append( QString().sprintf( "-%d.%s", _videos++, (const char*) captureFormat.lower() ) ); |
531 | postProcessVideo( CAPTUREFILE, name ); | 531 | postProcessVideo( CAPTUREFILE, name ); |
532 | 532 | ||
533 | #ifndef QT_NO_DEBUG | 533 | #ifndef QT_NO_DEBUG |
534 | preview->setRefreshingRate( 1500 ); | 534 | preview->setRefreshingRate( 1500 ); |
535 | #else | 535 | #else |
536 | preview->setRefreshingRate( 200 ); | 536 | preview->setRefreshingRate( 200 ); |
537 | #endif | 537 | #endif |
538 | 538 | ||
539 | //delete[] _capturebuf; //FIXME: close memory leak | 539 | //delete[] _capturebuf; //FIXME: close memory leak |
540 | } | 540 | } |
541 | 541 | ||
542 | void CameraMainWindow::postProcessVideo( const QString& infile, const QString& outfile ) | 542 | void CameraMainWindow::postProcessVideo( const QString& infile, const QString& outfile ) |
543 | { | 543 | { |
544 | odebug << "post processing " << infile << " --> " << outfile << oendl; | 544 | odebug << "post processing " << infile << " --> " << outfile << oendl; |
545 | 545 | ||
546 | preview->setRefreshingRate( 0 ); | 546 | preview->setRefreshingRate( 0 ); |
547 | 547 | ||
548 | /* | 548 | /* |
549 | unsigned char buf[153600]; | 549 | unsigned char buf[153600]; |
550 | 550 | ||
551 | 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 ); |
552 | ::read( fd, &buf, 153600 ); | 552 | ::read( fd, &buf, 153600 ); |
553 | QImage i; | 553 | QImage i; |