Skip to content

Commit

Permalink
more config values and debug options
Browse files Browse the repository at this point in the history
  • Loading branch information
Niklas Pech committed Mar 31, 2014
1 parent 7818b07 commit 9751b09
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 32 deletions.
61 changes: 46 additions & 15 deletions buoy.orogen
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,19 @@ task_context "Detector" do

output_port("s_image", ro_ptr("base::samples::frame::Frame")).
doc("only for debugging")


output_port("v_image", ro_ptr("base::samples::frame::Frame")).
doc("only for debugging")
output_port("gray_debug_image", ro_ptr("base::samples::frame::Frame")).
doc("only for debugging")

output_port("hough_debug_image", ro_ptr("base::samples::frame::Frame")).
doc("only for debugging")

output_port("other_buoys","std::vector</avalon/feature/Buoy>").
doc("only for debugging")

output_port("light_image", ro_ptr("base::samples::frame::Frame")).
output_port("debug_image", ro_ptr("base::samples::frame::Frame")).
doc("the image which is shown in the light_image field in the debug-gui")


Expand All @@ -154,24 +162,46 @@ task_context "Detector" do

property("buoy_radius", "double", 0.05). #bei boye mit d=25cm ist wert von 0.05 realistisch. wieso?
doc("radius of the buoy in m")
#Properties for the Hough
property("hHoughAccumulatorThreshold", "int", 25).
doc("Hough threshold.")
property("sHoughAccumulatorThreshold", "int", 25).
doc("Hough threshold.")
property("vHoughAccumulatorThreshold", "int", 25).
doc("Hough threshold.")

property("houghTh", "int", 25).
property("hHoughEdgeThreshold", "int", 25).
doc("Hough threshold.")
property("sHoughEdgeThreshold", "int", 25).
doc("Hough threshold.")
property("vHoughEdgeThreshold", "int", 25).
doc("Hough threshold.")

property("hValue", "int", 65).
property("houghMinCircle", "int", 40).
doc("Buoy hue value.")

property("vValue", "int", 40).
property("houghMaxCircle", "int", 55).
doc("Buoy saturation value.")

#Property for the HSV
property("hValueMin", "int", 65).
doc("Buoy hue value.")
property("sValueMin", "int", 55).
doc("Buoy saturation value.")
property("vValueMin", "int", 40).
doc("Buoy hue value.")

property("sValue", "int", 55).

property("hValueMax", "int", 65).
doc("Buoy hue value.")
property("vValueMax", "int", 40).
doc("Buoy hue value.")
property("sValueMax", "int", 55).
doc("Buoy saturation value.")

property("steps", "int", 5).
doc("Step size to detect V value.")

property("edgeTh", "int", 35).
doc("Buoy V value.")
property("hSmooth", "int", 0)
property("sSmooth", "int", 0)
property("vSmooth", "int", 0)

property("debug_gui", "bool", true).
doc("Sets test mode.")
Expand All @@ -194,14 +224,15 @@ task_context "Detector" do
property("roi_height", "double", 3.0).
doc("for light detection: retion of interrest height")

property("val_th", "int", 254).
doc("")

property("sat_th", "int", 55).
doc("")

property("debug", "bool", 1).
doc("debugging or not?")
property("hsv_gray", "int", 0)
property("hough_debug_h", "bool", 0)
property("hough_debug_s", "bool", 0)
property("hough_debug_v", "bool", 0)


port_driven("frame")
end
Expand Down
4 changes: 2 additions & 2 deletions scripts/debug_gui/run_log.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env ruby
# -*- coding: utf-8 -*-

require 'buoy_detector.rb'
require './buoy_detector.rb'
require 'orocos/log'
#require 'type_specialize'

Expand All @@ -16,7 +16,7 @@
puts "No Log File in use"
exit 1
end
Orocos.run ("buoy_test" => nil, :wait => 20) do
Orocos.run ("buoy_test") do
#Orocos.log_all_ports
detector = Orocos::TaskContext.get "buoy_detector"
log = Orocos::Log::Replay.open(ARGV[0], Typelib::Registry.new)
Expand Down
9 changes: 6 additions & 3 deletions scripts/livetest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require 'vizkit'
include Orocos

