Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
monticore
EmbeddedMontiArc
generators
EMAM2Cpp
Commits
9ab6497a
Commit
9ab6497a
authored
Feb 27, 2020
by
Ahmed
Browse files
some fixes
parent
ce8429ec
Changes
20
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/monticore/lang/monticar/generator/cpp/ConversionHelperSource.java
View file @
9ab6497a
...
...
@@ -6,8 +6,7 @@ package de.monticore.lang.monticar.generator.cpp;
*/
public
class
ConversionHelperSource
{
public
static
String
conversionHelperSourceCode
=
"// convert an OpenCV matrix to Armadillo matrix. NOTE: a copy is made\n"
+
"#ifndef CONVHELPER_H\n"
+
public
static
String
conversionHelperSourceCode
=
"#ifndef CONVHELPER_H\n"
+
"#define CONVHELPER_H\n"
+
"#include <iostream>\n"
+
"#include \"armadillo\"\n"
+
...
...
src/main/java/de/monticore/lang/monticar/generator/cpp/commands/BoundingRectCommand.java
View file @
9ab6497a
...
...
@@ -55,7 +55,7 @@ public class BoundingRectCommand extends MathCommand{
MathFunctionFixer
.
fixMathFunctions
(
accessSymbol
,
bluePrintCPP
);
String
nameOfFirstParameter
=
mathMatrixNameExpressionSymbol
.
getMathMatrixAccessOperatorSymbol
().
getMathMatrixAccessSymbols
().
get
(
0
).
getTextualRepresentation
();
ComponentConverter
.
fixVariableType
(
nameOfFirstParameter
,
bluePrintCPP
,
"Q"
,
"vector<cv::Point>"
,
""
);
ComponentConverter
.
fixVariableType
(
nameOfFirstParameter
,
bluePrintCPP
,
"Q"
,
"
std::
vector<cv::Point>"
,
""
);
valueListString
+=
ExecuteMethodGenerator
.
generateExecuteCode
(
mathExpressionSymbol
,
new
ArrayList
<
String
>());
List
<
MathMatrixAccessSymbol
>
newMatrixAccessSymbols
=
new
ArrayList
<>();
...
...
src/main/java/de/monticore/lang/monticar/generator/cpp/commands/CvtColorCommand.java
View file @
9ab6497a
...
...
@@ -121,7 +121,7 @@ public class CvtColorCommand extends ArgumentNoReturnMathCommand{
}
else
if
(
properties
.
isPreCV
()){
finalInstruction
+=
" cv::Mat dstCV;\n"
+
" cv::cvtColor(src, dstCV, colorConversion);\n"
;
if
(
typeNameOut
==
"
c
ube"
){
if
(
typeNameOut
==
"
C
ube
<unsigned char>
"
){
finalInstruction
+=
" dst = to_armaCube<unsigned char, 3>(dstCV);\n"
;
}
else
{
finalInstruction
+=
" dst = to_arma<unsigned char>(dstCV);\n"
;
...
...
@@ -135,7 +135,7 @@ public class CvtColorCommand extends ArgumentNoReturnMathCommand{
" cv::Mat dstCV;\n"
+
" srcCV = to_cvmat<unsigned char>(src);\n"
+
" cv::cvtColor(srcCV, dstCV, colorConversion);\n"
;
if
(
typeNameOut
==
"
c
ube"
){
if
(
typeNameOut
==
"
C
ube
<unsigned char>
"
){
finalInstruction
+=
" dst = to_armaCube<unsigned char, 3>(dstCV);\n"
;
}
else
{
finalInstruction
+=
" dst = to_arma<unsigned char>(dstCV);\n"
;
...
...
src/main/java/de/monticore/lang/monticar/generator/cpp/commands/DilateCommand.java
View file @
9ab6497a
...
...
@@ -133,7 +133,7 @@ public class DilateCommand extends ArgumentNoReturnMathCommand{
}
else
if
(
properties
.
isPreCV
()){
finalInstruction
+=
" cv::Mat dstCV;\n"
+
" cv::dilate( src, dstCV, cv::element, cv::Point(-1,-1), iterations );\n"
;
if
(
typeNameOut
==
"
c
ube"
){
if
(
typeNameOut
==
"
C
ube
<unsigned char>
"
){
finalInstruction
+=
" dst = to_armaCube<unsigned char, 3>(dstCV);\n"
;
}
else
{
finalInstruction
+=
" dst = to_arma<unsigned char>(dstCV);\n"
;
...
...
@@ -147,7 +147,7 @@ public class DilateCommand extends ArgumentNoReturnMathCommand{
" cv::Mat dstCV;\n"
+
" srcCV = to_cvmat<unsigned char>(src);\n"
+
" cv::dilate( srcCV, dstCV, element, cv::Point(-1,-1), iterations );\n"
;
if
(
typeNameOut
==
"
c
ube"
){
if
(
typeNameOut
==
"
C
ube
<unsigned char>
"
){
finalInstruction
+=
" dst = to_armaCube<unsigned char, 3>(dstCV);\n"
;
}
else
{
finalInstruction
+=
" dst = to_arma<unsigned char>(dstCV);\n"
;
...
...
src/main/java/de/monticore/lang/monticar/generator/cpp/commands/FindContoursCommand.java
View file @
9ab6497a
...
...
@@ -94,7 +94,7 @@ public class FindContoursCommand extends ArgumentNoReturnMathCommand{
Variable
image
=
new
Variable
();
method
.
addParameter
(
image
,
"image"
,
"CommonMatrixType"
,
typeNameInConst
,
MathConverter
.
curBackend
.
getIncludeHeaderName
());
Variable
contours
=
new
Variable
();
method
.
addParameter
(
contours
,
"contours"
,
"CommonMatrixType"
,
"vector<vector<cv::Point>>&"
,
MathConverter
.
curBackend
.
getIncludeHeaderName
());
method
.
addParameter
(
contours
,
"contours"
,
"CommonMatrixType"
,
"
std::
vector<
std::
vector<cv::Point>>&"
,
MathConverter
.
curBackend
.
getIncludeHeaderName
());
Variable
mode
=
new
Variable
();
method
.
addParameter
(
mode
,
"mode"
,
"Integer"
,
"int"
,
""
);
Variable
meth
=
new
Variable
();
...
...
src/main/java/de/monticore/lang/monticar/generator/cpp/commands/GaussianBlurCommand.java
View file @
9ab6497a
...
...
@@ -129,7 +129,7 @@ public class GaussianBlurCommand extends ArgumentNoReturnMathCommand{
finalInstruction
=
" cv::Mat dstCV;\n"
+
" cv::Size sizeO = cv::Size(sizeX, sizeY);\n"
+
" cv::GaussianBlur(src, dstCV, sizeO, sigmaX, sigmaY);\n"
;
if
(
typeNameOut
==
"
c
ube"
){
if
(
typeNameOut
==
"
C
ube
<unsigned char>
"
){
finalInstruction
+=
" dst = to_armaCube<unsigned char, 3>(dstCV);\n"
;
}
else
{
finalInstruction
+=
" dst = to_arma<unsigned char>(dstCV);\n"
;
...
...
@@ -145,7 +145,7 @@ public class GaussianBlurCommand extends ArgumentNoReturnMathCommand{
" srcCV = to_cvmat<unsigned char>(src);\n"
+
" cv::Size sizeO = cv::Size(sizeX, sizeY);\n"
+
" cv::GaussianBlur(srcCV, dstCV, sizeO, sigmaX, sigmaY);\n"
;
if
(
typeNameOut
==
"
c
ube"
){
if
(
typeNameOut
==
"
C
ube
<unsigned char>
"
){
finalInstruction
+=
" dst = to_armaCube<unsigned char, 3>(dstCV);\n"
;
}
else
{
finalInstruction
+=
" dst = to_arma<unsigned char>(dstCV);\n"
;
...
...
src/main/java/de/monticore/lang/monticar/generator/cpp/commands/LargestContourCommand.java
View file @
9ab6497a
...
...
@@ -52,7 +52,7 @@ public class LargestContourCommand extends MathCommand {
MathFunctionFixer
.
fixMathFunctions
(
accessSymbol
,
bluePrintCPP
);
String
nameOfFirstParameter
=
mathMatrixNameExpressionSymbol
.
getMathMatrixAccessOperatorSymbol
().
getMathMatrixAccessSymbols
().
get
(
0
).
getTextualRepresentation
();
ComponentConverter
.
fixVariableType
(
nameOfFirstParameter
,
bluePrintCPP
,
"Q"
,
"vector<vector<cv::Point>>"
,
""
);
ComponentConverter
.
fixVariableType
(
nameOfFirstParameter
,
bluePrintCPP
,
"Q"
,
"
std::
vector<
std::
vector<cv::Point>>"
,
""
);
Method
largestContourMethod
=
getLargestContourMethod
();
valueListString
+=
ExecuteMethodGenerator
.
generateExecuteCode
(
mathExpressionSymbol
,
new
ArrayList
<
String
>());
List
<
MathMatrixAccessSymbol
>
newMatrixAccessSymbols
=
new
ArrayList
<>();
...
...
@@ -73,7 +73,7 @@ public class LargestContourCommand extends MathCommand {
//add parameters
Variable
contours
=
new
Variable
();
method
.
addParameter
(
contours
,
"contours"
,
"double"
,
"const std::vector
<std::vector<cv::Point>>&"
,
""
);
method
.
addParameter
(
contours
,
"contours"
,
"double"
,
"const std::vector<std::vector<cv::Point>>&"
,
""
);
//add an instruction to the method
method
.
addInstruction
(
methodBody
());
...
...
@@ -93,7 +93,7 @@ public class LargestContourCommand extends MathCommand {
" maxAreaContourId = j;\n"
+
" }\n"
+
" }\n"
+
" return contours.at(maxAreaContourId);"
;
" return contours.at(maxAreaContourId);
\n
"
;
}
@Override
...
...
src/main/java/de/monticore/lang/monticar/generator/cpp/commands/RectangleCommand.java
View file @
9ab6497a
...
...
@@ -130,7 +130,7 @@ public class RectangleCommand extends MathCommand{
" return src;\n"
;
}
else
if
(
properties
.
isPreCV
()){
finalInstruction
=
" cv::rectangle(src, rect.tl(), rect.br(), cv::Scalar(color(0), color(1), color(2)), thickness, lineType);\n"
;
if
(
typeNameOut
==
"
c
ube"
){
if
(
typeNameOut
==
"
C
ube
<unsigned char>
"
){
finalInstruction
+=
" arma::cube srcCube;\n"
+
" srcCube = to_armaCube<unsigned char, 3>(src);\n"
+
" return srcCube;\n"
;
...
...
@@ -148,7 +148,7 @@ public class RectangleCommand extends MathCommand{
finalInstruction
=
" cv::Mat srcCV;\n"
+
" srcCV = to_cvmat<unsigned char>(src);\n"
+
" cv::rectangle(srcCV, rect.tl(), rect.br(), cv::Scalar(color(0), color(1), color(2)), thickness, lineType);\n"
;
if
(
typeNameOut
==
"
c
ube"
){
if
(
typeNameOut
==
"
C
ube
<unsigned char>
"
){
finalInstruction
+=
" arma::cube srcCube;\n"
+
" srcCube = to_armaCube<unsigned char, 3>(srcCV);\n"
+
" return srcCube;\n"
;
...
...
src/test/resources/results/armadillo/testMath/l0/ConvHelper.h
View file @
9ab6497a
#ifndef CONVHELPER_H
#define CONVHELPER_H
#include <iostream>
#include "armadillo"
#include <stdarg.h>
#include <initializer_list>
#include <fstream>
using
namespace
arma
;
// convert an OpenCV matrix to Armadillo matrix. NOTE: a copy is made
template
<
typename
T
>
arma
::
Mat
<
T
>
to_arma
(
const
cv
::
Mat_
<
T
>&
src
)
{
arma
::
Mat
<
T
>
dst
(
reinterpret_cast
<
double
*>
(
src
.
data
),
src
.
cols
,
src
.
rows
);
arma
::
Mat
<
T
>
dst
(
reinterpret_cast
<
T
*>
(
src
.
data
),
src
.
cols
,
src
.
rows
);
//src.copyTo({ src.rows, src.cols, dst.memptr() });
return
dst
;
}
...
...
@@ -26,7 +36,7 @@ Cube<T> to_armaCube(const cv::Mat_<cv::Vec<T, NC>>& src)
// convert an Armadillo cube to OpenCV matrix. NOTE: a copy is made
template
<
typename
T
>
cv
::
Mat
to_cvmat
(
Cube
<
T
>&
src
)
{
cv
::
Mat
to_cvmat
(
const
Cube
<
T
>&
src
)
{
std
::
vector
<
cv
::
Mat_
<
T
>>
channels
;
for
(
size_t
c
=
0
;
c
<
src
.
n_slices
;
++
c
)
{
auto
*
data
=
const_cast
<
T
*>
(
src
.
slice
(
c
).
memptr
());
...
...
@@ -35,4 +45,7 @@ cv::Mat to_cvmat(Cube<T>& src) {
cv
::
Mat
dst
;
cv
::
merge
(
channels
,
dst
);
return
dst
;
}
\ No newline at end of file
}
#endif
\ No newline at end of file
src/test/resources/results/armadillo/testMath/l0/test_math_boundingRectCommandTest.h
View file @
9ab6497a
...
...
@@ -9,14 +9,14 @@ using namespace arma;
using
namespace
std
;
class
test_math_boundingRectCommandTest
{
public:
vector
<
cv
::
Point
>
contour
;
double
rect
;
std
::
vector
<
cv
::
Point
>
contour
;
cv
::
Rect
rect
;
void
init
()
{
}
void
execute
()
{
rect
Angle
=
(
cv
::
boundingRect
(
contour
));
rect
=
(
cv
::
boundingRect
(
contour
));
}
};
...
...
src/test/resources/results/armadillo/testMath/l0/test_math_cvtColorCommandTest.h
View file @
9ab6497a
...
...
@@ -10,21 +10,21 @@ using namespace arma;
using
namespace
std
;
class
test_math_cvtColorCommandTest
{
public:
arma
::
m
at
src
;
arma
::
M
at
<
unsigned
char
>
src
;
int
colorConversion
;
arma
::
m
at
dst
;
arma
::
M
at
<
unsigned
char
>
dst
;
void
init
()
{
src
=
m
at
(
n
,
m
);
dst
=
m
at
(
n
,
m
);
src
=
M
at
<
unsigned
char
>
(
n
,
m
);
dst
=
M
at
<
unsigned
char
>
(
n
,
m
);
}
void
cvtColorHelper
(
arma
::
m
at
src
,
arma
::
m
at
dst
,
int
colorConversion
)
void
cvtColorHelper
(
const
arma
::
M
at
<
unsigned
char
>&
src
,
arma
::
M
at
<
unsigned
char
>&
dst
,
int
colorConversion
)
{
cv
::
Mat
srcCV
;
cv
::
Mat
dstCV
;
srcCV
=
ConvHelper
::
to_cvmat
(
src
);
srcCV
=
to_cvmat
<
unsigned
char
>
(
src
);
cv
::
cvtColor
(
srcCV
,
dstCV
,
colorConversion
);
dst
=
ConvHelper
::
to_arma
(
dstCV
);
dst
=
to_arma
<
unsigned
char
>
(
dstCV
);
}
void
execute
()
{
...
...
src/test/resources/results/armadillo/testMath/l0/test_math_dilateCommandTest.h
View file @
9ab6497a
...
...
@@ -10,30 +10,30 @@ using namespace arma;
using
namespace
std
;
class
test_math_dilateCommandTest
{
public:
arma
::
m
at
src
;
arma
::
M
at
<
unsigned
char
>
src
;
int
dilation_elem
;
int
iterations
;
arma
::
m
at
dst
;
arma
::
M
at
<
unsigned
char
>
dst
;
void
init
()
{
src
=
m
at
(
n
,
m
);
dst
=
m
at
(
n
,
m
);
src
=
M
at
<
unsigned
char
>
(
n
,
m
);
dst
=
M
at
<
unsigned
char
>
(
n
,
m
);
}
void
dilateHelper
(
arma
::
m
at
src
,
arma
::
m
at
dst
,
int
dilation_elem
,
int
iterations
)
void
dilateHelper
(
const
arma
::
M
at
<
unsigned
char
>&
src
,
arma
::
M
at
<
unsigned
char
>&
dst
,
int
dilation_elem
,
int
iterations
)
{
int
dilation_type
=
0
;
if
(
dilation_elem
==
0
){
dilation_type
=
MORPH_RECT
;
}
else
if
(
dilation_elem
==
1
){
dilation_type
=
MORPH_CROSS
;
}
else
if
(
dilation_elem
==
2
)
{
dilation_type
=
MORPH_ELLIPSE
;
}
dilation_size
=
dilation_elem
;
cv
::
m
at
element
=
cv
::
getStructuringElement
(
dilation_type
,
Size
(
2
*
dilation_size
+
1
,
2
*
dilation_size
+
1
),
Point
(
-
1
,
-
1
)
);
if
(
dilation_elem
==
0
){
dilation_type
=
cv
::
MORPH_RECT
;
}
else
if
(
dilation_elem
==
1
){
dilation_type
=
cv
::
MORPH_CROSS
;
}
else
if
(
dilation_elem
==
2
)
{
dilation_type
=
cv
::
MORPH_ELLIPSE
;
}
int
dilation_size
=
dilation_elem
;
cv
::
M
at
element
=
cv
::
getStructuringElement
(
dilation_type
,
cv
::
Size
(
2
*
dilation_size
+
1
,
2
*
dilation_size
+
1
),
cv
::
Point
(
-
1
,
-
1
)
);
cv
::
Mat
srcCV
;
cv
::
Mat
dstCV
;
srcCV
=
ConvHelper
::
to_cvmat
(
src
);
cv
::
dilate
(
srcCV
,
dstCV
,
element
,
Point
(
-
1
,
-
1
),
iterations
);
dst
=
ConvHelper
::
to_arma
(
dstCV
);
srcCV
=
to_cvmat
<
unsigned
char
>
(
src
);
cv
::
dilate
(
srcCV
,
dstCV
,
element
,
cv
::
Point
(
-
1
,
-
1
),
iterations
);
dst
=
to_arma
<
unsigned
char
>
(
dstCV
);
}
void
execute
()
{
...
...
src/test/resources/results/armadillo/testMath/l0/test_math_erodeAndGaussianBlurCommandTest.h
View file @
9ab6497a
...
...
@@ -11,13 +11,13 @@ using namespace arma;
using
namespace
std
;
class
test_math_erodeAndGaussianBlurCommandTest
{
public:
c
ube
src
;
C
ube
<
unsigned
char
>
src
;
int
erosion_elemIn
;
colvec
sizeY
;
colvec
two
;
c
ube
dst
;
c
ube
outMatrix
;
arma
::
m
at
out2Matrix
;
C
ube
<
unsigned
char
>
dst
;
C
ube
<
unsigned
char
>
outMatrix
;
arma
::
M
at
<
unsigned
char
>
out2Matrix
;
void
init
()
{
src
=
cube
(
n
,
m
,
3
);
...
...
@@ -25,35 +25,35 @@ sizeY=colvec(3);
two
=
colvec
(
2
);
dst
=
cube
(
n
,
m
,
3
);
outMatrix
=
cube
(
3
,
n
,
m
);
out2Matrix
=
m
at
(
2
,
m
);
out2Matrix
=
M
at
<
unsigned
char
>
(
2
,
m
);
}
void
erodeHelper
(
c
ube
src
,
cv
::
Mat
dst
,
int
erosion_elem
,
int
iterations
)
void
erodeHelper
(
c
onst
Cube
<
unsigned
char
>&
src
,
cv
::
Mat
&
dst
,
int
erosion_elem
,
int
iterations
)
{
int
erosion_type
=
0
;
if
(
erosion_elem
==
0
){
erosion_type
=
MORPH_RECT
;
}
else
if
(
erosion_elem
==
1
){
erosion_type
=
MORPH_CROSS
;
}
else
if
(
erosion_elem
==
2
)
{
erosion_type
=
MORPH_ELLIPSE
;
}
erosion_size
=
erosion_elem
;
if
(
erosion_elem
==
0
){
erosion_type
=
cv
::
MORPH_RECT
;
}
else
if
(
erosion_elem
==
1
){
erosion_type
=
cv
::
MORPH_CROSS
;
}
else
if
(
erosion_elem
==
2
)
{
erosion_type
=
cv
::
MORPH_ELLIPSE
;
}
int
erosion_size
=
erosion_elem
;
cv
::
Mat
element
=
cv
::
getStructuringElement
(
erosion_type
,
Size
(
2
*
erosion_size
+
1
,
2
*
erosion_size
+
1
),
Point
(
-
1
,
-
1
)
);
cv
::
Size
(
2
*
erosion_size
+
1
,
2
*
erosion_size
+
1
),
cv
::
Point
(
-
1
,
-
1
)
);
cv
::
Mat
srcCV
;
srcCV
=
ConvHelper
::
to_cvmat
(
src
);
cv
::
erode
(
srcCV
,
dst
,
element
,
Point
(
-
1
,
-
1
),
iterations
);
srcCV
=
to_cvmat
<
unsigned
char
>
(
src
);
cv
::
erode
(
srcCV
,
dst
,
element
,
cv
::
Point
(
-
1
,
-
1
),
iterations
);
}
void
dilateHelper
(
cv
::
Mat
src
,
cv
::
Mat
dst
,
int
dilation_elem
,
int
iterations
)
void
dilateHelper
(
const
cv
::
Mat
&
src
,
cv
::
Mat
&
dst
,
int
dilation_elem
,
int
iterations
)
{
int
dilation_type
=
0
;
if
(
dilation_elem
==
0
){
dilation_type
=
MORPH_RECT
;
}
else
if
(
dilation_elem
==
1
){
dilation_type
=
MORPH_CROSS
;
}
else
if
(
dilation_elem
==
2
)
{
dilation_type
=
MORPH_ELLIPSE
;
}
dilation_size
=
dilation_elem
;
cv
::
m
at
element
=
cv
::
getStructuringElement
(
dilation_type
,
Size
(
2
*
dilation_size
+
1
,
2
*
dilation_size
+
1
),
Point
(
-
1
,
-
1
)
);
cv
::
dilate
(
src
,
dst
,
element
,
Point
(
-
1
,
-
1
),
iterations
);
if
(
dilation_elem
==
0
){
dilation_type
=
cv
::
MORPH_RECT
;
}
else
if
(
dilation_elem
==
1
){
dilation_type
=
cv
::
MORPH_CROSS
;
}
else
if
(
dilation_elem
==
2
)
{
dilation_type
=
cv
::
MORPH_ELLIPSE
;
}
int
dilation_size
=
dilation_elem
;
cv
::
M
at
element
=
cv
::
getStructuringElement
(
dilation_type
,
cv
::
Size
(
2
*
dilation_size
+
1
,
2
*
dilation_size
+
1
),
cv
::
Point
(
-
1
,
-
1
)
);
cv
::
dilate
(
src
,
dst
,
element
,
cv
::
Point
(
-
1
,
-
1
),
iterations
);
}
void
findContoursHelper
(
cv
::
Mat
image
,
vector
<
vector
<
cv
::
Point
>>
contours
,
int
mode
,
int
method
)
void
findContoursHelper
(
const
cv
::
Mat
&
image
,
std
::
vector
<
std
::
vector
<
cv
::
Point
>>
&
contours
,
int
mode
,
int
method
)
{
cv
::
findContours
(
image
,
contours
,
mode
,
method
);
}
...
...
@@ -68,7 +68,7 @@ cube src4 = (det(src));
erodeHelper
(
src4
,
dst
,
erosion_elem
,
iterations
);
erodeHelper
(
src
,
dst
,
erosion_elem
,
iterations
);
dilateHelper
(
dst
,
dst3
,
dilation_elem
,
iterations
);
cv
::
findContours
(
dst3
,
contours
,
method
,
mode
);
findContours
Helper
(
dst3
,
contours
,
method
,
mode
);
}
};
...
...
src/test/resources/results/armadillo/testMath/l0/test_math_findContoursCommandTest.h
View file @
9ab6497a
...
...
@@ -11,24 +11,24 @@ using namespace arma;
using
namespace
std
;
class
test_math_findContoursCommandTest
{
public:
arma
::
m
at
image
;
arma
::
M
at
<
unsigned
char
>
image
;
int
mode
;
int
method
;
vector
<
vector
<
cv
::
Point
>>
contours
;
std
::
vector
<
std
::
vector
<
cv
::
Point
>>
contours
;
void
init
()
{
image
=
m
at
(
n
,
m
);
image
=
M
at
<
unsigned
char
>
(
n
,
m
);
}
void
findContoursHelper
(
arma
::
m
at
image
,
vector
<
vector
<
cv
::
Point
>>
contours
,
int
mode
,
int
method
)
void
findContoursHelper
(
const
arma
::
M
at
<
unsigned
char
>&
image
,
std
::
vector
<
std
::
vector
<
cv
::
Point
>>
&
contours
,
int
mode
,
int
method
)
{
cv
::
Mat
srcCV
;
srcCV
=
ConvHelper
::
to_cvmat
(
src
);
cv
::
findContours
(
image
,
contours
,
mode
,
method
);
srcCV
=
to_cvmat
<
unsigned
char
>
(
image
);
cv
::
findContours
(
srcCV
,
contours
,
mode
,
method
);
}
void
execute
()
{
cv
::
findContours
(
image
,
contours
,
mode
,
method
);
findContours
Helper
(
image
,
contours
,
mode
,
method
);
}
};
#endif
\ No newline at end of file
#endif
src/test/resources/results/armadillo/testMath/l0/test_math_gaussianBlurCommandTest.h
View file @
9ab6497a
...
...
@@ -10,24 +10,25 @@ using namespace arma;
using
namespace
std
;
class
test_math_gaussianBlurCommandTest
{
public:
c
ube
src
;
C
ube
<
unsigned
char
>
src
;
int
sizeX
;
int
sizeY
;
double
sigmaX
;
double
sigmaY
;
c
ube
dst
;
C
ube
<
unsigned
char
>
dst
;
void
init
()
{
src
=
cube
(
3
,
n
,
m
);
dst
=
cube
(
3
,
n
,
m
);
src
=
cube
(
n
,
m
,
3
);
dst
=
cube
(
n
,
m
,
3
);
}
void
gaussianBlurHelper
(
c
ube
src
,
c
ube
dst
,
int
sizeX
,
int
sizeY
,
double
sigmaX
,
double
sigmaY
)
void
gaussianBlurHelper
(
c
onst
Cube
<
unsigned
char
>&
src
,
C
ube
<
unsigned
char
>&
dst
,
int
sizeX
,
int
sizeY
,
double
sigmaX
,
double
sigmaY
)
{
cv
::
Mat
srcCV
;
cv
::
Mat
dstCV
;
srcCV
=
ConvHelper
::
to_cvmat
(
src
);
cv
::
gaussianBlur
(
srcCV
,
dstCV
,
Size
(
sizeX
,
sizeY
),
sigmaX
,
sigmaY
);
dst
=
ConvHelper
::
to_armaCube
(
dstCV
);
srcCV
=
to_cvmat
<
unsigned
char
>
(
src
);
cv
::
Size
sizeO
=
cv
::
Size
(
sizeX
,
sizeY
);
cv
::
GaussianBlur
(
srcCV
,
dstCV
,
sizeO
,
sigmaX
,
sigmaY
);
dst
=
to_armaCube
<
unsigned
char
,
3
>
(
dstCV
);
}
void
execute
()
{
...
...
src/test/resources/results/armadillo/testMath/l0/test_math_inRangeCommandTest.h
View file @
9ab6497a
...
...
@@ -10,25 +10,25 @@ using namespace arma;
using
namespace
std
;
class
test_math_inRangeCommandTest
{
public:
arma
::
m
at
src
;
arma
::
M
at
<
unsigned
char
>
src
;
colvec
lowerBoundary
;
colvec
upperBoundary
;
arma
::
m
at
dst
;
arma
::
M
at
<
unsigned
char
>
dst
;
void
init
()
{
src
=
m
at
(
n
,
m
);
src
=
M
at
<
unsigned
char
>
(
n
,
m
);
lowerBoundary
=
colvec
(
3
);
upperBoundary
=
colvec
(
3
);
dst
=
m
at
(
n
,
m
);
dst
=
M
at
<
unsigned
char
>
(
n
,
m
);
}
void
inRangeHelper
(
c
ube
src
,
arma
::
m
at
dst
,
colvec
lowerB
,
colvec
upperB
)
void
inRangeHelper
(
c
onst
Cube
<
unsigned
char
>&
src
,
arma
::
M
at
<
unsigned
char
>&
dst
,
colvec
lowerB
,
colvec
upperB
)
{
cv
::
Mat
srcCV
;
cv
::
Mat
dstCV
;
srcCV
=
ConvHelper
::
to_cvmat
(
src
);
srcCV
=
to_cvmat
<
unsigned
char
>
(
src
);
cv
::
inRange
(
srcCV
,
cv
::
Scalar
(
lowerB
(
0
),
lowerB
(
1
),
lowerB
(
2
)),
cv
::
Scalar
(
upperB
(
0
),
upperB
(
1
),
upperB
(
2
)),
dstCV
);
dst
=
ConvHelper
::
to_arma
(
dstCV
);
dst
=
to_arma
<
unsigned
char
>
(
dstCV
);
}
void
execute
()
{
...
...
@@ -36,4 +36,4 @@ inRangeHelper(src, dst, lowerBoundary, upperBoundary);
}
};
#endif
#endif
\ No newline at end of file
src/test/resources/results/armadillo/testMath/l0/test_math_largestContourCommandTest.h
View file @
9ab6497a
...
...
@@ -9,12 +9,12 @@ using namespace arma;
using
namespace
std
;
class
test_math_largestContourCommandTest
{
public:
vector
<
vector
<
cv
::
Point
>>
contours
;
vector
<
cv
::
Point
>
lContour
;
std
::
vector
<
std
::
vector
<
cv
::
Point
>>
contours
;
std
::
vector
<
cv
::
Point
>
lContour
;
void
init
()
{
}
vector
<
Point
>
largestContour
(
vector
<
vector
<
Point
>>
contours
)
std
::
vector
<
cv
::
Point
>
largestContour
(
const
std
::
vector
<
std
::
vector
<
cv
::
Point
>>
&
contours
)
{
double
maxArea
=
0
;
int
maxAreaContourId
=
-
1
;
...
...
@@ -25,8 +25,7 @@ int maxAreaContourId = -1;
maxAreaContourId
=
j
;
}
}
return
contours
.
at
(
getMaxAreaContourId
(
contours
));
}
return
contours
.
at
(
maxAreaContourId
);
}
void
execute
()
{
...
...
src/test/resources/results/armadillo/testMath/l0/test_math_rectangleCommandTest.h
View file @
9ab6497a
...
...
@@ -10,25 +10,25 @@ using namespace arma;
using
namespace
std
;
class
test_math_rectangleCommandTest
{
public:
c
ube
src
;
C
ube
<
unsigned
char
>
src
;
Rect
rect
;
colvec
color
;
int
thickness
;
int
lineType
;
c
ube
outputImg
;
C
ube
<
unsigned
char
>
outputImg
;
void
init
()
{
src
=
cube
(
3
,
n
,
m
);
color
=
colvec
(
3
);
outputImg
=
cube
(
3
,
n
,
m
);
}
c
ube
rectangleHelper
(
c
ube
src
,
cv
::
Rect
rect
,
colvec
color
,
int
thickness
,
int
lineType
)
C
ube
<
unsigned
char
>
rectangleHelper
(
c
onst
Cube
<
unsigned
char
>&
src
,
cv
::
Rect
&
rect
,
colvec
color
,
int
thickness
,
int
lineType
)
{
cv
::
Mat
srcCV
;
srcCV
=
ConvHelper
::
to_cvmat
(
src
);
cv
::
rectangle
(
srcCV
,
rect
.
tl
(),
rect
.
br
(),
Scalar
(
color
(
0
),
color
(
1
),
color
(
2
)),
thickness
,
lineType
);
srcCV
=
to_cvmat
<
unsigned
char
>
(
src
);
cv
::
rectangle
(
srcCV
,
rect
.
tl
(),
rect
.
br
(),
cv
::
Scalar
(
color
(
0
),
color
(
1
),
color
(
2
)),
thickness
,
lineType
);
arma
::
cube
srcCube
;
srcCube
=
to_armaCube
(
srcCV
);
srcCube
=
to_armaCube
<
unsigned
char
,
3
>
(
srcCV
);
return
srcCube
;
}
void
execute
()
...
...
@@ -37,5 +37,4 @@ outputImg = (rectangleHelper(src, rect, color, thickness, lineType));
}
};
#endif
#endif
\ No newline at end of file
src/test/resources/test/math/BoundingRectCommandTest.emam
View file @
9ab6497a
...
...
@@ -7,6 +7,6 @@ component BoundingRectCommandTest{
out
Q
rect
;
implementation
Math
{
rect
Angle
=
boundingRect
(
contour
);
rect
=
boundingRect
(
contour
);
}
}
src/test/resources/test/math/GaussianBlurCommandTest.emam
View file @
9ab6497a
...
...
@@ -3,12 +3,12 @@ package test.math;
component
GaussianBlurCommandTest
{
port
in
Q
^{
3
,
n
,
m
}
src
,
in
Q
^{
n
,
m
,
3
}
src
,
in
Z
sizeX
,
in
Z
sizeY
,
in
Q
sigmaX
,