Commit 4fca5600 authored by Ahmed's avatar Ahmed

add including strings for cv

parent d147eb5f
......@@ -18,6 +18,7 @@ import java.util.List;
*/
public class BluePrintCPP extends BluePrint {
public List<String> additionalIncludeStrings = new ArrayList<>();
public List<String> cvIncludeStrings = new ArrayList<>();
public BluePrintCPP(String name) {
super(name);
......@@ -37,6 +38,19 @@ public class BluePrintCPP extends BluePrint {
return additionalIncludeStrings.contains(includeString);
}
public List<String> getCVIncludeStrings() {
return cvIncludeStrings;
}
public void addCVIncludeString(String includeString) {
if (!hasCVIncludeString(includeString))
cvIncludeStrings.add(includeString);
}
public boolean hasCVIncludeString(String includeString) {
return additionalIncludeStrings.contains(includeString);
}
public List<String> getConsts() {
List<String> consts = new ArrayList<>();
......
......@@ -99,26 +99,6 @@ public class LanguageUnitCPP extends LanguageUnit {
alreadyGeneratedIncludes.add(MathConverter.curBackend.getIncludeHeaderName());
}
List<String> cvImgprocCommands = Arrays.asList("dilate","erode", "cvtColor", "GaussianBlur", "threshold",
"findContours", "drawContours", "boundingRect", "putText", "circle");
List<String> cvCoreCommands = Arrays.asList("inRange");
// add iclude cv imgproc and cv core
String nameLowerCase = bluePrint.getName().toLowerCase();
boolean isUsedCV = false;
if (containsString(nameLowerCase, cvImgprocCommands)) {
resultString += "#include \"opencv2/imgproc.hpp\"\n";
alreadyGeneratedIncludes.add("opencv2/imgproc.hpp");
isUsedCV = true;
} else if(containsString(nameLowerCase, cvCoreCommands)){
resultString += "#include \"opencv2/core.hpp\"\n";
alreadyGeneratedIncludes.add("opencv2/core.hpp");
isUsedCV = true;
}
for (Variable v : bluePrint.getVariables()) {
//TODO remove multiple same includes
if (v.hasInclude()) {
......@@ -144,6 +124,8 @@ public class LanguageUnitCPP extends LanguageUnit {
for (String string : bluePrint.getAdditionalIncludeStrings())
resultString += "#include \"" + string + ".h\"\n";
for(String string: bluePrint.getCVIncludeStrings())
resultString += "#include \"" + string + ".hpp\"\n";
if (generatorCPP.isExecutionLoggingActive)
resultString += "#include <fstream>\n";
......@@ -160,7 +142,7 @@ public class LanguageUnitCPP extends LanguageUnit {
resultString += "using namespace arma;\n";
}
if(isUsedCV){
if(!bluePrint.cvIncludeStrings.isEmpty()){
resultString += "using namespace cv;\n";
}
......
......@@ -21,7 +21,6 @@ import java.util.List;
* @author Ahmed Diab.
*/
public abstract class ArgumentReturnMathCommand extends MathCommand{
//TODO rename to argumentReturnMathCommand
public ArgumentReturnMathCommand() {
}
......@@ -38,6 +37,7 @@ public abstract class ArgumentReturnMathCommand extends MathCommand{
return false;
}
@Override
public boolean isArgumentReturnMathCommand() {
return true;
}
......
......@@ -63,6 +63,7 @@ public class BoundingRectCommand extends MathCommand{
newMatrixAccessSymbols.add(new MathMatrixAccessSymbol(stringExpression));
mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().setMathMatrixAccessSymbols(newMatrixAccessSymbols);
((BluePrintCPP) bluePrint).addCVIncludeString("opencv2/imgproc");
}
}
......@@ -63,6 +63,7 @@ public class CircleCommand extends MathCommand{
newMatrixAccessSymbols.add(new MathMatrixAccessSymbol(stringExpression));
mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().setMathMatrixAccessSymbols(newMatrixAccessSymbols);
((BluePrintCPP) bluePrint).addCVIncludeString("opencv2/imgproc");
}
}
......@@ -63,6 +63,7 @@ public class CvtColorCommand extends MathCommand{
newMatrixAccessSymbols.add(new MathMatrixAccessSymbol(stringExpression));
mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().setMathMatrixAccessSymbols(newMatrixAccessSymbols);
((BluePrintCPP) bluePrint).addCVIncludeString("opencv2/imgproc");
}
}
......@@ -63,6 +63,7 @@ public class DilateCommand extends MathCommand{
newMatrixAccessSymbols.add(new MathMatrixAccessSymbol(stringExpression));
mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().setMathMatrixAccessSymbols(newMatrixAccessSymbols);
((BluePrintCPP) bluePrint).addCVIncludeString("opencv2/imgproc");
}
}
......@@ -63,6 +63,7 @@ public class DrawContoursCommand extends MathCommand{
newMatrixAccessSymbols.add(new MathMatrixAccessSymbol(stringExpression));
mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().setMathMatrixAccessSymbols(newMatrixAccessSymbols);
((BluePrintCPP) bluePrint).addCVIncludeString("opencv2/imgproc");
}
}
......@@ -48,7 +48,7 @@ public class ErodeCommand extends ArgumentReturnMathCommand{
newMatrixAccessSymbols.add(new MathMatrixAccessSymbol(stringExpression));
mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().setMathMatrixAccessSymbols(newMatrixAccessSymbols);
((BluePrintCPP) bluePrint).addAdditionalIncludeString("octave/builtin-defun-decls");
((BluePrintCPP) bluePrint).addCVIncludeString("opencv2/imgproc");
}
public void convertUsingArmadilloBackend(MathExpressionSymbol mathExpressionSymbol, BluePrint bluePrint) {
......@@ -65,6 +65,7 @@ public class ErodeCommand extends ArgumentReturnMathCommand{
mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().setMathMatrixAccessSymbols(newMatrixAccessSymbols);
((BluePrintCPP) bluePrint).addCVIncludeString("opencv2/imgproc");
}
}
......@@ -63,6 +63,7 @@ public class FindContoursCommand extends MathCommand{
newMatrixAccessSymbols.add(new MathMatrixAccessSymbol(stringExpression));
mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().setMathMatrixAccessSymbols(newMatrixAccessSymbols);
((BluePrintCPP) bluePrint).addCVIncludeString("opencv2/imgproc");
}
}
......@@ -63,6 +63,7 @@ public class GaussianBlurCommand extends MathCommand{
newMatrixAccessSymbols.add(new MathMatrixAccessSymbol(stringExpression));
mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().setMathMatrixAccessSymbols(newMatrixAccessSymbols);
((BluePrintCPP) bluePrint).addCVIncludeString("opencv2/imgproc");
}
}
......@@ -63,6 +63,7 @@ public class InRangeCommand extends MathCommand{
newMatrixAccessSymbols.add(new MathMatrixAccessSymbol(stringExpression));
mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().setMathMatrixAccessSymbols(newMatrixAccessSymbols);
((BluePrintCPP) bluePrint).addCVIncludeString("opencv2/core");
}
}
......@@ -63,6 +63,7 @@ public class PutTextCommand extends MathCommand{
newMatrixAccessSymbols.add(new MathMatrixAccessSymbol(stringExpression));
mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().setMathMatrixAccessSymbols(newMatrixAccessSymbols);
((BluePrintCPP) bluePrint).addCVIncludeString("opencv2/imgproc");
}
}
......@@ -63,6 +63,7 @@ public class ThresholdCommand extends MathCommand{
newMatrixAccessSymbols.add(new MathMatrixAccessSymbol(stringExpression));
mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().setMathMatrixAccessSymbols(newMatrixAccessSymbols);
((BluePrintCPP) bluePrint).addCVIncludeString("opencv2/imgproc");
}
}
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