// created: 2015/10/07 // filename: HoughLines.cpp // // author: Guillaume Sanahuja // Copyright Heudiasyc UMR UTC/CNRS 7253 // // version: $Id: $ // // purpose: HoughLines // // /*********************************************************************/ #include "HoughLines.h" #include #include #include #include #include #include #include #define MAX_LINES 100 using std::string; using namespace flair::core; using namespace flair::gui; namespace flair { namespace filter { HoughLines::HoughLines(const IODevice* parent,const LayoutPosition* position,string name) : IODevice(parent,name) { GroupBox* reglages_groupbox=new GroupBox(position,name); fullRhoStep=new SpinBox(reglages_groupbox->NewRow(),"full rho step:","pixels",0,255,1,1); fullThetaStep=new DoubleSpinBox(reglages_groupbox->LastRowLastCol(),"full theta step:","degrees",0,90,1,1); trackingRhoStep=new SpinBox(reglages_groupbox->NewRow(),"tracking rho step:","pixels",0,255,1,1); trackingThetaStep=new DoubleSpinBox(reglages_groupbox->LastRowLastCol(),"tracking theta step:","degrees",0,90,1,1); trackingDeltaTheta=new DoubleSpinBox(reglages_groupbox->LastRowLastCol(),"tracking delta theta:","degrees",0,90,1,1); nbPoints=new SpinBox(reglages_groupbox->NewRow(),"nb points:",0,10000,10,100); isTracking=false; lostLine=false; initLine=false; linesStorage = cvCreateMat(MAX_LINES, 1, CV_32FC2); //init output matrix of same size as init cvmatrix_descriptor* desc=new cvmatrix_descriptor(4,1); desc->SetElementName(0,0,"distance"); desc->SetElementName(1,0,"orientation rad"); desc->SetElementName(2,0,"orientation deg"); desc->SetElementName(3,0,"line_detected"); output=new cvmatrix(this,desc,floatType,name); delete desc; try{ cvimage::Type const &imageType=dynamic_cast(parent->GetOutputDataType()); if(imageType.GetFormat()!=cvimage::Type::Format::Gray) { Err("input image is not gray\n"); return; } } catch(std::bad_cast& bc) { Err("io type mismatch\n"); return; } SetIsReady(true); } HoughLines::~HoughLines(void) { cvReleaseMat(&linesStorage); } void HoughLines::UpdateFrom(const io_data *data) { } bool HoughLines::isLineDetected() const { if(output->Value(3,0)==1) { return true; } else { return false; } } float HoughLines::GetOrientation(void) const { return output->Value(1,0); } float HoughLines::GetDistance(void) const { return output->Value(0,0); } cvmatrix *HoughLines::Output(void) const { return output; } } // end namespace filter } // end namespace flair