[FFmpeg-devel] [PATCH] libavfilter: Add dehaze-filter option in existing derain filter.
Liu Steven
lq at chinaffmpeg.org
Thu Aug 22 12:16:12 EEST 2019
> 在 2019年8月22日,下午5:08,Xuewei Meng <xwmeng96 at gmail.com> 写道:
>
> Add the support of dehaze filter in existing derain filter source
> code. As the processing procedure in FFmpeg is the same for current
> derain and dehaze, we reuse the derain filter source code. The
> model training and generation scripts are in repo
> https://github.com/XueweiMeng/derain_filter.git.
>
> Signed-off-by: Xuewei Meng <xwmeng96 at gmail.com>
> ---
> doc/filters.texi | 14 +++++++++++++-
> libavfilter/vf_derain.c | 13 +++++++++----
> 2 files changed, 22 insertions(+), 5 deletions(-)
>
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 323c02970e..49fc030489 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -8431,7 +8431,7 @@ delogo=x=0:y=0:w=100:h=77:band=10
>
> @section derain
>
> -Remove the rain in the input image/video by applying the derain methods based on
> +Remove the rain/haze in the input image/video by applying the derain/dehaze methods based on
> convolutional neural networks. Supported models:
>
> @itemize
> @@ -8449,6 +8449,18 @@ files (.pb) by using tools/python/convert.py
> The filter accepts the following options:
>
> @table @option
> + at item filter_type
> +Specify which filter to use. This option accepts the following values:
> +
> + at table @samp
> + at item derain
> +Derain filter. To conduct derain filter, you need to use a derain model.
> +
> + at item dehaze
> +Dehaze filter. To conduct dehaze filter, you need to use a dehaze model.
> + at end table
> +Default value is @samp{derain}.
> +
> @item dnn_backend
> Specify which DNN backend to use for model loading and execution. This option accepts
> the following values:
> diff --git a/libavfilter/vf_derain.c b/libavfilter/vf_derain.c
> index c380b40122..b33c37bfb4 100644
> --- a/libavfilter/vf_derain.c
> +++ b/libavfilter/vf_derain.c
> @@ -35,6 +35,7 @@ typedef struct DRContext {
> const AVClass *class;
>
> char *model_filename;
> + int filter_type;
> DNNBackendType backend_type;
> DNNModule *dnn_module;
> DNNModel *model;
> @@ -46,12 +47,16 @@ typedef struct DRContext {
> #define OFFSET(x) offsetof(DRContext, x)
> #define FLAGS AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM
> static const AVOption derain_options[] = {
> - { "dnn_backend", "DNN backend", OFFSET(backend_type), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS, "backend" },
> - { "native", "native backend flag", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, FLAGS, "backend" },
> + { "filter_type", "filter type(derain/dehaze)", OFFSET(filter_type), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS, "type" },
> + { "derain", "derain filter flag", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, FLAGS, "type" },
> + { "dehaze", "dehaze filter flag", 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, 0, 0, FLAGS, "type" },
> +
> + { "dnn_backend", "DNN backend", OFFSET(backend_type), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS, "backend" },
This should no modify context.
> + { "native", "native backend flag", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, FLAGS, "backend" },
This should no modify context.
> #if (CONFIG_LIBTENSORFLOW == 1)
> - { "tensorflow", "tensorflow backend flag", 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, 0, 0, FLAGS, "backend" },
> + { "tensorflow", "tensorflow backend flag", 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, 0, 0, FLAGS, "backend" },
This should no modify context.
> #endif
> - { "model", "path to model file", OFFSET(model_filename), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, FLAGS },
> + { "model", "path to model file", OFFSET(model_filename), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, FLAGS },
This should no modify context.
> { NULL }
> };
>
maybe only need add tree parameters, is it?
> --
> 2.17.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
More information about the ffmpeg-devel
mailing list