OFX::PageParamDescriptor*
CImgOperatorPluginHelperBase::describeInContextBegin(OFX::ImageEffectDescriptor &desc,
                                                     OFX::ContextEnum /*context*/,
                                                     const char* srcAClipName,
                                                     const char* srcBClipName,
                                                     bool supportsRGBA,
                                                     bool supportsRGB,
                                                     bool supportsXY,
                                                     bool supportsAlpha,
                                                     bool supportsTiles,
                                                     bool /*processRGB*/,
                                                     bool /*processAlpha*/,
                                                     bool /*processIsSecret*/)
{
    OFX::ClipDescriptor *srcBClip = desc.defineClip(srcBClipName);
    OFX::ClipDescriptor *srcAClip = desc.defineClip(srcAClipName);
    OFX::ClipDescriptor *dstClip = desc.defineClip(kOfxImageEffectOutputClipName);
    if (supportsRGBA) {
        srcAClip->addSupportedComponent(OFX::ePixelComponentRGBA);
        srcBClip->addSupportedComponent(OFX::ePixelComponentRGBA);
        dstClip->addSupportedComponent(OFX::ePixelComponentRGBA);
    }
    if (supportsRGB) {
        srcAClip->addSupportedComponent(OFX::ePixelComponentRGB);
        srcBClip->addSupportedComponent(OFX::ePixelComponentRGB);
        dstClip->addSupportedComponent(OFX::ePixelComponentRGB);
    }
    if (supportsXY) {
        srcAClip->addSupportedComponent(OFX::ePixelComponentXY);
        srcBClip->addSupportedComponent(OFX::ePixelComponentXY);
        dstClip->addSupportedComponent(OFX::ePixelComponentXY);
    }
    if (supportsAlpha) {
        srcAClip->addSupportedComponent(OFX::ePixelComponentAlpha);
        srcBClip->addSupportedComponent(OFX::ePixelComponentAlpha);
        dstClip->addSupportedComponent(OFX::ePixelComponentAlpha);
    }
    srcAClip->setTemporalClipAccess(false);
    srcBClip->setTemporalClipAccess(false);
    dstClip->setSupportsTiles(supportsTiles);
    srcAClip->setSupportsTiles(supportsTiles);
    srcBClip->setSupportsTiles(supportsTiles);
    srcAClip->setIsMask(false);
    srcBClip->setIsMask(false);

    // create the params
    OFX::PageParamDescriptor *page = desc.definePageParam("Controls");

    return page;
}
Beispiel #2
0
OFX::PageParamDescriptor*
CImgFilterPluginHelperBase::describeInContextBegin(bool sourceIsOptional,
                                                   OFX::ImageEffectDescriptor &desc,
                                                   OFX::ContextEnum context,
                                                   bool supportsRGBA,
                                                   bool supportsRGB,
                                                   bool supportsXY,
                                                   bool supportsAlpha,
                                                   bool supportsTiles,
                                                   bool processRGB,
                                                   bool processAlpha,
                                                   bool processIsSecret)
{

#ifdef OFX_EXTENSIONS_NATRON
    desc.setChannelSelector(OFX::ePixelComponentNone); // we have our own channel selector
#endif

    OFX::ClipDescriptor *srcClip = desc.defineClip(kOfxImageEffectSimpleSourceClipName);
    if (supportsRGBA) {
        srcClip->addSupportedComponent(OFX::ePixelComponentRGBA);
    }
    if (supportsRGB) {
        srcClip->addSupportedComponent(OFX::ePixelComponentRGB);
    }
    if (supportsXY) {
        srcClip->addSupportedComponent(OFX::ePixelComponentXY);
    }
    if (supportsAlpha) {
        srcClip->addSupportedComponent(OFX::ePixelComponentAlpha);
    }
    srcClip->setTemporalClipAccess(false);
    srcClip->setSupportsTiles(supportsTiles);
    srcClip->setIsMask(false);
    if (context == OFX::eContextGeneral && sourceIsOptional) {
        srcClip->setOptional(sourceIsOptional);
    }

    OFX::ClipDescriptor *dstClip = desc.defineClip(kOfxImageEffectOutputClipName);
    if (supportsRGBA) {
        dstClip->addSupportedComponent(OFX::ePixelComponentRGBA);
    }
    if (supportsRGB) {
        dstClip->addSupportedComponent(OFX::ePixelComponentRGB);
    }
    if (supportsXY) {
        dstClip->addSupportedComponent(OFX::ePixelComponentXY);
    }
    if (supportsAlpha) {
        dstClip->addSupportedComponent(OFX::ePixelComponentAlpha);
    }
    dstClip->setSupportsTiles(supportsTiles);

    OFX::ClipDescriptor *maskClip = (context == OFX::eContextPaint) ? desc.defineClip("Brush") : desc.defineClip("Mask");
    maskClip->addSupportedComponent(OFX::ePixelComponentAlpha);
    maskClip->setTemporalClipAccess(false);
    if (context != OFX::eContextPaint) {
        maskClip->setOptional(true);
    }
    maskClip->setSupportsTiles(supportsTiles);
    maskClip->setIsMask(true);

    // create the params
    OFX::PageParamDescriptor *page = desc.definePageParam("Controls");

    {
        OFX::BooleanParamDescriptor* param = desc.defineBooleanParam(kNatronOfxParamProcessR);
        param->setLabel(kNatronOfxParamProcessRLabel);
        param->setHint(kNatronOfxParamProcessRHint);
        param->setDefault(processRGB);
        param->setIsSecret(processIsSecret);
        param->setLayoutHint(OFX::eLayoutHintNoNewLine);
        if (page) {
            page->addChild(*param);
        }
    }
    {
        OFX::BooleanParamDescriptor* param = desc.defineBooleanParam(kNatronOfxParamProcessG);
        param->setLabel(kNatronOfxParamProcessGLabel);
        param->setHint(kNatronOfxParamProcessGHint);
        param->setDefault(processRGB);
        param->setIsSecret(processIsSecret);
        param->setLayoutHint(OFX::eLayoutHintNoNewLine);
        if (page) {
            page->addChild(*param);
        }
    }
    {
        OFX::BooleanParamDescriptor* param = desc.defineBooleanParam(kNatronOfxParamProcessB);
        param->setLabel(kNatronOfxParamProcessBLabel);
        param->setHint(kNatronOfxParamProcessBHint);
        param->setDefault(processRGB);
        param->setIsSecret(processIsSecret);
        param->setLayoutHint(OFX::eLayoutHintNoNewLine);
        if (page) {
            page->addChild(*param);
        }
    }
    {
        OFX::BooleanParamDescriptor* param = desc.defineBooleanParam(kNatronOfxParamProcessA);
        param->setLabel(kNatronOfxParamProcessALabel);
        param->setHint(kNatronOfxParamProcessAHint);
        param->setDefault(processAlpha);
        param->setIsSecret(processIsSecret);
        if (page) {
            page->addChild(*param);
        }
    }


    return page;
}
/**
 * @brief Function called to describe the plugin controls and features.
 * @param[in, out]   desc       Effect descriptor
 * @param[in]        context    Application context
 */
