diff --git a/ui/src/main/java/edu/wpi/grip/ui/codegeneration/CppTMethods.java b/ui/src/main/java/edu/wpi/grip/ui/codegeneration/CppTMethods.java index 540b720f36..dfe5e3fc73 100644 --- a/ui/src/main/java/edu/wpi/grip/ui/codegeneration/CppTMethods.java +++ b/ui/src/main/java/edu/wpi/grip/ui/codegeneration/CppTMethods.java @@ -5,6 +5,8 @@ import com.google.common.base.CaseFormat; +import org.apache.commons.lang3.text.WordUtils; + public class CppTMethods extends TemplateMethods { public CppTMethods() { super(); @@ -17,7 +19,7 @@ public String name(String name) { @Override public String getterName(String name) { - return "get" + name(name); + return "Get" + WordUtils.capitalize(name(name)); } @Override diff --git a/ui/src/main/resources/edu/wpi/grip/ui/codegeneration/cpp/Pipeline.h.vm b/ui/src/main/resources/edu/wpi/grip/ui/codegeneration/cpp/Pipeline.h.vm index 411d58b2e3..1d460a26fc 100644 --- a/ui/src/main/resources/edu/wpi/grip/ui/codegeneration/cpp/Pipeline.h.vm +++ b/ui/src/main/resources/edu/wpi/grip/ui/codegeneration/cpp/Pipeline.h.vm @@ -5,13 +5,12 @@ \#include #end #if($implementVisionPipeline) -\#include "VisionPipeline.h" +\#include "vision/VisionPipeline.h" #end \#include \#include \#include -\#include \#include \#include \#include @@ -35,7 +34,7 @@ namespace grip { * * An OpenCV pipeline generated by GRIP. */ -class $className #if($testing or $implementVisionPipeline):#if($testing) public AbsPipeline #else public VisionPipeline #end#end{ +class $className #if($testing or $implementVisionPipeline):#if($testing) public AbsPipeline #else public frc::VisionPipeline #end#end{ private: #foreach($step in $pipeline.getSteps()) #if($step.name() == "Switch" || $step.name() == "Valve") @@ -63,7 +62,7 @@ class $className #if($testing or $implementVisionPipeline):#if($testing) public public: $className(); - void process(#foreach($source in $pipeline.getSources())#cType($source.type()) $source.value()#if($pipeline.getSources().indexOf($source) lt $pipeline.getSources().size() - 1), #end#end); + void Process(#foreach($source in $pipeline.getSources())#cType($source.type())& $source.value()#if($pipeline.getSources().indexOf($source) lt $pipeline.getSources().size() - 1), #end#end)#if($implementVisionPipeline) override#end; #foreach($step in $pipeline.getSteps()) #if($step.name() == "Switch" || $step.name() == "Valve") #set($boolInp = $step.getInput(0)) diff --git a/ui/src/main/resources/edu/wpi/grip/ui/codegeneration/cpp/Pipeline.vm b/ui/src/main/resources/edu/wpi/grip/ui/codegeneration/cpp/Pipeline.vm index 5bb86be17c..5b5b4fbf22 100644 --- a/ui/src/main/resources/edu/wpi/grip/ui/codegeneration/cpp/Pipeline.vm +++ b/ui/src/main/resources/edu/wpi/grip/ui/codegeneration/cpp/Pipeline.vm @@ -1,14 +1,8 @@ \#include "${className}.h" -/** -* Initializes a ${className}. -*/ namespace grip { $className::$className() { -#foreach($source in $pipeline.getSources()) -## this->$source.value() = new #cType($source.type())(); -#end #foreach($step in $pipeline.getSteps()) #if($step.name() == "Switch" || $step.name() == "Valve") #set($boolInp = $step.getInput(0)) @@ -53,12 +47,9 @@ $className::$className() { #end } /** -* Runs an iteration of the Pipeline and updates outputs. -* -* Sources need to be set before calling this method. -* +* Runs an iteration of the pipeline and updates outputs. */ -void $className::process(#foreach($source in $pipeline.getSources())#cType($source.type()) $source.value()#if($pipeline.getSources().indexOf($source) lt $pipeline.getSources().size() - 1), #end#end){ +void $className::Process(#foreach($source in $pipeline.getSources())#cType($source.type())& $source.value()#if($pipeline.getSources().indexOf($source) lt $pipeline.getSources().size() - 1), #end#end){ #foreach($step in $pipeline.getSteps()) //Step $step.name()$step.num(): #parse("$vmLoc/Step.vm") @@ -66,19 +57,6 @@ void $className::process(#foreach($source in $pipeline.getSources())#cType($sour #end } -#foreach($source in $pipeline.getSources()) -/** - * This method is a generated setter for $source.value(). - * @param source the $source.type() to set - */ -void $className::set${source.value()}(#cType(${source.type()}) #funPassType($source.type())${source.value()}){ -#if($source.type().equals("Mat")) - ${source.value()}.copyTo(this->${source.value()}); -#else - this->$source.value() = ${source.value()}; -#end -} -#end #foreach($step in $pipeline.getSteps()) #if($step.name() == "Switch" || $step.name() == "Valve") #set($boolInp = $step.getInput(0)) diff --git a/ui/src/main/resources/edu/wpi/grip/ui/codegeneration/cpp/operations/Filter_Contours.vm b/ui/src/main/resources/edu/wpi/grip/ui/codegeneration/cpp/operations/Filter_Contours.vm index 7370ffaa79..64b90b93f8 100644 --- a/ui/src/main/resources/edu/wpi/grip/ui/codegeneration/cpp/operations/Filter_Contours.vm +++ b/ui/src/main/resources/edu/wpi/grip/ui/codegeneration/cpp/operations/Filter_Contours.vm @@ -31,7 +31,7 @@ This creates the C++ OpenCV Filter Contours function double solid = 100 * area / cv::contourArea(hull); if (solid < solidity[0] || solid > solidity[1]) continue; if (contour.size() < minVertexCount || contour.size() > maxVertexCount) continue; - double ratio = bb.width / bb.height; + double ratio = (double) bb.width / (double) bb.height; if (ratio < minRatio || ratio > maxRatio) continue; output.push_back(contour); } diff --git a/ui/src/main/resources/edu/wpi/grip/ui/codegeneration/cpp/operations/Find_Blobs.vm b/ui/src/main/resources/edu/wpi/grip/ui/codegeneration/cpp/operations/Find_Blobs.vm index 4c0372718a..cc1cb7a74f 100644 --- a/ui/src/main/resources/edu/wpi/grip/ui/codegeneration/cpp/operations/Find_Blobs.vm +++ b/ui/src/main/resources/edu/wpi/grip/ui/codegeneration/cpp/operations/Find_Blobs.vm @@ -23,6 +23,6 @@ params.maxCircularity = circularity[1]; params.filterByConvexity = false; params.filterByInertia = false; - cv::Ptr detector = SimpleBlobDetector::create(params); + cv::Ptr detector = cv::SimpleBlobDetector::create(params); detector->detect(input, blobList); }