Orocos::CORBA.name_service = "192.168.128.51"
#Orocos::CORBA.name_service = "192.168.128.51"


Orocos.initialize
Expand All @@ -19,11 +19,14 @@
camera.frame.connect_to detector.frame
detector.buoy.connect_to survey.input_buoy

#detector.sValue = 170


detector.configure
detector.start

survey.configure
survey.start
#survey.configure
#survey.start

Vizkit.display camera.frame

Expand Down
79 changes: 68 additions & 11 deletions tasks/Detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@ using namespace buoy;
Detector::Detector(std::string const& name, TaskCore::TaskState initial_state)
: DetectorBase(name, initial_state)
{
std::cout <<"init" << std::endl;
// h_frame = new base::samples::frame::Frame();
// s_frame = new base::samples::frame::Frame();
// h_frame.init(0,0,8,base::samples::frame::MODE_GRAYSCALE);
// s_frame.init(0,0,8,base::samples::frame::MODE_GRAYSCALE);
hframe.reset(new base::samples::frame::Frame());
sframe.reset(new base::samples::frame::Frame());
lframe.reset(new base::samples::frame::Frame());
vframe.reset(new base::samples::frame::Frame());
grayframe.reset(new base::samples::frame::Frame());
houghframe.reset(new base::samples::frame::Frame());
debugframe.reset(new base::samples::frame::Frame());
}

Detector::Detector(std::string const& name, RTT::ExecutionEngine* engine, TaskCore::TaskState initial_state)
Expand All @@ -49,12 +53,14 @@ Detector::~Detector()