void PushPixelPluginFactory::describeInContext( OFX::ImageEffectDescriptor& desc,
                                                  OFX::EContext context )
{
	// Create the mandated output clip
	OFX::ClipDescriptor* dstClip = desc.defineClip( kOfxImageEffectOutputClipName );
	dstClip->addSupportedComponent( OFX::ePixelComponentRGBA );
	dstClip->addSupportedComponent( OFX::ePixelComponentAlpha );
	dstClip->setSupportsTiles( kSupportTiles );

	OFX::ClipDescriptor* srcClip = desc.defineClip( kOfxImageEffectSimpleSourceClipName );
	srcClip->addSupportedComponent( OFX::ePixelComponentRGBA );
	srcClip->addSupportedComponent( OFX::ePixelComponentAlpha );
	// no tiles on src clip, because it depends on the mask content so we can't
	// define the maximal bounding box needed...
	srcClip->setSupportsTiles( false );

	OFX::ClipDescriptor* maskClip = desc.defineClip( kClipMask );
	maskClip->addSupportedComponent( OFX::ePixelComponentRGBA );
	maskClip->addSupportedComponent( OFX::ePixelComponentAlpha );
	maskClip->setIsMask( true );
	maskClip->setOptional( true );
	maskClip->setSupportsTiles( true );

    OFX::ChoiceParamDescriptor* output = desc.defineChoiceParam( kParamOutput );
    output->setLabel( "Output" );
    output->appendOption( kParamOutputMotionVectors );
    output->appendOption( kParamOutputPushPixel );
    output->setDefault( 1 );

	OFX::DoubleParamDescriptor* size = desc.defineDoubleParam( kParamSize );
	size->setLabel( "Size" );
	size->setHint( "Size of the gradient window." );
	size->setRange( 0.0, std::numeric_limits<double>::max() );
	size->setDisplayRange( 1.0, 10.0 );
	size->setDefault( 2.0 );

	OFX::BooleanParamDescriptor* normalizedKernel = desc.defineBooleanParam( kParamNormalizedKernel );
	normalizedKernel->setLabel( "Normalized kernel" );
	normalizedKernel->setHint( "Use a normalized kernel to compute the gradient." );
	normalizedKernel->setDefault( true );
//#ifndef TUTTLE_PRODUCTION
	normalizedKernel->setIsSecret( true );
//#endif
	
	OFX::DoubleParamDescriptor* intensity = desc.defineDoubleParam( kParamIntensity );
	intensity->setLabel( "Intensity" );
	intensity->setHint( "Scale motion vectors." );
	intensity->setDisplayRange( 0.0, 2.0 );
	intensity->setDefault( 0.75 );

	OFX::DoubleParamDescriptor* angle = desc.defineDoubleParam( kParamAngle );
	angle->setLabel( "Angle" );
	angle->setHint( "Rotation on the gradient." );
	angle->setDisplayRange(-180, 180);
	angle->setDoubleType( OFX::eDoubleTypeAngle );
	angle->setDefault( 0.0 );

    OFX::ChoiceParamDescriptor* interpolation = desc.defineChoiceParam( kParamInterpolation );
    interpolation->setLabel( "Interpolation" );
    interpolation->setHint( "Interpolation method." );
    interpolation->appendOption( kParamInterpolationNearest );
    interpolation->appendOption( kParamInterpolationBilinear );
    interpolation->setDefault( 1 );

	OFX::ChoiceParamDescriptor* border = desc.defineChoiceParam( kParamBorder );
	border->setLabel( "Gradient border" );
	border->setHint( "Border method for gradient computation." );
	border->appendOption( kParamBorderMirror );
	border->appendOption( kParamBorderConstant );
	border->appendOption( kParamBorderBlack );
	border->appendOption( kParamBorderPadded );
}
void LensCalibrationPluginFactory::describeInContext(OFX::ImageEffectDescriptor& desc, OFX::ContextEnum context)
{
  //Input Clip
  OFX::ClipDescriptor *srcClip = desc.defineClip(kOfxImageEffectSimpleSourceClipName);
  srcClip->addSupportedComponent(OFX::ePixelComponentRGBA);
  srcClip->setTemporalClipAccess(false);
  srcClip->setSupportsTiles(false);
  srcClip->setIsMask(false);
  srcClip->setOptional(false);
  
  //Output clip
  OFX::ClipDescriptor *dstClip = desc.defineClip(kOfxImageEffectOutputClipName);
  dstClip->addSupportedComponent(OFX::ePixelComponentRGBA);
  dstClip->setSupportsTiles(false);
  
  //Calibration Group
  {
    OFX::GroupParamDescriptor *groupCalibration = desc.defineGroupParam(kParamGroupCalibration);
    groupCalibration->setLabel("Calibration");
    groupCalibration->setAsTab();

    {
      OFX::Int2DParamDescriptor *param = desc.defineInt2DParam(kParamImageSize);
      param->setLabel("Image Size");
      param->setHint("Input image size used to calibrate the optics. Obviously, all images should have the same size.");
      param->setDefault(0, 0);
      param->setDisplayRange(0, 0, 10000, 10000);
      param->setAnimates(false);
      param->setParent(*groupCalibration);
      param->setEnabled(false); // should not be edited by the user
    }

    {
      OFX::BooleanParamDescriptor *param = desc.defineBooleanParam(kParamInputImageIsGray);
      param->setLabel("Input image is gray");
      param->setHint("Input image is gray");
      param->setParent(*groupCalibration);
    }
    
    {
      OFX::ChoiceParamDescriptor *param = desc.defineChoiceParam(kParamPatternType);
      param->setLabel("Pattern Type");
      param->setHint("Type of pattern to detect");
      param->appendOptions(kStringParamPatternType);
      param->setDefault(eParamPatternTypeChessboard);
      param->setAnimates(false);
      param->setParent(*groupCalibration);
    }

    {
      OFX::Int2DParamDescriptor *param = desc.defineInt2DParam(kParamPatternSize);
      param->setLabel("Pattern Size");
      param->setHint("Number of inner corners per one of board dimension Width Height");
      param->setDefault(10, 7);
      param->setRange(2, 2, kOfxFlagInfiniteMax, kOfxFlagInfiniteMax);
      param->setDisplayRange(2, 2, 15, 15);
      param->setAnimates(false);
      param->setParent(*groupCalibration);
    }
    
    {
      OFX::DoubleParamDescriptor *param = desc.defineDoubleParam(kParamSquareSize);
      param->setLabel("Square Size");
      param->setHint("Define the size of the grid's square cells (mm)");
      param->setDisplayRange(0, 100);
      param->setDefault(1);
      param->setAnimates(false);
      param->setParent(*groupCalibration);
      param->setLayoutHint(OFX::eLayoutHintDivider);
    }

    {
      OFX::IntParamDescriptor *param = desc.defineIntParam(kParamNbRadialCoef);
      param->setLabel("Nb Radial Coef");
      param->setHint("Number of radial coefficient.");
      param->setRange(0, 6);
      param->setDisplayRange(0, 6);
      param->setDefault(3);
      param->setAnimates(false);
      param->setParent(*groupCalibration);
    }

    {
      OFX::IntParamDescriptor *param = desc.defineIntParam(kParamMaxFrames);
      param->setLabel("Max Frames");
      param->setHint("Maximal number of frames to extract from the video file.");
      param->setRange(0, kOfxFlagInfiniteMax);
      param->setDisplayRange(0, 1000);
      param->setDefault(0);
      param->setAnimates(false);
      param->setParent(*groupCalibration);
    }

    {
      OFX::IntParamDescriptor *param = desc.defineIntParam(kParamMaxCalibFrames);
      param->setLabel("Max Calibration Frames");
      param->setHint("Maximal number of frames to use to calibrate from the selected frames.");
      param->setRange(0, kOfxFlagInfiniteMax);
      param->setDisplayRange(0, 1000);
      param->setDefault(100);
      param->setAnimates(false);
      param->setParent(*groupCalibration);
    }

    {
      OFX::IntParamDescriptor *param = desc.defineIntParam(kParamCalibGridSize);
      param->setLabel("Max Calibration Grid Size");
      param->setHint("Define the number of cells per edge.");
      param->setRange(0, kOfxFlagInfiniteMax);
      param->setDisplayRange(0, 100);
      param->setDefault(10);
      param->setAnimates(false);
      param->setParent(*groupCalibration);
    }

    {
      OFX::IntParamDescriptor *param = desc.defineIntParam(kParamMinInputFrames);
      param->setLabel("Min Input Frames");
      param->setHint("Minimal number of frames to limit the calibration refinement loop.");
      param->setRange(0, kOfxFlagInfiniteMax);
      param->setDisplayRange(0, 1000);
      param->setDefault(10);
      param->setAnimates(false);
      param->setParent(*groupCalibration);
    }

    {
      OFX::DoubleParamDescriptor *param = desc.defineDoubleParam(kParamMaxTotalAvgErr);
      param->setLabel("Max Total Average Error");
      param->setHint("Maximal limit of the total average error");
      param->setRange(0, 1);
      param->setDisplayRange(0, 1);
      param->setDefault(0.1);
      param->setAnimates(false);
      param->setParent(*groupCalibration);
    }
    
    {
      OFX::PushButtonParamDescriptor *param = desc.definePushButtonParam(kParamCalibrate);
      param->setLabel("Calibrate");
      param->setHint("calibrate");
      param->setParent(*groupCalibration);
    }

  }

  //Output Group
  {
    OFX::GroupParamDescriptor *groupOutput = desc.defineGroupParam(kParamGroupOutput);
    groupOutput->setLabel("Output");
    groupOutput->setAsTab();
    
    {
      OFX::BooleanParamDescriptor *param = desc.defineBooleanParam(kParamOutputIsCalibrated);
      param->setLabel("Is calibrated");
      param->setHint("Is calibrated");
      param->setParent(*groupOutput);
    }
    
    {
      OFX::DoubleParamDescriptor *param = desc.defineDoubleParam(kParamOutputAvgReprojErr);
      param->setLabel("Average Reprojection Error");
      param->setDisplayRange(0, 10);
      param->setEvaluateOnChange(false);
      param->setEnabled(false);
      param->setAnimates(true);
      param->setParent(*groupOutput);
      param->setLayoutHint(OFX::eLayoutHintDivider);
    }
    
    {
      OFX::GroupParamDescriptor *groupCamera = desc.defineGroupParam(kParamOutputCameraGroup);
      groupCamera->setLabel("Intrinsics Camera Parameters");
      groupCamera->setParent(*groupOutput);
      groupCamera->setOpen(true);

      {
        OFX::DoubleParamDescriptor *param = desc.defineDoubleParam(kParamOutputFocalLenght);
        param->setLabel("Focal Length");
        param->setDisplayRange(1, 100);
        param->setAnimates(true);
        param->setEvaluateOnChange(false);
        param->setEnabled(false);
        param->setAnimates(false);
        param->setParent(*groupCamera);
      }

      {
        OFX::Double2DParamDescriptor *param = desc.defineDouble2DParam(kParamOutputPrincipalPointOffset);
        param->setLabel("Principal Point");
        param->setAnimates(true);
        param->setEvaluateOnChange(false);
        param->setEnabled(false);
        param->setAnimates(false);
        param->setParent(*groupCamera);
      }
    }
    
    {    
      OFX::GroupParamDescriptor *groupLensDistortion = desc.defineGroupParam(kParamOutputLensDistortionGroup);
      groupLensDistortion->setLabel("Lens Distortion Coefficients");
      groupLensDistortion->setParent(*groupOutput);
      groupLensDistortion->setOpen(true);
        
      {
        OFX::DoubleParamDescriptor *param = desc.defineDoubleParam(kParamOutputRadialCoef1);
        param->setLabel("Radial Coef1");
        param->setDisplayRange(0, 10);
        param->setAnimates(true);
        param->setEvaluateOnChange(false);
        param->setEnabled(false);
        param->setAnimates(false);
        param->setParent(*groupLensDistortion);
      }

      {
        OFX::DoubleParamDescriptor *param = desc.defineDoubleParam(kParamOutputRadialCoef2);
        param->setLabel("Radial Coef2");
        param->setDisplayRange(0, 10);
        param->setAnimates(true);
        param->setEvaluateOnChange(false);
        param->setEnabled(false);
        param->setAnimates(false);
        param->setParent(*groupLensDistortion);
      }

      {
        OFX::DoubleParamDescriptor *param = desc.defineDoubleParam(kParamOutputRadialCoef3);
        param->setLabel("Radial Coef3");
        param->setDisplayRange(0, 10);
        param->setAnimates(true);
        param->setEvaluateOnChange(false);
        param->setEnabled(false);
        param->setAnimates(false);
        param->setParent(*groupLensDistortion);
      }

      {
        OFX::DoubleParamDescriptor *param = desc.defineDoubleParam(kParamOutputTangentialCoef1);
        param->setLabel("Tangential Coef1");
        param->setDisplayRange(0, 10);
        param->setAnimates(true);
        param->setEvaluateOnChange(false);
        param->setEnabled(false);
        param->setAnimates(false);
        param->setParent(*groupLensDistortion);
      }

      {
        OFX::DoubleParamDescriptor *param = desc.defineDoubleParam(kParamOutputTangentialCoef2);
        param->setLabel("Tangential Coef2");
        param->setDisplayRange(0, 10);
        param->setAnimates(true);
        param->setEvaluateOnChange(false);
        param->setEnabled(false);
        param->setAnimates(false);
        param->setParent(*groupLensDistortion);
        param->setLayoutHint(OFX::eLayoutHintDivider);
      }
    }
    
    {
      OFX::PushButtonParamDescriptor *param = desc.definePushButtonParam(kParamOutputClear);
      param->setLabel("Clear");
      param->setHint("clear");
      param->setEnabled(false);
      param->setParent(*groupOutput);
    }
  }
  
  //Debug Group
  {
    OFX::GroupParamDescriptor *groupDebug = desc.defineGroupParam(kParamGroupDebug);
    groupDebug->setLabel("Debug");
    groupDebug->setAsTab();

    {
      OFX::BooleanParamDescriptor *param = desc.defineBooleanParam(kParamDebugEnable);
      param->setLabel("Enable Debug");
      param->setHint("Would you want to export undistorted images?");
      param->setParent(*groupDebug);
    }

    {
      OFX::StringParamDescriptor *param = desc.defineStringParam(kParamDebugRejectedImgFolder);
      param->setLabel("Rejected Frames");
      param->setHint("Folder to export delete images during the calibration refinement loop.");
      param->setStringType(OFX::eStringTypeDirectoryPath);
      param->setFilePathExists(true);
      param->setParent(*groupDebug);
    }

    {
      OFX::StringParamDescriptor *param = desc.defineStringParam(kParamDebugSelectedImgFolder);
      param->setLabel("Selected Frames");
      param->setHint("Folder to export debug images.");
      param->setStringType(OFX::eStringTypeDirectoryPath);
      param->setFilePathExists(true);
      param->setParent(*groupDebug);
    }
  }
}