Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
monticore
EmbeddedMontiArc
generators
EMAM2Cpp
Commits
a9cf7e71
Commit
a9cf7e71
authored
Dec 30, 2019
by
Ahmed
Browse files
add GaussianBlurCommand
parent
7d8d8bdd
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/monticore/lang/monticar/generator/cpp/commands/DilateCommand.java
View file @
a9cf7e71
...
...
@@ -95,8 +95,8 @@ public class DilateCommand extends ArgumentReturnMathCommand{
" dilation_size = dilation_elem;\n"
+
" mat element = getStructuringElement( dilation_type,\n"
+
" Size( 2*dilation_size + 1, 2*dilation_size+1 ),\n"
+
" Point(
dilation_size, dilation_size
) );\n"
+
" dilate( src, dst, element, Point(-1,-1), iterations );"
;
" Point(
-1, -1
) );\n"
+
" dilate( src, dst, element, Point(-1,-1), iterations );
\n
"
;
}
@Override
...
...
src/main/java/de/monticore/lang/monticar/generator/cpp/commands/ErodeCommand.java
View file @
a9cf7e71
...
...
@@ -61,7 +61,7 @@ public class ErodeCommand extends ArgumentReturnMathCommand{
private
Method
getErodeHelperMethod
(){
Method
method
=
new
Method
(
"erodeHelper"
,
"void"
);
//parameter
//parameter
s
Variable
src
=
new
Variable
();
src
.
setName
(
"src"
);
src
.
setVariableType
(
new
VariableType
(
"CommonMatrixType"
,
MathConverter
.
curBackend
.
getMatrixTypeName
(),
MathConverter
.
curBackend
.
getIncludeHeaderName
()));
...
...
@@ -96,8 +96,8 @@ public class ErodeCommand extends ArgumentReturnMathCommand{
" erosion_size = erosion_elem;\n"
+
" mat element = getStructuringElement( erosion_type,\n"
+
" Size( 2*erosion_size + 1, 2*erosion_size+1 ),\n"
+
" Point(
erosion_size, erosion_size
) );\n"
+
" erode( src, dst, element, Point(-1,-1), iterations );"
;
" Point(
-1, -1
) );\n"
+
" erode( src, dst, element, Point(-1,-1), iterations );
\n
"
;
}
@Override
...
...
src/main/java/de/monticore/lang/monticar/generator/cpp/commands/GaussianBlurCommand.java
View file @
a9cf7e71
package
de.monticore.lang.monticar.generator.cpp.commands
;
import
alice.tuprolog.Int
;
import
de.monticore.lang.math._symboltable.expression.MathExpressionSymbol
;
import
de.monticore.lang.math._symboltable.matrix.MathMatrixAccessSymbol
;
import
de.monticore.lang.math._symboltable.matrix.MathMatrixNameExpressionSymbol
;
import
de.monticore.lang.monticar.generator.BluePrint
;
import
de.monticore.lang.monticar.generator.MathCommand
;
import
de.monticore.lang.monticar.generator.*
;
import
de.monticore.lang.monticar.generator.cpp.BluePrintCPP
;
import
de.monticore.lang.monticar.generator.cpp.MathFunctionFixer
;
import
de.monticore.lang.monticar.generator.cpp.converter.ExecuteMethodGenerator
;
...
...
@@ -19,7 +19,7 @@ import java.util.List;
* @author Ahmed Diab
*/
public
class
GaussianBlurCommand
extends
MathCommand
{
public
class
GaussianBlurCommand
extends
ArgumentReturn
MathCommand
{
public
GaussianBlurCommand
()
{
setMathCommandName
(
"gaussianBlur"
);
}
...
...
@@ -45,13 +45,65 @@ public class GaussianBlurCommand extends MathCommand{
String
valueListString
=
""
;
for
(
MathMatrixAccessSymbol
accessSymbol
:
mathMatrixNameExpressionSymbol
.
getMathMatrixAccessOperatorSymbol
().
getMathMatrixAccessSymbols
())
MathFunctionFixer
.
fixMathFunctions
(
accessSymbol
,
(
BluePrintCPP
)
bluePrint
);
Method
gaussianBlurHelperMethod
=
getGaussianBlurHelperMethod
();
valueListString
+=
ExecuteMethodGenerator
.
generateExecuteCode
(
mathExpressionSymbol
,
new
ArrayList
<
String
>());
List
<
MathMatrixAccessSymbol
>
newMatrixAccessSymbols
=
new
ArrayList
<>();
MathStringExpression
stringExpression
=
new
MathStringExpression
(
"gaussianBlur"
+
valueListString
,
mathMatrixNameExpressionSymbol
.
getMathMatrixAccessOperatorSymbol
().
getMathMatrixAccessSymbols
());
MathStringExpression
stringExpression
=
new
MathStringExpression
(
"gaussianBlur
Helper
"
+
valueListString
,
mathMatrixNameExpressionSymbol
.
getMathMatrixAccessOperatorSymbol
().
getMathMatrixAccessSymbols
());
newMatrixAccessSymbols
.
add
(
new
MathMatrixAccessSymbol
(
stringExpression
));
mathMatrixNameExpressionSymbol
.
getMathMatrixAccessOperatorSymbol
().
setMathMatrixAccessSymbols
(
newMatrixAccessSymbols
);
((
BluePrintCPP
)
bluePrint
).
addCVIncludeString
(
"opencv2/imgproc"
);
bluePrint
.
addMethod
(
gaussianBlurHelperMethod
);
}
private
Method
getGaussianBlurHelperMethod
(){
Method
method
=
new
Method
(
"gaussianBlurHelper"
,
"void"
);
//parameters
Variable
src
=
new
Variable
();
src
.
setName
(
"src"
);
src
.
setVariableType
(
new
VariableType
(
"CommonMatrixType"
,
MathConverter
.
curBackend
.
getMatrixTypeName
(),
MathConverter
.
curBackend
.
getIncludeHeaderName
()));
Variable
dst
=
new
Variable
();
dst
.
setName
(
"dst"
);
dst
.
setVariableType
(
new
VariableType
(
"CommonMatrixType"
,
MathConverter
.
curBackend
.
getMatrixTypeName
(),
MathConverter
.
curBackend
.
getIncludeHeaderName
()));
Variable
sizeX
=
new
Variable
();
sizeX
.
setName
(
"sizeX"
);
sizeX
.
setVariableType
(
new
VariableType
(
"Integer"
,
"int"
,
""
));
Variable
sizeY
=
new
Variable
();
sizeY
.
setName
(
"sizeY"
);
sizeY
.
setVariableType
(
new
VariableType
(
"Integer"
,
"int"
,
""
));
Variable
sigmaX
=
new
Variable
();
sigmaX
.
setName
(
"sigmaX"
);
sigmaX
.
setVariableType
(
new
VariableType
(
"Double"
,
"double"
,
""
));
Variable
sigmaY
=
new
Variable
();
sigmaY
.
setName
(
"sigmaY"
);
sigmaY
.
setVariableType
(
new
VariableType
(
"Double"
,
"double"
,
""
));
method
.
addParameter
(
src
);
method
.
addParameter
(
dst
);
method
.
addParameter
(
sizeX
);
method
.
addParameter
(
sizeY
);
method
.
addParameter
(
sigmaX
);
method
.
addParameter
(
sigmaY
);
method
.
addInstruction
(
methodBody
());
return
method
;
}
private
Instruction
methodBody
(){
return
new
Instruction
()
{
@Override
public
String
getTargetLanguageInstruction
()
{
return
" gaussianBlur(src, dst, Size(sizeX, sizeY), sigmaX, sigmaY);\n"
;
}
@Override
public
boolean
isConnectInstruction
()
{
return
false
;
}
};
}
}
src/test/resources/results/armadillo/testMath/l0/test_math_dilateCommandTest.h
View file @
a9cf7e71
...
...
@@ -27,8 +27,9 @@ void dilateHelper(mat src, mat dst, int erosion_elem, int iterations)
dilation_size
=
dilation_elem
;
mat
element
=
getStructuringElement
(
dilation_type
,
Size
(
2
*
dilation_size
+
1
,
2
*
dilation_size
+
1
),
Point
(
dilation_size
,
dilation_size
)
);
dilate
(
src
,
dst
,
element
,
Point
(
-
1
,
-
1
),
iterations
);}
Point
(
-
1
,
-
1
)
);
dilate
(
src
,
dst
,
element
,
Point
(
-
1
,
-
1
),
iterations
);
}
void
execute
()
{
dilateHelper
(
src
,
dst
,
dilation_elem
,
iterations
);
...
...
src/test/resources/results/armadillo/testMath/l0/test_math_erodeCommandTest.h
View file @
a9cf7e71
...
...
@@ -28,8 +28,9 @@ void erodeHelper(mat src, mat dst, int erosion_elem, int iterations)
erosion_size
=
erosion_elem
;
mat
element
=
getStructuringElement
(
erosion_type
,
Size
(
2
*
erosion_size
+
1
,
2
*
erosion_size
+
1
),
Point
(
erosion_size
,
erosion_size
)
);
erode
(
src
,
dst
,
element
,
Point
(
-
1
,
-
1
),
iterations
);}
Point
(
-
1
,
-
1
)
);
erode
(
src
,
dst
,
element
,
Point
(
-
1
,
-
1
),
iterations
);
}
void
execute
()
{
erodeHelper
(
src
,
dst
,
erosion_elem
,
iterations
);
...
...
src/test/resources/results/armadillo/testMath/l0/test_math_gaussianBlurCommandTest.h
View file @
a9cf7e71
...
...
@@ -9,12 +9,24 @@ using namespace arma;
using
namespace
cv
;
class
test_math_gaussianBlurCommandTest
{
public:
mat
src
;
int
sizeX
;
int
sizeY
;
double
sigmaX
;
double
sigmaY
;
mat
dst
;
void
init
()
{
src
=
mat
(
n
,
m
);
dst
=
mat
(
n
,
m
);
}
void
gaussianBlurHelper
(
mat
src
,
mat
dst
,
int
sizeX
,
int
sizeY
,
double
sigmaX
,
double
sigmaY
)
{
gaussianBlur
(
src
,
dst
,
Size
(
sizeX
,
sizeY
),
sigmaX
,
sigmaY
);
}
void
execute
()
{
double
a
=
(
gaussianBlur
(
0
,
0
,
0
,
0
,
0
)
);
gaussianBlurHelper
(
src
,
dst
,
sizeX
,
sizeY
,
sigmaX
,
sigmaY
);
}
};
...
...
src/test/resources/test/math/GaussianBlurCommandTest.emam
View file @
a9cf7e71
/*
(
c
)
https
://
github
.
com
/
MontiCore
/
monticore
*/
package
test
.
math
;
component
GaussianBlurCommandTest
{
implementation
Math
{
Q
a
=
gaussianBlur
(
0
,
0
,
0
,
0
,
0
);
component
GaussianBlurCommandTest
{
port
in
Q
^{
n
,
m
}
src
,
in
Z
sizeX
,
in
Z
sizeY
,
in
Q
sigmaX
,
in
Q
sigmaY
,
out
Q
^{
n
,
m
}
dst
;
implementation
Math
{
dst
=
gaussianBlur
(
src
,
sizeX
,
sizeY
,
sigmaX
,
sigmaY
);
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment