Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix various issues with generated C++ #798

Merged
merged 7 commits into from
Jan 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
\#include <String>
#end
#if($implementVisionPipeline)
\#include "VisionPipeline.h"
\#include "vision/VisionPipeline.h"

#end
\#include <opencv2/objdetect/objdetect.hpp>
\#include <opencv2/highgui/highgui.hpp>
\#include <opencv2/imgproc/imgproc.hpp>
\#include <opencv2/contrib/contrib.hpp>
\#include <opencv2/core/core.hpp>
\#include <opencv2/features2d.hpp>
\#include <iostream>
Expand All @@ -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")
Expand Down Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
@@ -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))
Expand Down Expand Up @@ -53,32 +47,16 @@ $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")

#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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
params.maxCircularity = circularity[1];
params.filterByConvexity = false;
params.filterByInertia = false;
cv::Ptr<cv::SimpleBlobDetector> detector = SimpleBlobDetector::create(params);
cv::Ptr<cv::SimpleBlobDetector> detector = cv::SimpleBlobDetector::create(params);
detector->detect(input, blobList);
}