OMX_ERRORTYPE ofxRPiCameraVideoGrabber::setShutterSpeed(int shutterSpeedMicroSeconds_) { OMX_ERRORTYPE error = OMX_GetConfig(camera, OMX_IndexConfigCommonExposureValue, &exposureConfig); OMX_TRACE(error); exposureConfig.nShutterSpeedMsec = shutterSpeedMicroSeconds_; error = applyExposure(__func__); OMX_TRACE(error); if(error == OMX_ErrorNone) { shutterSpeed = getShutterSpeed(); } ofLogVerbose(__func__) << "POST getShutterSpeed(): " << getShutterSpeed(); return error; }
string ofxRPiCameraVideoGrabber::currentStateToString() { stringstream info; info << "sharpness " << getSharpness() << endl; info << "contrast " << getContrast() << endl; info << "brightness " << getBrightness() << endl; info << "saturation " << getSaturation() << endl; info << "ISO " << getISO() << endl; info << "AutoISO " << getAutoISO() << endl; info << "DRE " << getDRE() << endl; info << "cropRectangle " << getCropRectangle() << endl; info << "zoomLevelNormalized " << getZoomLevelNormalized() << endl; info << "mirror " << getMirror() << endl; info << "rotation " << getRotation() << endl; info << "imageFilter " << getImageFilter() << endl; info << "exposurePreset " << getExposurePreset() << endl; info << "evCompensation " << getEvCompensation() << endl; info << "autoShutter " << getAutoShutter() << endl; info << "shutterSpeed " << getShutterSpeed() << endl; info << "meteringType " << getMeteringType() << endl; info << "SoftwareSaturationEnabled " << isSoftwareSaturationEnabled() << endl; info << "SoftwareSharpeningEnabled " << isSoftwareSharpeningEnabled() << endl; //OMXCameraSettings info << omxCameraSettings.toString() << endl; return info.str(); }
string ofxRPiCameraVideoGrabber::printExposure() { stringstream ss; ss << "meteringType: " << OMX_Maps::getInstance().getMetering(exposureConfig.eMetering) << "\n"; ss << "evCompensation: " << getEvCompensation() << "\n"; ss << "autoShutter: " << getAutoShutter() << "\n"; ss << "shutterSpeedMicroSeconds: " << getShutterSpeed() << "\n"; ss << "autoISO: " << getAutoISO() << "\n"; ss << "ISO: " << getISO() << "\n"; return ss.str(); }
QSharedPointer<CaptureDevice> TimeLapseCapture::parseArguments() { QCommandLineParser parser; ErrorMessageHelper die(err.device(), &parser); parser.setApplicationDescription("Tool for capture sequence of images from digital camera (V4L or GPhoto2 API)."); parser.addHelpOption(); parser.addVersionOption(); QCommandLineOption outputOption(QStringList() << "o" << "output", QCoreApplication::translate("main", "Output directory."), QCoreApplication::translate("main", "directory")); parser.addOption(outputOption); QCommandLineOption verboseOption(QStringList() << "V" << "verbose", QCoreApplication::translate("main", "Verbose output.")); parser.addOption(verboseOption); QCommandLineOption deviceOption(QStringList() << "d" << "device", QCoreApplication::translate("main", "Capture device."), QCoreApplication::translate("main", "device")); parser.addOption(deviceOption); QCommandLineOption listOption(QStringList() << "l" << "list", QCoreApplication::translate("main", "List available capture devices and exits.")); parser.addOption(listOption); QCommandLineOption intervalOption(QStringList() << "i" << "interval", QCoreApplication::translate("main", "Capture interval (in milliseconds). Default is 10000."), QCoreApplication::translate("main", "interval")); parser.addOption(intervalOption); QCommandLineOption cntOption(QStringList() << "c" << "count", QCoreApplication::translate("main", "How many images should be captured. Default value is infinite."), QCoreApplication::translate("main", "count")); parser.addOption(cntOption); QCommandLineOption rowOption(QStringList() << "r" << "raw", QCoreApplication::translate("main", "Store all captured images in raw.")); parser.addOption(rowOption); QCommandLineOption getShutterSpeedOption(QStringList() << "s" << "shutterspeed-options", QCoreApplication::translate("main", "Prints available shutterspeed setting choices and exits.")); parser.addOption(getShutterSpeedOption); QCommandLineOption adaptiveShutterSpeedOption(QStringList() << "a" << "adaptive-shutterspeed", QCoreApplication::translate("main", "Camera shutterspeed will be adaptively changed after exposure metering.\n" "This option setup how many images should be used for exposure metering. \n" "Default value is 0 - it means that shutterspeed will not be changed by capture tool." ), QCoreApplication::translate("main", "count")); parser.addOption(adaptiveShutterSpeedOption); QCommandLineOption shutterSpeedStepOption(QStringList() << "shutterspeed-step", QCoreApplication::translate("main", "How large should be step when changing shutterspeed. \n" "Default value is 1." ), QCoreApplication::translate("main", "step")); parser.addOption(shutterSpeedStepOption); QCommandLineOption minShutterSpeedOption(QStringList() << "min-shutterspeed", QCoreApplication::translate("main", "Minimum shutterspeed (fastest shutter) used by adaptive shutterspeed"), QCoreApplication::translate("main", "shutterspeed")); parser.addOption(minShutterSpeedOption); QCommandLineOption maxShutterSpeedOption(QStringList() << "max-shutterspeed", QCoreApplication::translate("main", "Maximum shutterspeed (slowest shutter) used by adaptive shutterspeed.\n" "If camera supports BULB shutterspeed, it can be defined as \"BULB:XX\" here (it means bulb with XX s exposure)." ), QCoreApplication::translate("main", "shutterspeed")); parser.addOption(maxShutterSpeedOption); // Process the actual command line arguments given by the user parser.process(*this); // verbose? if (!parser.isSet(verboseOption)) { blackHole = new BlackHoleDevice(); verboseOutput.setDevice(blackHole); } else { // verbose verboseOutput << "Turning on verbose output..." << endl; verboseOutput << applicationName() << " " << applicationVersion() << endl; } // raw? storeRawImages = parser.isSet(rowOption); // interval if (parser.isSet(intervalOption)) { bool ok = false; long i = parser.value(intervalOption).toLong(&ok); if (!ok) die << "Cant parse interval."; if (i <= 0) die << "Interval have to be possitive"; interval = i; } // count if (parser.isSet(cntOption)) { bool ok = false; int i = parser.value(cntOption).toInt(&ok); if (!ok) die << "Cant parse count."; cnt = i; } // list devices? QList<QSharedPointer < CaptureDevice>> devices = listDevices(); QSharedPointer<CaptureDevice> dev; if (parser.isSet(listOption)) { if (devices.isEmpty()) { die << QCoreApplication::translate("main", "No compatible capture device found"); } else { out << "Found devices: " << endl; for (QSharedPointer<CaptureDevice> d : devices) { out << " " << d->toString() << endl; } } std::exit(0); } // capture device bool assigned = false; if (!parser.isSet(deviceOption)) { verboseOutput << "Found devices: " << endl; for (QSharedPointer<CaptureDevice> d : devices) { if (!assigned) { dev = d; assigned = true; } verboseOutput << " " << d->toString() << endl; } if (!assigned) die << "No supported device."; } else { QString devVal = parser.value(deviceOption); for (QSharedPointer<CaptureDevice> d : devices) { if (d->toString().contains(devVal, Qt::CaseInsensitive)) { assigned = true; dev = d; break; } } if (!assigned) { die << QString("No device matching \"%1\" found.").arg(devVal); } } out << "Using device " << dev->toString() << endl; // getShutterSpeedOption ? QList<ShutterSpeedChoice> choices = dev->getShutterSpeedChoices(); if (parser.isSet(getShutterSpeedOption)) { if (choices.isEmpty()) { err << "Device " << dev->toShortString() << " don't support shutterspeed setting" << endl; } else { out << "Device " << dev->toShortString() << " shutterspeed choices:" << endl; for (ShutterSpeedChoice ch : choices) { out << " " << ch.toString() << endl; } out << "Current shutter speed: " << dev->currentShutterSpeed().toString() << endl; } std::exit(0); } // automatic chutter speed // this functionality is experimental! if (parser.isSet(adaptiveShutterSpeedOption)) { bool ok = false; int changeThreshold = parser.value(adaptiveShutterSpeedOption).toInt(&ok); if (!ok) die << "Cant parse adaptive shutterspeed option."; if (changeThreshold > 0) { if (choices.isEmpty()) { die << "Camera don't support shutterspeed setting."; } else { ShutterSpeedChoice currentShutterSpeed; ShutterSpeedChoice minShutterSpeed; ShutterSpeedChoice maxShutterSpeed; currentShutterSpeed = dev->currentShutterSpeed(); minShutterSpeed = choices.first(); for (ShutterSpeedChoice ch : choices) { if ((!ch.isBulb()) && ch.toMicrosecond() > maxShutterSpeed.toMicrosecond()) maxShutterSpeed = ch; } int shutterSpeedStep = 1; if (parser.isSet(shutterSpeedStepOption)) { bool ok = false; shutterSpeedStep = parser.value(shutterSpeedStepOption).toInt(&ok); if (!ok) die << "Cant parse shutterspeed step."; if (shutterSpeedStep < 1) die << "Shutterspeed step can be less than one."; } if (parser.isSet(minShutterSpeedOption)) { QString optStr = parser.value(minShutterSpeedOption); minShutterSpeed = getShutterSpeed(optStr, choices, &die); } if (parser.isSet(maxShutterSpeedOption)) { QString optStr = parser.value(maxShutterSpeedOption); maxShutterSpeed = getShutterSpeed(optStr, choices, &die); } out << "Using automatic shutter speed:" << endl; out << " current shutter speed: " << currentShutterSpeed.toString() << endl; out << " min shutter speed: " << minShutterSpeed.toString() << endl; out << " max shutter speed: " << maxShutterSpeed.toString() << endl; out << " change threshold: " << changeThreshold << endl; out << " change step: " << shutterSpeedStep << endl; if (minShutterSpeed.toMicrosecond() <= 0 || maxShutterSpeed.toMicrosecond() <= 0 || maxShutterSpeed.toMicrosecond() < minShutterSpeed.toMicrosecond()) die << "Invalid shutter speed configurarion"; if (maxShutterSpeed.toMs() > interval) { err << QString("Warning: Maximum shutter speed (%1 ms) is greater than capture interval (%2 ms)!") .arg(maxShutterSpeed.toMs()) .arg(interval) << endl; } shutterSpdAlg = new MatrixMeteringAlg(choices, currentShutterSpeed, minShutterSpeed, maxShutterSpeed, &err, &verboseOutput, changeThreshold, shutterSpeedStep); } } } // output if (!parser.isSet(outputOption)) die << "Output directory is not set"; output = QDir(parser.value(outputOption)); if (output.exists()) err << "Output directory exists already." << endl; if (!output.mkpath(".")) die << QString("Can't create output directory %1 !").arg(output.path()); return dev; }