source: flair-src/trunk/lib/FlairVisionFilter/src/HoughLines.cpp @ 148

Last change on this file since 148 was 148, checked in by Sanahuja Guillaume, 4 years ago

m

File size: 2.7 KB
Line 
1//  created:    2015/10/07
2//  filename:   HoughLines.cpp
3//
4//  author:     Guillaume Sanahuja
5//              Copyright Heudiasyc UMR UTC/CNRS 7253
6//
7//  version:    $Id: $
8//
9//  purpose:    HoughLines
10//
11//
12/*********************************************************************/
13
14#include "HoughLines.h"
15#include <cvimage.h>
16#include <cvmatrix.h>
17#include <Layout.h>
18#include <GroupBox.h>
19#include <SpinBox.h>
20#include <DoubleSpinBox.h>
21#include <typeinfo>
22
23#define MAX_LINES 100
24
25using std::string;
26using namespace flair::core;
27using namespace flair::gui;
28
29namespace flair { namespace filter {
30
31HoughLines::HoughLines(const IODevice* parent,const LayoutPosition* position,string name) : IODevice(parent,name) {
32    GroupBox* reglages_groupbox=new GroupBox(position,name);
33    fullRhoStep=new SpinBox(reglages_groupbox->NewRow(),"full rho step:","pixels",0,255,1,1);
34    fullThetaStep=new DoubleSpinBox(reglages_groupbox->LastRowLastCol(),"full theta step:","degrees",0,90,1,1);
35    trackingRhoStep=new SpinBox(reglages_groupbox->NewRow(),"tracking rho step:","pixels",0,255,1,1);
36    trackingThetaStep=new DoubleSpinBox(reglages_groupbox->LastRowLastCol(),"tracking theta step:","degrees",0,90,1,1);
37    trackingDeltaTheta=new DoubleSpinBox(reglages_groupbox->LastRowLastCol(),"tracking delta theta:","degrees",0,90,1,1);
38    nbPoints=new SpinBox(reglages_groupbox->NewRow(),"nb points:",0,10000,10,100);
39
40    isTracking=false;
41    lostLine=false;
42    initLine=false;
43    linesStorage = cvCreateMat(MAX_LINES, 1, CV_32FC2);
44
45    //init output matrix of same size as init
46    cvmatrix_descriptor* desc=new cvmatrix_descriptor(4,1);
47    desc->SetElementName(0,0,"distance");
48    desc->SetElementName(1,0,"orientation rad");
49    desc->SetElementName(2,0,"orientation deg");
50    desc->SetElementName(3,0,"line_detected");
51    output=new cvmatrix(this,desc,floatType,name);
52    delete desc;
53
54    try{
55        cvimage::Type const &imageType=dynamic_cast<cvimage::Type const &>(parent->GetOutputDataType());
56        if(imageType.GetFormat()!=cvimage::Type::Format::Gray) {
57            Err("input image is not gray\n");
58        }
59    } catch(std::bad_cast& bc) {
60        Err("io type mismatch\n");
61    }
62}
63
64HoughLines::~HoughLines(void) {
65    cvReleaseMat(&linesStorage);
66}
67
68void HoughLines::UpdateFrom(const io_data *data) {
69 
70}
71
72bool HoughLines::isLineDetected() const {
73    if(output->Value(3,0)==1) {
74        return true;
75    } else {
76        return false;
77    }
78}
79
80float HoughLines::GetOrientation(void) const {
81    return output->Value(1,0);
82}
83
84float HoughLines::GetDistance(void) const {
85    return output->Value(0,0);
86}
87
88cvmatrix *HoughLines::Output(void) const {
89    return output;
90}
91
92} // end namespace filter
93} // end namespace flair
Note: See TracBrowser for help on using the repository browser.