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

Last change on this file since 124 was 124, checked in by Sanahuja Guillaume, 7 years ago

modifs jpeg

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