bool Detector::configureHook()
{
std::cout <<"configure" << std::endl;
if (! DetectorBase::configureHook())
return false;
return true;
}
bool Detector::startHook()
{
std::cout <<"start" << std::endl;
if (!DetectorBase::startHook()){
std::cout<<"startHook: FALSE"<<std::endl;
return false;
Expand All @@ -68,8 +74,6 @@ bool Detector::startHook()
current_state=NO_BUOY_FOUND;
state(current_state);

detector.configureHoughThreshold(_houghTh);
// detector.configureEdgeThreshold(edgeTh);servoing_rbs

filter.setBufferSize(buoys_buffer_size);
filter.setMinSize(buoys_buffer_size_min);
Expand All @@ -83,6 +87,29 @@ bool Detector::startHook()

void Detector::updateHook()
{
std::cout <<"update" << std::endl;
std::cout <<"configure" << std::endl;
detector.configureHoughAccumulatorThresholdH(_hHoughAccumulatorThreshold.get());
detector.configureHoughAccumulatorThresholdS(_sHoughAccumulatorThreshold.get());
detector.configureHoughAccumulatorThresholdV(_vHoughAccumulatorThreshold.get());
detector.configureHoughEdgeThresholdH(_hHoughEdgeThreshold.get());
detector.configureHoughEdgeThresholdS(_sHoughEdgeThreshold.get());
detector.configureHoughEdgeThresholdV(_vHoughEdgeThreshold.get());

detector.configureHoughCircleMin(_houghMinCircle.get());
detector.configureHoughCircleMax(_houghMaxCircle.get());

detector.configureHValueMin(_hValueMin.get());
detector.configureSValueMin(_sValueMin.get());
detector.configureVValueMin(_vValueMin.get());

detector.configureHValueMax(_hValueMax.get());
detector.configureSValueMax(_sValueMax.get());
detector.configureVValueMax(_vValueMax.get());

detector.configureDebug(_debug.get());
detector.configureDebugGray(_hsv_gray.get());
detector.configureDebugHough(_hough_debug_h.get(), _hough_debug_s.get(), _hough_debug_v.get());
DetectorBase::updateHook();
if (_frame.read(fp) != RTT::NewData) {
return;
Expand All @@ -101,7 +128,10 @@ void Detector::updateHook()

filter.setMaxage((double)_filter_timeout);

BuoyFeatureVector result = detector.buoyDetection(&image, _hValue.get(), _sValue.get());
std::cout <<"buoy detection" << std::endl;
BuoyFeatureVector result = detector.buoyDetection(&image);

std::cout <<"feed" << std::endl;
filter.feed(result);

BuoyFeatureVector vector = filter.process();
Expand All @@ -116,7 +146,8 @@ void Detector::updateHook()
buoy=vector.front();
posestimator.estimateAuvKoordinates(buoy, frame, _buoy_radius.get());
current_state = BUOY_FOUND;
light_on = detector.findWhiteLight(&image, buoy, feature::WhiteLightSettings(_roi_x,_roi_y,_roi_width,_roi_height,_val_th,_sat_th));
//light_on = detector.findWhiteLight(&image, buoy, feature::WhiteLightSettings(_roi_x,_roi_y,_roi_width,_roi_height,_val_th,_sat_th));
light_on = false;
}
_buoy.write(buoy);
_light.write(light_on);
Expand All @@ -126,19 +157,45 @@ void Detector::updateHook()
previous_state=current_state;
}

if(_debug){
if(_debug.get()){
std::cout <<"writeout" << std::endl;
std::cout << "1" << std::endl;
base::samples::frame::Frame* h_p = hframe.write_access();
base::samples::frame::Frame* s_p = sframe.write_access();
base::samples::frame::Frame* l_p = lframe.write_access();
frame_helper::FrameHelper::copyMatToFrame(detector.getHshaded(),*h_p);
base::samples::frame::Frame* v_p = vframe.write_access();
base::samples::frame::Frame* hsv_debug_p = grayframe.write_access();
base::samples::frame::Frame* hough_debug_p = houghframe.write_access();
base::samples::frame::Frame* debug_p = debugframe.write_access();

std::cout << "2" << std::endl;
std::cout << "2.1" << std::endl;
frame_helper::FrameHelper::copyMatToFrame(detector.getHplane(),*h_p);
std::cout << "2.2" << std::endl;
frame_helper::FrameHelper::copyMatToFrame(detector.getSplane(),*s_p);
frame_helper::FrameHelper::copyMatToFrame(detector.getDebugImage(),*l_p);
std::cout << "2.3" << std::endl;
frame_helper::FrameHelper::copyMatToFrame(detector.getVplane(),*v_p);
std::cout << "2.4" << std::endl;
frame_helper::FrameHelper::copyMatToFrame(detector.getHSVDebug(),*hsv_debug_p);
std::cout << "2.5" << std::endl;
frame_helper::FrameHelper::copyMatToFrame(detector.getHoughDebug(),*hough_debug_p);
std::cout << "2.6" << std::endl;
frame_helper::FrameHelper::copyMatToFrame(detector.getDebugImage(),*debug_p);

std::cout << "3" << std::endl;
hframe.reset(h_p);
sframe.reset(s_p);
lframe.reset(l_p);
vframe.reset(v_p);
grayframe.reset(hsv_debug_p);
houghframe.reset(hough_debug_p);
debugframe.reset(debug_p);

std::cout << "4" << std::endl;
_h_image.write(hframe);
_s_image.write(sframe);
_light_image.write(lframe);
_v_image.write(vframe);
_gray_debug_image.write(grayframe);
_hough_debug_image.write(houghframe);
_debug_image.write(debugframe);
_other_buoys.write(vector);
}
}
Expand Down
5 changes: 4 additions & 1 deletion tasks/Detector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ namespace buoy {
frame_helper::FrameHelper frameHelper;
RTT::extras::ReadOnlyPointer<base::samples::frame::Frame> hframe;
RTT::extras::ReadOnlyPointer<base::samples::frame::Frame> sframe;
RTT::extras::ReadOnlyPointer<base::samples::frame::Frame> lframe; //light-frame
RTT::extras::ReadOnlyPointer<base::samples::frame::Frame> vframe;
RTT::extras::ReadOnlyPointer<base::samples::frame::Frame> grayframe;
RTT::extras::ReadOnlyPointer<base::samples::frame::Frame> houghframe;
RTT::extras::ReadOnlyPointer<base::samples::frame::Frame> debugframe; //light-frame


public:
Expand Down

0 comments on commit 9751b09

Please sign in to comment.