예제 #1
0
  void WriteFrame::onInput(InputImageInfo info, Magick::Image img) {
    QString framePath = outputDir.path() + QDir::separator()
      + leadingZeros(info.frame, FRAME_FILE_LEADING_ZEROS) + QString(".jpeg");

    *verboseOutput << "Write frame " << framePath << endl;
    if (!dryRun) {
      img.compressType(Magick::JPEGCompression);
      img.magick( "JPEG" );
      img.write(framePath.toStdString());
    }
    // update image location & emit signal
    info.file = QFileInfo(framePath);
    emit input(info, img);
  }
예제 #2
0
  void TimeLapseCapture::imageCaptured(QString format, Magick::Blob blob, Magick::Geometry sizeHint) {
    bool readRawFromFile = false;

    QString framePath = output.path() + QDir::separator()
      + leadingZeros(capturedCnt, FRAME_FILE_LEADING_ZEROS) + "_" + leadingZeros(capturedSubsequence, 2);

    if (format == "RGB") {
      if (storeRawImages) {
        // store RAW RGB data in PPM format
        QString pgmHeader = QString("P6\n%1 %2\n255\n").arg(sizeHint.width()).arg(sizeHint.height());
        std::string headerStr = pgmHeader.toStdString();
        const char *headerBytes = headerStr.c_str();
        size_t headerLen = strlen(headerBytes);

        if (shutterSpdAlg != NULL && capturedSubsequence == 0) {
          Magick::Image capturedImage;
          capturedImage.read(blob, sizeHint, 8, "RGB");
          shutterSpdAlg->update(capturedImage);
        }

        framePath += ".ppm";
        QFile file(framePath);
        file.open(QIODevice::WriteOnly);
        file.write(headerBytes, headerLen);
        file.write((char*) blob.data(), blob.length());
        file.close();
      } else {
        // convert RGB data to JPEG
        Magick::Image capturedImage;
        capturedImage.read(blob, sizeHint, 8, "RGB");

        if (shutterSpdAlg != NULL && capturedSubsequence == 0) {
          shutterSpdAlg->update(capturedImage);
        }

        QDateTime now = QDateTime::currentDateTime();
        QString exifDateTime = now.toString("yyyy:MM:dd HH:mm:ss");\

        // ImageMagick don't support writing of exif data
        // TODO: setup exif timestamp correctly
        capturedImage.attribute("EXIF:DateTime", exifDateTime.toStdString());
        //capturedImage.defineValue("EXIF", "DateTime", exifDateTime.toStdString());

        capturedImage.compressType(Magick::JPEGCompression);
        capturedImage.magick("JPEG");
        framePath += ".jpeg";
        capturedImage.write(framePath.toStdString());

      }
    } else {

      if (shutterSpdAlg != NULL && capturedSubsequence == 0) {
        try {
          Magick::Image capturedImage;
          capturedImage.read(blob, format.toStdString());
          shutterSpdAlg->update(capturedImage);
        } catch (const std::exception &e) {
          err << "Failed to decode captured image (" << format << "): " << QString::fromUtf8(e.what()) << endl;
          readRawFromFile = true;
        }
      }

      // store other formats in device specific format 
      framePath += "." + format;
      QFile file(framePath);
      file.open(QIODevice::WriteOnly);
      file.write((char*) blob.data(), blob.length());
      file.close();

      if (readRawFromFile && shutterSpdAlg != NULL && capturedSubsequence == 0) {
        /* I don't understand ImageMagick correctly, but it fails with reading RAW files
         * from memory blob, but reading from file works (sometimes). 
         * Maybe, it don't support delegating (dcraw, ufraw...) with memory data...
         */
        try {
          Magick::Image capturedImage;
          capturedImage.read(framePath.toStdString());
          shutterSpdAlg->update(capturedImage);
        } catch (const std::exception &e) {
          err << "Failed to decode captured image (" << framePath << "): " << QString::fromUtf8(e.what()) << endl;
        }
      }
    }

    verboseOutput << "Captured frame saved to " << framePath << endl;

    capturedSubsequence++;
  }
예제 #3
0
파일: STL.cpp 프로젝트: 0xPr0xy/ImageMagick
void Magick::compressTypeImage::operator()( Magick::Image &image_ ) const
{
  image_.compressType( _compressType );
}