source: flair-src/branches/sanscv/lib/FlairVisionFilter/src/HoughLines.cpp@ 324

Last change on this file since 324 was 324, checked in by Sanahuja Guillaume, 5 years ago

removing opencv dependency

File size: 2.8 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 <Image.h>
16#include <Matrix.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 = (CvMat*)malloc(sizeof(CvMat));
44 linesStorage->data.fl = (float*)malloc(MAX_LINES*2*sizeof(float));//was CV_32FC2, 2 channels
45
46
47 //init output matrix of same size as init
48 MatrixDescriptor* desc=new MatrixDescriptor(4,1);
49 desc->SetElementName(0,0,"distance");
50 desc->SetElementName(1,0,"orientation rad");
51 desc->SetElementName(2,0,"orientation deg");
52 desc->SetElementName(3,0,"line_detected");
53 output=new Matrix(this,desc,floatType,name);
54 delete desc;
55
56 try{
57 Image::Type const &imageType=dynamic_cast<Image::Type const &>(parent->GetOutputDataType());
58 if(imageType.GetFormat()!=Image::Type::Format::Gray) {
59 Err("input image is not gray\n");
60 return;
61 }
62 } catch(std::bad_cast& bc) {
63 Err("io type mismatch\n");
64 return;
65 }
66
67 SetIsReady(true);
68}
69
70HoughLines::~HoughLines(void) {
71 free((char*)(linesStorage->data.fl));
72 free((char*)linesStorage);
73}
74
75void HoughLines::UpdateFrom(const io_data *data) {
76
77}
78
79bool HoughLines::isLineDetected() const {
80 if(output->Value(3,0)==1) {
81 return true;
82 } else {
83 return false;
84 }
85}
86
87float HoughLines::GetOrientation(void) const {
88 return output->Value(1,0);
89}
90
91float HoughLines::GetDistance(void) const {
92 return output->Value(0,0);
93}
94
95Matrix *HoughLines::Output(void) const {
96 return output;
97}
98
99} // end namespace filter
100} // end namespace flair
Note: See TracBrowser for help on using the repository browser.