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

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

iadded isready to iodevice:
avoid problem of imu not ready in ardrone2

File size: 2.7 KB
RevLine 
[122]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);
[148]52    delete desc;
[122]53
54    try{
55        cvimage::Type const &imageType=dynamic_cast<cvimage::Type const &>(parent->GetOutputDataType());
[124]56        if(imageType.GetFormat()!=cvimage::Type::Format::Gray) {
57            Err("input image is not gray\n");
[157]58            return;
[122]59        }
60    } catch(std::bad_cast& bc) {
61        Err("io type mismatch\n");
[157]62        return;
[122]63    }
[157]64   
65    SetIsReady(true);
[122]66}
67
68HoughLines::~HoughLines(void) {
69    cvReleaseMat(&linesStorage);
70}
71
72void HoughLines::UpdateFrom(const io_data *data) {
73 
74}
75
76bool HoughLines::isLineDetected() const {
77    if(output->Value(3,0)==1) {
78        return true;
79    } else {
80        return false;
81    }
82}
83
84float HoughLines::GetOrientation(void) const {
85    return output->Value(1,0);
86}
87
88float HoughLines::GetDistance(void) const {
89    return output->Value(0,0);
90}
91
92cvmatrix *HoughLines::Output(void) const {
93    return output;
94}
95
96} // end namespace filter
97} // end namespace flair
Note: See TracBrowser for help on using the repository browser.