diff --git a/modules/matlab/generator/filters.py b/modules/matlab/generator/filters.py
index 30b1cf000..d712c321c 100644
--- a/modules/matlab/generator/filters.py
+++ b/modules/matlab/generator/filters.py
@@ -1,6 +1,7 @@
from textwrap import TextWrapper
from string import split, join
import re, os
+urlexpr = re.compile(r"((https?):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)", re.MULTILINE|re.UNICODE)
def inputs(args):
'''Keeps only the input arguments in a list of elements.
@@ -58,7 +59,6 @@ def binaryToDecimal(string):
return string
def formatMatlabConstant(string, table):
- import re
# split the string into expressions
words = re.split('(\W+)', string)
# add a 'cv' prefix if an expression is also a key in the lookup table
@@ -70,6 +70,11 @@ def formatMatlabConstant(string, table):
words = 'bitshift('+shift[0]+', '+shift[1]+')' if len(shift) == 2 else words
return words
+def matlabURL(string):
+ """This filter is used to construct a Matlab specific URL that calls the
+ system browser instead of the (insanely bad) builtin Matlab browser"""
+ return re.sub(urlexpr, '\\1', string)
+
def capitalizeFirst(text):
return text[0].upper() + text[1:]
diff --git a/modules/matlab/generator/gen_matlab.py b/modules/matlab/generator/gen_matlab.py
index 3cc182902..1e41c306c 100644
--- a/modules/matlab/generator/gen_matlab.py
+++ b/modules/matlab/generator/gen_matlab.py
@@ -45,6 +45,7 @@ class MatlabWrapperGenerator(object):
jtemplate.filters['toUpperCamelCase'] = toUpperCamelCase
jtemplate.filters['toLowerCamelCase'] = toLowerCamelCase
jtemplate.filters['toUnderCase'] = toUnderCase
+ jtemplate.filters['matlabURL'] = matlabURL
jtemplate.filters['stripTags'] = stripTags
jtemplate.filters['filename'] = filename
jtemplate.filters['comment'] = comment
diff --git a/modules/matlab/generator/templates/template_doc_base.m b/modules/matlab/generator/templates/template_doc_base.m
index e94bf0b0f..3b1f641bf 100644
--- a/modules/matlab/generator/templates/template_doc_base.m
+++ b/modules/matlab/generator/templates/template_doc_base.m
@@ -1,9 +1,9 @@
{% import 'functional.cpp' as functional %}
-{{ ('CV.' + fun.name | upper + ' ' + doc.brief | stripTags) | comment(75, '%') }}
+{{ ('CV.' + fun.name | upper + ' ' + doc.brief | stripTags) | comment(75, '%') | matlabURL }}
%
% {{ functional.composeMatlab(fun) | upper }}
{% if doc.long %}
-{{ doc.long | stripTags | qualify(fun.name) | comment(75, '% ') }}
+{{ doc.long | stripTags | qualify(fun.name) | comment(75, '% ') | matlabURL }}
{% endif %}
%
{# ----------------------- Returns --------------------- #}
@@ -57,6 +57,6 @@ cv.{{ item }}{% if not loop.last %}, {% endif %}
{% endif %}
{# ----------------------- Online ---------------------- #}
{% set url = 'http://docs.opencv.org/modules/' + doc.module + '/doc/' + (doc.file|filename) + '.html#' + (fun.name|slugify) %}
-% Online docs: {{url}}
+% Online docs: {{ url | matlabURL }}
% Copyright {{ time.strftime("%Y", time.localtime()) }} The OpenCV Foundation
%