Commit d917fb64 authored by Ahmed's avatar Ahmed

update commands

parent b2aa4ee6
......@@ -7,9 +7,20 @@ 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" +
"#define CONVHELPER_H\n" +
"#include <iostream>\n" +
"#include \"armadillo\"\n" +
"#include <stdarg.h>\n" +
"#include <initializer_list>\n" +
"#include <fstream>\n" +
"using namespace arma;\n" +
"\n" +
"\n" +
"// convert an OpenCV matrix to Armadillo matrix. NOTE: a copy is made\n" +
"template <typename T>\n" +
"arma::Mat<T> to_arma(const cv::Mat_<T>& src) {\n" +
" arma::Mat<T> dst(reinterpret_cast<double*>(src.data), src.cols, src.rows);\n" +
" arma::Mat<T> dst(reinterpret_cast<T*>(src.data), src.cols, src.rows);\n" +
" //src.copyTo({ src.rows, src.cols, dst.memptr() });\n" +
" return dst;\n" +
"}\n" +
......@@ -34,7 +45,7 @@ public class ConversionHelperSource {
"\n" +
"// convert an Armadillo cube to OpenCV matrix. NOTE: a copy is made\n" +
"template <typename T>\n" +
"cv::Mat to_cvmat(Cube<T>& src) {\n" +
"cv::Mat to_cvmat(const Cube<T>& src) {\n" +
" std::vector<cv::Mat_<T>> channels;\n" +
" for (size_t c = 0; c < src.n_slices; ++c) {\n" +
" auto* data = const_cast<T*>(src.slice(c).memptr());\n" +
......@@ -43,5 +54,8 @@ public class ConversionHelperSource {
" cv::Mat dst;\n" +
" cv::merge(channels, dst);\n" +
" return dst;\n" +
"}\n";
"}\n" +
"\n" +
"\n" +
"#endif";
}
......@@ -65,6 +65,7 @@ public class CvtColorCommand extends ArgumentNoReturnMathCommand{
bluePrintCPP.addCVIncludeString("ConvHelper");
bluePrint.addMethod(cvtColorHelperMethod);
redefineArmaMat(bluePrintCPP);
redefineInit(bluePrintCPP);
}
......@@ -76,7 +77,9 @@ public class CvtColorCommand extends ArgumentNoReturnMathCommand{
String typeNameOut = "";
if(typeName.equals("") || typeName.equals("mat")){
typeName = "arma::mat";
typeName = "arma::Mat<unsigned char>";
}else if(typeName.equals("cube")){
typeName = "Cube<unsigned char>";
}
if(properties.isPreCV()){
......@@ -91,11 +94,14 @@ public class CvtColorCommand extends ArgumentNoReturnMathCommand{
typeNameOut = typeName;
}
String typeNameInConst = "const " + typeNameIn +"&";
String typeNameOutRef = typeNameOut + "&";
//add parameters
Variable src = new Variable();
method.addParameter(src, "src", "CommonMatrixType", typeNameIn, MathConverter.curBackend.getIncludeHeaderName());
method.addParameter(src, "src", "CommonMatrixType", typeNameInConst, MathConverter.curBackend.getIncludeHeaderName());
Variable dst = new Variable();
method.addParameter(dst, "dst", "CommonMatrixType", typeNameOut, MathConverter.curBackend.getIncludeHeaderName());
method.addParameter(dst, "dst", "CommonMatrixType", typeNameOutRef, MathConverter.curBackend.getIncludeHeaderName());
Variable coloerConversion = new Variable();
method.addParameter(coloerConversion,"colorConversion", "Integer", "int", "");
//add an instruction to the method
......@@ -116,23 +122,23 @@ public class CvtColorCommand extends ArgumentNoReturnMathCommand{
finalInstruction += " cv::Mat dstCV;\n" +
" cv::cvtColor(src, dstCV, colorConversion);\n";
if(typeNameOut == "cube"){
finalInstruction += " dst = ConvHelper::to_armaCube(dstCV);\n";
finalInstruction += " dst = to_armaCube<unsigned char, 3>(dstCV);\n";
} else {
finalInstruction += " dst = ConvHelper::to_arma(dstCV);\n";
finalInstruction += " dst = to_arma<unsigned char>(dstCV);\n";
}
} else if(properties.isSucCV()){
finalInstruction += " cv::Mat srcCV;\n" +
" srcCV = ConvHelper::to_cvmat(src);\n" +
" srcCV = to_cvmat<unsigned char>(src);\n" +
" cv::cvtColor(srcCV, dst, colorConversion);\n";
} else {
finalInstruction += " cv::Mat srcCV;\n" +
" cv::Mat dstCV;\n" +
" srcCV = ConvHelper::to_cvmat(src);\n" +
" srcCV = to_cvmat<unsigned char>(src);\n" +
" cv::cvtColor(srcCV, dstCV, colorConversion);\n";
if(typeNameOut == "cube"){
finalInstruction += " dst = ConvHelper::to_armaCube(dstCV);\n";
finalInstruction += " dst = to_armaCube<unsigned char, 3>(dstCV);\n";
} else {
finalInstruction += " dst = ConvHelper::to_arma(dstCV);\n";
finalInstruction += " dst = to_arma<unsigned char>(dstCV);\n";
}
}
return finalInstruction;
......
......@@ -65,6 +65,7 @@ public class DilateCommand extends ArgumentNoReturnMathCommand{
bluePrintCPP.addCVIncludeString("ConvHelper");
bluePrint.addMethod(dilateHelperMethod);
redefineArmaMat(bluePrintCPP);
redefineInit(bluePrintCPP);
}
......@@ -74,10 +75,14 @@ public class DilateCommand extends ArgumentNoReturnMathCommand{
String typeName = getTypeOfFirstInput(mathMatrixNameExpressionSymbol, bluePrintCPP);
String typeNameIn = "";
String typeNameOut = "";
if(typeName.equals("") || typeName.equals("mat")){
typeName = "arma::mat";
typeName = "arma::Mat<unsigned char>";
}else if(typeName.equals("cube")){
typeName = "Cube<unsigned char>";
}
if(properties.isPreCV()){
typeNameIn = "cv::Mat";
} else {
......@@ -90,11 +95,14 @@ public class DilateCommand extends ArgumentNoReturnMathCommand{
typeNameOut = typeName;
}
String typeNameInConst = "const " + typeNameIn +"&";
String typeNameOutRef = typeNameOut + "&";
//add parameters
Variable src = new Variable();
method.addParameter(src, "src", "CommonMatrix", typeNameIn, MathConverter.curBackend.getIncludeHeaderName());;
method.addParameter(src, "src", "CommonMatrix", typeNameInConst, MathConverter.curBackend.getIncludeHeaderName());;
Variable dst = new Variable();
method.addParameter(dst, "dst", "CommonMatrixType", typeNameOut, MathConverter.curBackend.getIncludeHeaderName());
method.addParameter(dst, "dst", "CommonMatrixType", typeNameOutRef, MathConverter.curBackend.getIncludeHeaderName());
Variable erosion_elem = new Variable();
method.addParameter(erosion_elem,"dilation_elem", "Integer", "int", "");
Variable iterations = new Variable();
......@@ -111,38 +119,38 @@ public class DilateCommand extends ArgumentNoReturnMathCommand{
@Override
public String getTargetLanguageInstruction() {
String finalInstruction = " int dilation_type = 0;\n" +
" if( dilation_elem == 0 ){ dilation_type = MORPH_RECT; }\n" +
" else if( dilation_elem == 1 ){ dilation_type = MORPH_CROSS; }\n" +
" else if( dilation_elem == 2) { dilation_type = MORPH_ELLIPSE; }\n" +
" dilation_size = dilation_elem;\n" +
" cv::mat element = cv::getStructuringElement( dilation_type,\n" +
" Size( 2*dilation_size + 1, 2*dilation_size+1 ),\n" +
" Point( -1, -1 ) );\n";
String finalInstruction = " int dilation_type = 0;\n" +
" if( dilation_elem == 0 ){ dilation_type = cv::MORPH_RECT; }\n" +
" else if( dilation_elem == 1 ){ dilation_type = cv::MORPH_CROSS; }\n" +
" else if( dilation_elem == 2) { dilation_type = cv::MORPH_ELLIPSE; }\n" +
" int dilation_size = dilation_elem;\n" +
" cv::Mat element = cv::getStructuringElement( dilation_type,\n" +
" cv::Size( 2*dilation_size + 1, 2*dilation_size+1 ),\n" +
" cv::Point( -1, -1 ) );\n";
if(properties.isPreCV() && properties.isSucCV()){
finalInstruction += " cv::dilate( src, dst, element, Point(-1,-1), iterations );\n";
finalInstruction += " cv::dilate( src, dst, element, cv::Point(-1,-1), iterations );\n";
}else if(properties.isPreCV()){
finalInstruction += " cv::Mat dstCV;\n" +
" cv::dilate( src, dstCV, element, Point(-1,-1), iterations );\n";
" cv::dilate( src, dstCV, cv::element, cv::Point(-1,-1), iterations );\n";
if(typeNameOut == "cube"){
finalInstruction += " dst = ConvHelper::to_armaCube(dstCV);\n";
finalInstruction += " dst = to_armaCube<unsigned char, 3>(dstCV);\n";
} else {
finalInstruction += " dst = ConvHelper::to_arma(dstCV);\n";
finalInstruction += " dst = to_arma<unsigned char>(dstCV);\n";
}
} else if(properties.isSucCV()){
finalInstruction += " cv::Mat srcCV;\n" +
" srcCV = ConvHelper::to_cvmat(src);\n" +
" cv::dilate( srcCV, dst, element, Point(-1,-1), iterations );\n";
" srcCV = to_cvmat<unsigned char>(src);\n" +
" cv::dilate( srcCV, dst, element, cv::Point(-1,-1), iterations );\n";
} else {
finalInstruction += " cv::Mat srcCV;\n" +
" cv::Mat dstCV;\n" +
" srcCV = ConvHelper::to_cvmat(src);\n" +
" cv::dilate( srcCV, dstCV, element, Point(-1,-1), iterations );\n";
" cv::Mat dstCV;\n" +
" srcCV = to_cvmat<unsigned char>(src);\n" +
" cv::dilate( srcCV, dstCV, element, cv::Point(-1,-1), iterations );\n";
if(typeNameOut == "cube"){
finalInstruction += " dst = ConvHelper::to_armaCube(dstCV);\n";
finalInstruction += " dst = to_armaCube<unsigned char, 3>(dstCV);\n";
} else {
finalInstruction += " dst = ConvHelper::to_arma(dstCV);\n";
finalInstruction += " dst = to_arma<unsigned char>(dstCV);\n";
}
}
return finalInstruction;
......
......@@ -117,14 +117,14 @@ public class ErodeCommand extends ArgumentNoReturnMathCommand{
return new Instruction() {
@Override
public String getTargetLanguageInstruction() {
String finalInstruction =" int erosion_type = 0;\n" +
" if( erosion_elem == 0 ){ erosion_type = cv::MORPH_RECT; }\n" +
" else if( erosion_elem == 1 ){ erosion_type = cv::MORPH_CROSS; }\n" +
" else if( erosion_elem == 2) { erosion_type = cv::MORPH_ELLIPSE; }\n" +
" int erosion_size = erosion_elem;\n" +
" cv::Mat element = cv::getStructuringElement( erosion_type,\n" +
" cv::Size( 2*erosion_size + 1, 2*erosion_size+1 ),\n" +
" cv::Point( -1, -1 ) );\n";
String finalInstruction = " int erosion_type = 0;\n" +
" if( erosion_elem == 0 ){ erosion_type = cv::MORPH_RECT; }\n" +
" else if( erosion_elem == 1 ){ erosion_type = cv::MORPH_CROSS; }\n" +
" else if( erosion_elem == 2) { erosion_type = cv::MORPH_ELLIPSE; }\n" +
" int erosion_size = erosion_elem;\n" +
" cv::Mat element = cv::getStructuringElement( erosion_type,\n" +
" cv::Size( 2*erosion_size + 1, 2*erosion_size+1 ),\n" +
" cv::Point( -1, -1 ) );\n";
if(properties.isPreCV() && properties.isSucCV()){
finalInstruction += " cv::erode( src, dst, element, cv::Point(-1,-1), iterations );\n";
......
......@@ -57,7 +57,7 @@ public class FindContoursCommand extends ArgumentNoReturnMathCommand{
Method findContoursHelperMethod = getFindContoursHelperMethod(mathMatrixNameExpressionSymbol, bluePrintCPP, properties);
valueListString += ExecuteMethodGenerator.generateExecuteCode(mathExpressionSymbol, new ArrayList<String>());
List<MathMatrixAccessSymbol> newMatrixAccessSymbols = new ArrayList<>();
MathStringExpression stringExpression = new MathStringExpression("cv::findContours" + valueListString,mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().getMathMatrixAccessSymbols());
MathStringExpression stringExpression = new MathStringExpression("findContoursHelper" + valueListString,mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().getMathMatrixAccessSymbols());
newMatrixAccessSymbols.add(new MathMatrixAccessSymbol(stringExpression));
mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().setMathMatrixAccessSymbols(newMatrixAccessSymbols);
......@@ -66,6 +66,7 @@ public class FindContoursCommand extends ArgumentNoReturnMathCommand{
bluePrintCPP.addCVIncludeString("vector");
bluePrint.addMethod(findContoursHelperMethod);
redefineArmaMat(bluePrintCPP);
redefineInit(bluePrintCPP);
}
......@@ -76,7 +77,9 @@ public class FindContoursCommand extends ArgumentNoReturnMathCommand{
String typeNameIn = "";
if(typeName.equals("") || typeName.equals("mat")){
typeName = "arma::mat";
typeName = "arma::Mat<unsigned char>";
}else if(typeName.equals("cube")){
typeName = "Cube<unsigned char>";
}
if(properties.isPreCV()){
......@@ -84,12 +87,14 @@ public class FindContoursCommand extends ArgumentNoReturnMathCommand{
} else {
typeNameIn = typeName;
}
String typeNameInConst = "const " + typeNameIn +"&";
//add parameters
Variable image = new Variable();
method.addParameter(image, "image", "CommonMatrixType", typeNameIn, MathConverter.curBackend.getIncludeHeaderName());
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", "vector<vector<cv::Point>>&", MathConverter.curBackend.getIncludeHeaderName());
Variable mode = new Variable();
method.addParameter(mode,"mode", "Integer", "int", "");
Variable meth = new Variable();
......@@ -110,8 +115,8 @@ public class FindContoursCommand extends ArgumentNoReturnMathCommand{
finalInstruction += " cv::findContours( image, contours, mode, method );\n";
} else {
finalInstruction += " cv::Mat srcCV;\n" +
" srcCV = ConvHelper::to_cvmat(src);\n" +
" cv::findContours( image, contours, mode, method );\n";
" srcCV = to_cvmat<unsigned char>(image);\n" +
" cv::findContours( srcCV, contours, mode, method );\n";
}
return finalInstruction;
}
......
......@@ -66,7 +66,8 @@ public class GaussianBlurCommand extends ArgumentNoReturnMathCommand{
bluePrintCPP.addCVIncludeString("opencv2/imgproc");
bluePrintCPP.addCVIncludeString("ConvHelper");
bluePrint.addMethod(gaussianBlurHelperMethod);
redefineArmaMat(bluePrintCPP);
redefineInit(bluePrintCPP);
}
private Method getGaussianBlurHelperMethod(MathMatrixNameExpressionSymbol mathMatrixNameExpressionSymbol, BluePrintCPP bluePrintCPP, MathExpressionProperties properties){
......@@ -76,8 +77,11 @@ public class GaussianBlurCommand extends ArgumentNoReturnMathCommand{
String typeNameOut = "";
if(typeName.equals("") || typeName.equals("mat")){
typeName = "arma::mat";
typeName = "arma::Mat<unsigned char>";
}else if(typeName.equals("cube")){
typeName = "Cube<unsigned char>";
}
if(properties.isPreCV()){
typeNameIn = "cv::Mat";
} else {
......@@ -90,11 +94,14 @@ public class GaussianBlurCommand extends ArgumentNoReturnMathCommand{
typeNameOut = typeName;
}
String typeNameInConst = "const " + typeNameIn +"&";
String typeNameOutRef = typeNameOut + "&";
//add parameters
Variable src = new Variable();
method.addParameter(src, "src", "CommonMatrix",typeNameIn, MathConverter.curBackend.getIncludeHeaderName());;
method.addParameter(src, "src", "CommonMatrix",typeNameInConst, MathConverter.curBackend.getIncludeHeaderName());;
Variable dst = new Variable();
method.addParameter(dst, "dst", "CommonMatrixType", typeNameOut, MathConverter.curBackend.getIncludeHeaderName());
method.addParameter(dst, "dst", "CommonMatrixType", typeNameOutRef, MathConverter.curBackend.getIncludeHeaderName());
Variable sizeX = new Variable();
method.addParameter(sizeX, "sizeX", "Integer", "int", "");
Variable sizeY = new Variable();
......@@ -116,28 +123,32 @@ public class GaussianBlurCommand extends ArgumentNoReturnMathCommand{
public String getTargetLanguageInstruction() {
String finalInstruction = "";
if(properties.isPreCV() && properties.isSucCV()){
finalInstruction = " cv::gaussianBlur(src, dst, Size(sizeX, sizeY), sigmaX, sigmaY);\n";
finalInstruction = " cv::Size sizeO = cv::Size(sizeX, sizeY);\n" +
" cv::GaussianBlur(src, dst, sizeO, sigmaX, sigmaY);\n";
}else if(properties.isPreCV()){
finalInstruction = " cv::Mat dstCV;\n" +
" cv::gaussianBlur(src, dstCV, Size(sizeX, sizeY), sigmaX, sigmaY);\n";
finalInstruction = " cv::Mat dstCV;\n" +
" cv::Size sizeO = cv::Size(sizeX, sizeY);\n" +
" cv::GaussianBlur(src, dstCV, sizeO, sigmaX, sigmaY);\n";
if(typeNameOut == "cube"){
finalInstruction += " dst = ConvHelper::to_armaCube(dstCV);\n";
finalInstruction += " dst = to_armaCube<unsigned char, 3>(dstCV);\n";
} else {
finalInstruction += " dst = ConvHelper::to_arma(dstCV);\n";
finalInstruction += " dst = to_arma<unsigned char>(dstCV);\n";
}
} else if(properties.isSucCV()){
finalInstruction = " cv::Mat srcCV;\n" +
" srcCV = ConvHelper::to_cvmat(src);\n" +
" cv::gaussianBlur(srcCV, dst, Size(sizeX, sizeY), sigmaX, sigmaY);\n";
finalInstruction = " cv::Mat srcCV;\n" +
" srcCV = to_cvmat<unsigned char>(src);\n" +
" cv::Size sizeO = cv::Size(sizeX, sizeY);\n" +
" cv::GaussianBlur(srcCV, dst, sizeO, sigmaX, sigmaY);\n";
} else {
finalInstruction = " cv::Mat srcCV;\n" +
" cv::Mat dstCV;\n" +
" srcCV = ConvHelper::to_cvmat(src);\n" +
" cv::gaussianBlur(srcCV, dstCV, Size(sizeX, sizeY), sigmaX, sigmaY);\n";
finalInstruction = " cv::Mat srcCV;\n" +
" cv::Mat dstCV;\n" +
" 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 == "cube"){
finalInstruction += " dst = ConvHelper::to_armaCube(dstCV);\n";
finalInstruction += " dst = to_armaCube<unsigned char, 3>(dstCV);\n";
} else {
finalInstruction += " dst = ConvHelper::to_arma(dstCV);\n";
finalInstruction += " dst = to_arma<unsigned char>(dstCV);\n";
}
}
return finalInstruction;
......
......@@ -65,6 +65,7 @@ public class InRangeCommand extends ArgumentNoReturnMathCommand{
bluePrintCPP.addCVIncludeString("ConvHelper");
bluePrint.addMethod(inRangeHelperMethod);
redefineArmaMat(bluePrintCPP);
redefineInit(bluePrintCPP);
}
......@@ -74,23 +75,27 @@ public class InRangeCommand extends ArgumentNoReturnMathCommand{
String typeNameIn = "";
String typeNameOut = "";
if(properties.isPreCV()){
typeNameIn = "cv::Mat";
} else {
typeNameIn = "cube";
typeNameIn = "Cube<unsigned char>";
}
if(properties.isSucCV()){
typeNameOut = "cv::Mat";
}else {
typeNameOut = "arma::mat";
typeNameOut = "arma::Mat<unsigned char>";
}
String typeNameInConst = "const " + typeNameIn +"&";
String typeNameOutRef = typeNameOut + "&";
//add parameters
Variable src = new Variable();
method.addParameter(src, "src", "CommonMatrix", typeNameIn, "");;
method.addParameter(src, "src", "CommonMatrix", typeNameInConst, "");;
Variable dst = new Variable();
method.addParameter(dst, "dst", "CommonMatrixType", typeNameOut, "");
method.addParameter(dst, "dst", "CommonMatrixType", typeNameOutRef, "");
Variable lowerBoundary = new Variable();
method.addParameter(lowerBoundary, "lowerB", "colvec", "colvec", "" );
Variable upperBoundary = new Variable();
......@@ -115,19 +120,19 @@ public class InRangeCommand extends ArgumentNoReturnMathCommand{
finalInstruction += " cv::Mat dstCV;\n" +
" cv::inRange(src, cv::Scalar(lowerB(0), lowerB(1), lowerB(2)),\n" +
" cv::Scalar(upperB(0), upperB(1), upperB(2)), dstCV);\n" +
" dst = ConvHelper::to_arma(dstCV);\n";
" dst = to_arma<unsigned char>(dstCV);\n";
} else if (properties.isSucCV()) {
finalInstruction += " cv::Mat srcCV;\n" +
" srcCV = ConvHelper::to_cvmat(src);\n" +
" srcCV = to_cvmat<unsigned char>(src);\n" +
" cv::inRange(srcCV, cv::Scalar(lowerB(0), lowerB(1), lowerB(2)),\n" +
" cv::Scalar(upperB(0), upperB(1), upperB(2)), dst);\n";
} else {
finalInstruction += " cv::Mat srcCV;\n" +
" cv::Mat dstCV;\n" +
" srcCV = ConvHelper::to_cvmat(src);\n" +
" srcCV = to_cvmat<unsigned char>(src);\n" +
" cv::inRange(srcCV, cv::Scalar(lowerB(0), lowerB(1), lowerB(2)),\n" +
" cv::Scalar(upperB(0), upperB(1), upperB(2)), dstCV);\n" +
" dst = ConvHelper::to_arma(dstCV);\n";
" dst = to_arma<unsigned char>(dstCV);\n";
}
return finalInstruction;
}
......
......@@ -63,15 +63,17 @@ public class LargestContourCommand extends MathCommand {
mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().setMathMatrixAccessSymbols(newMatrixAccessSymbols);
bluePrintCPP.addCVIncludeString("opencv2/imgproc");
bluePrint.addMethod(largestContourMethod);
redefineArmaMat(bluePrintCPP);
redefineInit(bluePrintCPP);
}
private Method getLargestContourMethod(){
Method method = new Method("largestContour", "vector<Point>");
Method method = new Method("largestContour", "std::vector<cv::Point>");
//add parameters
Variable contours = new Variable();
method.addParameter(contours, "contours", "double","vector <vector<Point>>", "");
method.addParameter(contours, "contours", "double","const std::vector <std::vector<cv::Point>>&", "");
//add an instruction to the method
method.addInstruction(methodBody());
......@@ -91,8 +93,7 @@ public class LargestContourCommand extends MathCommand {
" maxAreaContourId = j;\n" +
" }\n" +
" }\n" +
" return contours.at(getMaxAreaContourId(contours));\n" +
"}\n";
" return contours.at(maxAreaContourId);";
}
@Override
......
......@@ -127,29 +127,29 @@ public class RectangleCommand extends MathCommand{
finalInstruction = " cv::rectangle(src, rect.tl(), rect.br(), Scalar(color(0), color(1), color(2)), thickness, lineType);\n";
if(typeNameOut == "cube"){
finalInstruction += " arma::cube srcCube;\n" +
" srcCube = ConvHelper::to_armaCube(src);\n" +
" srcCube = to_armaCube<unsigned char, 3>(src);\n" +
" return srcCube;\n";
} else {
finalInstruction += " arma::mat srcArma;\n" +
" srcArma = ConvHelper::to_arma(src);\n" +
" srcArma = to_arma<unsigned char>(src);\n" +
" return srcArma;\n";
}
} else if(properties.isSucCV()){
finalInstruction = " cv::Mat srcCV;\n" +
" srcCV = ConvHelper::to_cvmat(src);\n" +
" srcCV = to_cvmat<unsigned char>(src);\n" +
" cv::rectangle(srcCV, rect.tl(), rect.br(), Scalar(color(0), color(1), color(2)), thickness, lineType);\n" +
" return srcCV;\n";
} else {
finalInstruction = " cv::Mat srcCV;\n" +
" srcCV = ConvHelper::to_cvmat(src);\n" +
" srcCV = to_cvmat<unsigned char>(src);\n" +
" cv::rectangle(srcCV, rect.tl(), rect.br(), Scalar(color(0), color(1), color(2)), thickness, lineType);\n";
if(typeNameOut == "cube"){
finalInstruction += " arma::cube srcCube;\n" +
" srcCube = to_armaCube(srcCV);\n" +
" srcCube = to_armaCube<unsigned char, 3>(srcCV);\n" +
" return srcCube;\n";
} else {
finalInstruction += " arma::mat srcArma;\n" +
" srcArma = to_arma(srcCV);\n" +
" srcArma = to_arma<unsigned char>(srcCV);\n" +
" return srcArma;\n";
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment