Commit 0668b1cc authored by Ahmed's avatar Ahmed

start enable mat conversion

parent d491f99b
......@@ -125,7 +125,6 @@ public class GeneratorCPP implements Generator {
public String generateString(TaggingResolver taggingResolver, EMAComponentInstanceSymbol componentInstanceSymbol, Scope symtab) {
MathStatementsSymbol mathSymbol = Helper.getMathStatementsSymbolFor(componentInstanceSymbol, symtab);
/// FIXME: 20/12/2019 go inside getMathStatement to consider how to determinte the expression type
return generateString(taggingResolver, componentInstanceSymbol, mathSymbol);
}
......
......@@ -86,6 +86,7 @@ public class LanguageUnitCPP extends LanguageUnit {
"#endif\n";
List<String> alreadyGeneratedIncludes = new ArrayList<>();
List<String> alreadyGeneratedCVIncludes = new ArrayList<>();
//includes
//add default include
String backendName = MathConverter.curBackend.getBackendName();
......@@ -122,13 +123,16 @@ public class LanguageUnitCPP extends LanguageUnit {
for (String string : bluePrint.getAdditionalIncludeStrings())
resultString += "#include \"" + string + ".h\"\n";
for(String string: bluePrint.getCVIncludeStrings())
if(string.contains("vector")){
resultString += "#include <" + string +">\n";
}else if(string.contains("ConvHelper")){
resultString += "#include \"" + "ConvHelper" + ".h\"\n";
} else {
resultString += "#include \"" + string + ".hpp\"\n";
for(String includeName: bluePrint.getCVIncludeStrings())
if(!alreadyGeneratedCVIncludes.contains(includeName)) {
alreadyGeneratedCVIncludes.add(includeName);
if (includeName.contains("vector")) {
resultString += "#include <" + includeName + ">\n";
} else if (includeName.contains("ConvHelper")) {
resultString += "#include \"" + "ConvHelper" + ".h\"\n";
} else {
resultString += "#include \"" + includeName + ".hpp\"\n";
}
}
if (generatorCPP.isExecutionLoggingActive)
resultString += "#include <fstream>\n";
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.generator.cpp;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._ast.ASTSubComponent;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.InstanceInformation;
import de.monticore.lang.monticar.generator.BluePrint;
import de.monticore.lang.monticar.generator.Instruction;
import de.monticore.lang.monticar.generator.Variable;
import de.monticore.lang.monticar.resolution._ast.ASTUnitNumberResolution;
import de.monticore.lang.monticar.si._symboltable.ResolutionDeclarationSymbol;
import de.se_rwth.commons.logging.Log;
import java.util.ArrayList;
import java.util.List;
/**
* @author Ahmed Diab
*/
public class MathExpressionProperties {
public Level pre = Level.ARMA;
public Level succ = Level.ARMA;
enum Level {
CV,
ARMA
}
/*public MathExpressionProperties(String name) {
(name);
}*/
}
......@@ -60,7 +60,7 @@ public class ErodeCommand extends ArgumentNoReturnMathCommand{
mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().setMathMatrixAccessSymbols(newMatrixAccessSymbols);
bluePrintCPP.addCVIncludeString("opencv2/imgproc");
bluePrintCPP.addAdditionalIncludeString("ConvHelper");
bluePrintCPP.addCVIncludeString("ConvHelper");
bluePrint.addMethod(erodeHelperMethod);
}
......
......@@ -40,7 +40,6 @@ public class ComponentConverter {
bluePrint.setGenerator(generatorCPP);
bluePrint.setOriginalSymbol(componentSymbol);
bluePrint.addDefineGenerics(componentSymbol);
// Hint: the variables will be added here to the BluePrint
addVariables(componentSymbol, bluePrint);
// ToDo: you can fix the variables type here or later, so before it will be used
BluePrintFixer.fixBluePrintDynamicVariableConnectRequestQueues(bluePrint);
......@@ -67,12 +66,19 @@ public class ComponentConverter {
MathInformationFilter.filterStaticInformation(componentSymbol, bluePrint, mathStatementsSymbol, generatorCPP, includeStrings);
//save function name
if(mathStatementsSymbol != null) {
HashMap<MathExpressionSymbol, MathExpressionProperties> tuples = new HashMap<MathExpressionSymbol, MathExpressionProperties>();
List<MathExpressionSymbol> mathExpressionSymbols = mathStatementsSymbol.getMathExpressionSymbols();
for(MathExpressionSymbol mathExpressionSymbol : mathExpressionSymbols){
String nameOfFunction = getNameOfMathCommand(mathExpressionSymbol);
namesOfFunctions.add(nameOfFunction);
fixFunctionTypes(nameOfFunction, mathExpressionSymbol, bluePrint);
}
for(MathExpressionSymbol mathExpressionSymbol : mathExpressionSymbols){
//MathExpressionProperties properties = new MathExpressionProperties();
//setPropertiesForMathExpression(mathExpressionSymbol, properties);
//tuples.put(mathExpressionSymbol, );
}
}
if(namesOfFunctions != null) {
for(String nameOfFunction : namesOfFunctions){
......
......@@ -4,11 +4,11 @@
#define M_PI 3.14159265358979323846
#endif
#include "armadillo"
#include "ConvHelper.h"
#include "opencv2/imgproc.hpp"
#include "ConvHelper.h"
#include <vector>
using namespace arma;
using namespace cv;
using namespace std;
class test_math_erodeAndGaussianBlurCommandTest{
public:
cube src;
......@@ -34,10 +34,10 @@ void erodeHelper(cube src, cube dst, int erosion_elem, int iterations)
else if( erosion_elem == 1 ){ erosion_type = MORPH_CROSS; }
else if( erosion_elem == 2) { erosion_type = MORPH_ELLIPSE; }
erosion_size = erosion_elem;
mat element = getStructuringElement( erosion_type,
mat element = cv::getStructuringElement( erosion_type,
Size( 2*erosion_size + 1, 2*erosion_size+1 ),
Point( -1, -1 ) );
erode( src, dst, element, Point(-1,-1), iterations );
cv::erode( src, dst, element, Point(-1,-1), iterations );
}
void dilateHelper(cube src, cube dst, int dilation_elem, int iterations)
{
......@@ -46,23 +46,23 @@ void dilateHelper(cube src, cube dst, int dilation_elem, int iterations)
else if( dilation_elem == 1 ){ dilation_type = MORPH_CROSS; }
else if( dilation_elem == 2) { dilation_type = MORPH_ELLIPSE; }
dilation_size = dilation_elem;
mat element = getStructuringElement( dilation_type,
mat element = cv::getStructuringElement( dilation_type,
Size( 2*dilation_size + 1, 2*dilation_size+1 ),
Point( -1, -1 ) );
dilate( src, dst, element, Point(-1,-1), iterations );
cv::dilate( src, dst, element, Point(-1,-1), iterations );
}
void execute()
{
erodeHelper(src, dst, erosion_elem, iterations);
cube dst2=cube(270,340,3);
erodeHelper(src, dst, erosion_elem, iterations);
erodeHelper(src, dst2, erosion_elem, iterations);
erodeHelper(src, dst, erosion_elem, iterations);
dilateHelper(dst, dst3, dilation_elem, iterations);
cube src4 = (det(src));
erodeHelper(src4, dst, erosion_elem, iterations);
erodeHelper(src, dst, erosion_elem, iterations);
dilateHelper(dst, dst3, dilation_elem, iterations);
findContours(dst3, contours, method, mode);
cv::findContours(dst3, contours, method, mode);
}
};
......
......@@ -18,7 +18,7 @@ component ErodeAndGaussianBlurCommandTest{
//Fall2
Q^{270,340,3} dst2;
dst = erode(src, erosion_elem, iterations);
dst2 = erode(src, erosion_elem, iterations);
//Fall3 a pre-cv and suc-cv
dst = erode(src, erosion_elem, iterations);
......
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