Commit d491f99b authored by Ahmed's avatar Ahmed

delete namespace cv

delete namespace cv and add cv for every function
parent 8f421ba4
......@@ -125,7 +125,9 @@ public class LanguageUnitCPP extends LanguageUnit {
for(String string: bluePrint.getCVIncludeStrings())
if(string.contains("vector")){
resultString += "#include <" + string +">\n";
}else {
}else if(string.contains("ConvHelper")){
resultString += "#include \"" + "ConvHelper" + ".h\"\n";
} else {
resultString += "#include \"" + string + ".hpp\"\n";
}
if (generatorCPP.isExecutionLoggingActive)
......@@ -145,8 +147,8 @@ public class LanguageUnitCPP extends LanguageUnit {
}
if(!bluePrint.cvIncludeStrings.isEmpty()){
resultString += "using namespace cv;\n";
}//TODO add here using namespace std;
resultString += "using namespace std;\n";
}
//class definition start
resultString += "class " + bluePrint.getName();
......
......@@ -59,11 +59,11 @@ public class BoundingRectCommand extends MathCommand{
valueListString += ExecuteMethodGenerator.generateExecuteCode(mathExpressionSymbol, new ArrayList<String>());
List<MathMatrixAccessSymbol> newMatrixAccessSymbols = new ArrayList<>();
MathStringExpression stringExpression = new MathStringExpression("boundingRect" + valueListString,mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().getMathMatrixAccessSymbols());
MathStringExpression stringExpression = new MathStringExpression("cv::boundingRect" + valueListString,mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().getMathMatrixAccessSymbols());
newMatrixAccessSymbols.add(new MathMatrixAccessSymbol(stringExpression));
mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().setMathMatrixAccessSymbols(newMatrixAccessSymbols);
((BluePrintCPP) bluePrint).addCVIncludeString("opencv2/imgproc");
bluePrintCPP.addCVIncludeString("opencv2/imgproc");
}
}
......@@ -47,16 +47,18 @@ public class CvtColorCommand extends ArgumentNoReturnMathCommand{
MathMatrixNameExpressionSymbol mathMatrixNameExpressionSymbol = (MathMatrixNameExpressionSymbol) mathExpressionSymbol;
mathMatrixNameExpressionSymbol.setNameToAccess("");
BluePrintCPP bluePrintCPP = (BluePrintCPP) bluePrint;
String valueListString = "";
for (MathMatrixAccessSymbol accessSymbol : mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().getMathMatrixAccessSymbols())
MathFunctionFixer.fixMathFunctions(accessSymbol, (BluePrintCPP) bluePrint);
MathFunctionFixer.fixMathFunctions(accessSymbol, bluePrintCPP);
valueListString += ExecuteMethodGenerator.generateExecuteCode(mathExpressionSymbol, new ArrayList<String>());
List<MathMatrixAccessSymbol> newMatrixAccessSymbols = new ArrayList<>();
MathStringExpression stringExpression = new MathStringExpression("cvtColor" + valueListString,mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().getMathMatrixAccessSymbols());
MathStringExpression stringExpression = new MathStringExpression("cv::cvtColor" + valueListString,mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().getMathMatrixAccessSymbols());
newMatrixAccessSymbols.add(new MathMatrixAccessSymbol(stringExpression));
mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().setMathMatrixAccessSymbols(newMatrixAccessSymbols);
((BluePrintCPP) bluePrint).addCVIncludeString("opencv2/imgproc");
bluePrintCPP.addCVIncludeString("opencv2/imgproc");
bluePrintCPP.addCVIncludeString("ConvHelper");
}
}
......@@ -46,18 +46,20 @@ public class DilateCommand extends ArgumentNoReturnMathCommand{
MathMatrixNameExpressionSymbol mathMatrixNameExpressionSymbol = (MathMatrixNameExpressionSymbol) mathExpressionSymbol;
mathMatrixNameExpressionSymbol.setNameToAccess("");
BluePrintCPP bluePrintCPP = (BluePrintCPP) bluePrint;
String valueListString = "";
for (MathMatrixAccessSymbol accessSymbol : mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().getMathMatrixAccessSymbols())
MathFunctionFixer.fixMathFunctions(accessSymbol, (BluePrintCPP) bluePrint);
MathFunctionFixer.fixMathFunctions(accessSymbol, bluePrintCPP);
Method dilateHelperMethod = getDilateHelperMethod(mathMatrixNameExpressionSymbol, (BluePrintCPP) bluePrint);
Method dilateHelperMethod = getDilateHelperMethod(mathMatrixNameExpressionSymbol, bluePrintCPP);
valueListString += ExecuteMethodGenerator.generateExecuteCode(mathExpressionSymbol, new ArrayList<String>());
List<MathMatrixAccessSymbol> newMatrixAccessSymbols = new ArrayList<>();
MathStringExpression stringExpression = new MathStringExpression("dilateHelper" + valueListString,mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().getMathMatrixAccessSymbols());
newMatrixAccessSymbols.add(new MathMatrixAccessSymbol(stringExpression));
mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().setMathMatrixAccessSymbols(newMatrixAccessSymbols);
((BluePrintCPP) bluePrint).addCVIncludeString("opencv2/imgproc");
bluePrintCPP.addCVIncludeString("opencv2/imgproc");
bluePrintCPP.addCVIncludeString("ConvHelper");
bluePrint.addMethod(dilateHelperMethod);
}
......@@ -95,10 +97,10 @@ public class DilateCommand extends ArgumentNoReturnMathCommand{
" 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" +
" mat element = getStructuringElement( dilation_type,\n" +
" mat element = cv::getStructuringElement( dilation_type,\n" +
" Size( 2*dilation_size + 1, 2*dilation_size+1 ),\n" +
" Point( -1, -1 ) );\n" +
" dilate( src, dst, element, Point(-1,-1), iterations );\n";
" cv::dilate( src, dst, element, Point(-1,-1), iterations );\n";
}
@Override
......
......@@ -97,10 +97,10 @@ public class ErodeCommand extends ArgumentNoReturnMathCommand{
" else if( erosion_elem == 1 ){ erosion_type = MORPH_CROSS; }\n" +
" else if( erosion_elem == 2) { erosion_type = MORPH_ELLIPSE; }\n" +
" erosion_size = erosion_elem;\n" +
" mat element = getStructuringElement( erosion_type,\n" +
" mat element = cv::getStructuringElement( erosion_type,\n" +
" Size( 2*erosion_size + 1, 2*erosion_size+1 ),\n" +
" Point( -1, -1 ) );\n" +
" erode( src, dst, element, Point(-1,-1), iterations );\n";
" cv::erode( src, dst, element, Point(-1,-1), iterations );\n";
}
@Override
......
......@@ -47,17 +47,19 @@ public class FindContoursCommand extends ArgumentNoReturnMathCommand{
MathMatrixNameExpressionSymbol mathMatrixNameExpressionSymbol = (MathMatrixNameExpressionSymbol) mathExpressionSymbol;
mathMatrixNameExpressionSymbol.setNameToAccess("");
BluePrintCPP bluePrintCPP = (BluePrintCPP) bluePrint;
String valueListString = "";
for (MathMatrixAccessSymbol accessSymbol : mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().getMathMatrixAccessSymbols())
MathFunctionFixer.fixMathFunctions(accessSymbol, (BluePrintCPP) bluePrint);
MathFunctionFixer.fixMathFunctions(accessSymbol, bluePrintCPP);
valueListString += ExecuteMethodGenerator.generateExecuteCode(mathExpressionSymbol, new ArrayList<String>());
List<MathMatrixAccessSymbol> newMatrixAccessSymbols = new ArrayList<>();
MathStringExpression stringExpression = new MathStringExpression("findContours" + valueListString,mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().getMathMatrixAccessSymbols());
MathStringExpression stringExpression = new MathStringExpression("cv::findContours" + valueListString,mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().getMathMatrixAccessSymbols());
newMatrixAccessSymbols.add(new MathMatrixAccessSymbol(stringExpression));
mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().setMathMatrixAccessSymbols(newMatrixAccessSymbols);
((BluePrintCPP) bluePrint).addCVIncludeString("opencv2/imgproc");
((BluePrintCPP) bluePrint).addCVIncludeString("vector");
bluePrintCPP.addCVIncludeString("opencv2/imgproc");
bluePrintCPP.addCVIncludeString("ConvHelper");
bluePrintCPP.addCVIncludeString("vector");
}
}
......@@ -47,18 +47,20 @@ public class GaussianBlurCommand extends ArgumentNoReturnMathCommand{
MathMatrixNameExpressionSymbol mathMatrixNameExpressionSymbol = (MathMatrixNameExpressionSymbol) mathExpressionSymbol;
mathMatrixNameExpressionSymbol.setNameToAccess("");
BluePrintCPP bluePrintCPP = (BluePrintCPP) bluePrint;
String valueListString = "";
for (MathMatrixAccessSymbol accessSymbol : mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().getMathMatrixAccessSymbols())
MathFunctionFixer.fixMathFunctions(accessSymbol, (BluePrintCPP) bluePrint);
MathFunctionFixer.fixMathFunctions(accessSymbol, bluePrintCPP);
Method gaussianBlurHelperMethod = getGaussianBlurHelperMethod(mathMatrixNameExpressionSymbol,(BluePrintCPP) bluePrint);
Method gaussianBlurHelperMethod = getGaussianBlurHelperMethod(mathMatrixNameExpressionSymbol,bluePrintCPP);
valueListString += ExecuteMethodGenerator.generateExecuteCode(mathExpressionSymbol, new ArrayList<String>());
List<MathMatrixAccessSymbol> newMatrixAccessSymbols = new ArrayList<>();
MathStringExpression stringExpression = new MathStringExpression("gaussianBlurHelper" + valueListString,mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().getMathMatrixAccessSymbols());
newMatrixAccessSymbols.add(new MathMatrixAccessSymbol(stringExpression));
mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().setMathMatrixAccessSymbols(newMatrixAccessSymbols);
((BluePrintCPP) bluePrint).addCVIncludeString("opencv2/imgproc");
bluePrintCPP.addCVIncludeString("opencv2/imgproc");
bluePrintCPP.addCVIncludeString("ConvHelper");
bluePrint.addMethod(gaussianBlurHelperMethod);
}
......@@ -96,7 +98,7 @@ public class GaussianBlurCommand extends ArgumentNoReturnMathCommand{
return new Instruction() {
@Override
public String getTargetLanguageInstruction() {
return " gaussianBlur(src, dst, Size(sizeX, sizeY), sigmaX, sigmaY);\n";
return " cv::gaussianBlur(src, dst, Size(sizeX, sizeY), sigmaX, sigmaY);\n";
}
@Override
......
......@@ -46,9 +46,10 @@ public class InRangeCommand extends ArgumentNoReturnMathCommand{
MathMatrixNameExpressionSymbol mathMatrixNameExpressionSymbol = (MathMatrixNameExpressionSymbol) mathExpressionSymbol;
mathMatrixNameExpressionSymbol.setNameToAccess("");
BluePrintCPP bluePrintCPP = (BluePrintCPP) bluePrint;
String valueListString = "";
for (MathMatrixAccessSymbol accessSymbol : mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().getMathMatrixAccessSymbols())
MathFunctionFixer.fixMathFunctions(accessSymbol, (BluePrintCPP) bluePrint);
MathFunctionFixer.fixMathFunctions(accessSymbol, bluePrintCPP);
Method inRangeHelperMethod = getInRangeHelperMethod();
valueListString += ExecuteMethodGenerator.generateExecuteCode(mathExpressionSymbol, new ArrayList<String>());
......@@ -57,7 +58,8 @@ public class InRangeCommand extends ArgumentNoReturnMathCommand{
newMatrixAccessSymbols.add(new MathMatrixAccessSymbol(stringExpression));
mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().setMathMatrixAccessSymbols(newMatrixAccessSymbols);
((BluePrintCPP) bluePrint).addCVIncludeString("opencv2/core");
bluePrintCPP.addCVIncludeString("opencv2/core");
bluePrintCPP.addCVIncludeString("ConvHelper");
bluePrint.addMethod(inRangeHelperMethod);
}
......@@ -84,7 +86,7 @@ public class InRangeCommand extends ArgumentNoReturnMathCommand{
return new Instruction() {
@Override
public String getTargetLanguageInstruction() {
return " inRange(src, Scalar(lowerB(0), lowerB(1), lowerB(2)),\n" +
return " cv::inRange(src, Scalar(lowerB(0), lowerB(1), lowerB(2)),\n" +
" Scalar(upperB(0), upperB(1), upperB(2)), dst);\n";
}
......
......@@ -61,7 +61,7 @@ public class LargestContourCommand extends MathCommand {
mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().setMathMatrixAccessSymbols(newMatrixAccessSymbols);
((BluePrintCPP) bluePrint).addCVIncludeString("opencv2/imgproc");
bluePrintCPP.addCVIncludeString("opencv2/imgproc");
bluePrint.addMethod(largestContourMethod);
}
......@@ -85,7 +85,7 @@ public class LargestContourCommand extends MathCommand {
return "double maxArea = 0;\n" +
"int maxAreaContourId = -1;\n" +
" for (int j = 0; j < contours.size(); j++) {\n" +
" double newArea = contourArea(contours.at(j));\n" +
" double newArea = cv::contourArea(contours.at(j));\n" +
" if (newArea > maxArea) {\n" +
" maxArea = newArea;\n" +
" maxAreaContourId = j;\n" +
......
......@@ -63,7 +63,8 @@ public class RectangleCommand extends MathCommand{
mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().setMathMatrixAccessSymbols(newMatrixAccessSymbols);
((BluePrintCPP) bluePrint).addCVIncludeString("opencv2/imgproc");
bluePrintCPP.addCVIncludeString("opencv2/imgproc");
bluePrintCPP.addCVIncludeString("ConvHelper");
bluePrint.addMethod(rectangleHelperMethod);
}
......
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