Commit 12bf3bd9 authored by Ahmed's avatar Ahmed

fix some bugs

parent 9ab6497a
......@@ -41,8 +41,4 @@ public class MathExpressionProperties {
public boolean isSucCV(){
return this.suc == Level.CV;
}
/*public MathExpressionProperties(String name) {
(name);
}*/
}
......@@ -26,6 +26,11 @@ import java.util.*;
import java.util.stream.Collectors;
/**
<<<<<<< master
=======
* @author Sascha Schneiders
* @author Ahmed Diab
>>>>>>> fix some bugs
* Handles code generation for a component and its "subsymbols"
*/
public class ComponentConverter {
......@@ -33,7 +38,7 @@ public class ComponentConverter {
public static BluePrintCPP currentBluePrint = null;
public static List<String> namesOfFunctions = new ArrayList<>();
public static List<MathCommand> usedMathCommand = new ArrayList<>();
public static HashMap<MathExpressionSymbol, MathExpressionProperties> tuples = new HashMap<MathExpressionSymbol, MathExpressionProperties>();
public static HashMap<MathExpressionSymbol, MathExpressionProperties> tuples = new HashMap<>();
public static BluePrint convertComponentSymbolToBluePrint(EMAComponentInstanceSymbol componentSymbol, MathStatementsSymbol mathStatementsSymbol, List<String> includeStrings, GeneratorCPP generatorCPP) {
BluePrintCPP bluePrint = new BluePrintCPP(GeneralHelperMethods.getTargetLanguageComponentName(componentSymbol.getFullName()));
......@@ -63,19 +68,17 @@ public class ComponentConverter {
}
//create arrays from variables that only differ at the end by _number_
BluePrintFixer.fixBluePrintVariableArrays(bluePrint);
//ToDo: add bluePrintFixer.fixBluePrintCvVariableArrays;
MathInformationFilter.filterStaticInformation(componentSymbol, bluePrint, mathStatementsSymbol, generatorCPP, includeStrings);
//save function name
//save functions names
if(mathStatementsSymbol != null) {
List<MathExpressionSymbol> mathExpressionSymbols = mathStatementsSymbol.getMathExpressionSymbols();
for(MathExpressionSymbol mathExpressionSymbol : mathExpressionSymbols){
String nameOfFunction = getNameOfMathCommand(mathExpressionSymbol);
namesOfFunctions.add(nameOfFunction);
fixFunctionTypes(nameOfFunction, mathExpressionSymbol, bluePrint);
}
if(mathExpressionSymbols.size() > 1) {
if(mathExpressionSymbols.size() >= 1) {
for (MathExpressionSymbol mathExpressionSymbol : mathExpressionSymbols) {
MathExpressionProperties properties = new MathExpressionProperties();
MathConverter.setPropertiesForMathExpression(mathExpressionSymbols, mathExpressionSymbol, bluePrint, properties);
......@@ -88,26 +91,11 @@ public class ComponentConverter {
} else{
ComponentConverter.tuples.put(mathExpressionSymbol, properties);
}
}
} else if(mathExpressionSymbols.size() == 1){
MathExpressionProperties properties = new MathExpressionProperties();
MathExpressionSymbol mathExpressionSymbol = mathExpressionSymbols.get(0);
if(mathExpressionSymbol.isAssignmentExpression() && ((MathAssignmentExpressionSymbol)mathExpressionSymbol).getExpressionSymbol().isMatrixExpression()){
MathMatrixExpressionSymbol mathMatrixExpressionSymbol = (MathMatrixExpressionSymbol) ((MathAssignmentExpressionSymbol)mathExpressionSymbol).getExpressionSymbol();
if(mathMatrixExpressionSymbol.isMatrixNameExpression()) {
MathMatrixNameExpressionSymbol mathMatrixNameExpressionSymbol = (MathMatrixNameExpressionSymbol) ((MathAssignmentExpressionSymbol) mathExpressionSymbol).getExpressionSymbol();
ComponentConverter.tuples.put(mathMatrixNameExpressionSymbol, properties);
}
} else{
ComponentConverter.tuples.put(mathExpressionSymbol, properties);
}
}
redefineVariables(mathExpressionSymbols, bluePrint);
}
//ToDo Redefine Function
if(namesOfFunctions != null) {
for(String nameOfFunction : namesOfFunctions){
usedMathCommand.add(bluePrint.getMathCommandRegister().getMathCommand(nameOfFunction));
......@@ -153,19 +141,8 @@ public class ComponentConverter {
bluePrint.getMathInformationRegister().addVariable(var);
var.setIsParameterVariable(true);
}
Collection<EMAComponentInstanceSymbol> subcomponents = componentSymbol.getSubComponents();
Collection<EMAPortInstanceSymbol> incomingPorts = componentSymbol.getIncomingPortInstances();
Collection<EMAPortInstanceSymbol> outcomingPorts = componentSymbol.getOutgoingPortInstances();
Collection<EMAComponentInstanceSymbol> intdependents = componentSymbol.getIndependentSubComponents();
Optional<InstanceInformation> infos = componentSymbol.getInstanceInformation();
Collection<EMAConnectorInstanceSymbol> connectors = componentSymbol.getConnectorInstances();
List<EMAVariable> parameters = componentSymbol.getParameters();
Optional<EMAComponentInstanceSymbol> parent = componentSymbol.getParent();
Collection<EMAPortInstanceSymbol> ports = componentSymbol.getPortInstanceList();
List<ASTExpression> expressions = componentSymbol.getArguments();
//add ports as variables to blueprint
//add ports as variables to blueprint
for (EMAPortInstanceSymbol port : componentSymbol.getPortInstanceList()) {
//Config ports might already be added from adaptable Parameters
if(!port.isConfig()) {
......@@ -423,8 +400,7 @@ public class ComponentConverter {
MathMatrixNameExpressionSymbol mathMatrixNameExpressionSymbol = (MathMatrixNameExpressionSymbol) ((MathAssignmentExpressionSymbol) mathExpressionSymbol).getExpressionSymbol();
String nameOfFirstParameter = mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().getMathMatrixAccessSymbols().get(0).getTextualRepresentation();
String nameOfOutput = getNameOfOutput(mathExpressionSymbol);
MathExpressionProperties properties = tuples.get(mathExpressionSymbol);
MathExpressionProperties properties = tuples.get(mathMatrixNameExpressionSymbol);
if (properties != null) {
if (properties.isPreCV()) {
fixVariableType(nameOfFirstParameter, bluePrintCPP, "CommonMatrixType", "cv::Mat", "");
......
......@@ -190,7 +190,6 @@ public class MathConverter {
setPrePropertyForMathExpression(mathExpressionSymbols,mathExpressionSymbol, bluePrint, indexOfCurrentMathExpression, properties);
setSucPropertyForMathExpression(mathExpressionSymbols, mathExpressionSymbol, bluePrint, indexOfCurrentMathExpression, properties);
}
}
public static void setPrePropertyForMathExpression(List<MathExpressionSymbol> mathExpressionSymbols, MathExpressionSymbol currentMathExpressionSymbol, BluePrintCPP bluePrint, int currentMathExpressionIndex, MathExpressionProperties properties){
......
......@@ -15,7 +15,8 @@ Cube<unsigned char> src;
int erosion_elemIn;
colvec sizeY;
colvec two;
Cube<unsigned char> dst;
cv::Mat dst;
cv::Mat dst3;
Cube<unsigned char> outMatrix;
arma::Mat<unsigned char> out2Matrix;
void init()
......@@ -23,7 +24,6 @@ void init()
src = cube(n, m, 3);
sizeY=colvec(3);
two=colvec(2);
dst = cube(n, m, 3);
outMatrix = cube(3, n, m);
out2Matrix=Mat<unsigned char>(2,m);
}
......@@ -60,16 +60,10 @@ void findContoursHelper(const cv::Mat& image, std::vector<std::vector<cv::Point>
void execute()
{
erodeHelper(src, dst, erosion_elem, iterations);
cube dst2=cube(270,340,3);
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);
findContoursHelper(dst3, contours, method, mode);
findContoursHelper(dst3, contours);
}
};
#endif
......@@ -8,29 +8,15 @@ component ErodeAndGaussianBlurCommandTest{
in Q^{3} sizeY,
in Q^{2} two,
out Q^{n,m,3} dst,
out Q^{n,m,3} dst3,
out Q^{3,n,m} outMatrix,
out Q^{2,m} out2Matrix;
implementation Math{
//Fall1 no pre-cv and no suc-cv
dst = erode(src, erosion_elem, iterations);
//Fall2
Q^{270,340,3} dst2;
dst2 = erode(src, erosion_elem, iterations);
//Fall3 a pre-cv and suc-cv
dst = erode(src, erosion_elem, iterations);
dst3 = dilate(dst, dilation_elem, iterations);
contours = findContours(dst3);
//Fall4
Q^{240, 340, 3} src4 = det(src);
dst = erode(src4, erosion_elem, iterations);
//Fall5
dst = erode(src, erosion_elem, iterations);
dst3 = dilate(dst, dilation_elem, iterations);
contours = findContours(dst3, method, mode);
}
}
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