1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
#pragma once
#include <vector>
#include "abstring.h"
#include "bvimagergb.h"
#include "bvrgbpixel.h"
#include "bvfilters.h"
#include "vraibolabmodule.h"
#define DISP_DIST_THRESHOLD 20
#define MAX_DISP_GRADIENT 1.0
#define ERROR_DISP_GRADIENT 1000.0
#define MAX_COLOR_DIFF 5
#define MAX_LUM_DIFF 10.0
struct candidate {
unsigned xLeft;
unsigned xRight;
double propapilityCounter;
bool isAssigned;
bool operator== (const candidate& other) const {
return (xLeft == other.xLeft && xRight == other.xRight);
}
bool operator== (const candidate* other) const {
return (xLeft == other->xLeft && xRight == other->xRight);
}
};
struct candidatePair {
candidate* firstCand;
candidate* secondCand;
double disparityGradient;
bool isAssigned;
bool isDeleted;
//long pairNum;
double candidateDistance;
bool operator== (const candidatePair& other) const {
return ( (firstCand == other.firstCand) && (secondCand == other.secondCand) );
}
bool hasCandidate(const candidate& other) const {
return (*firstCand == other) || (*secondCand == other);
}
bool hasCandidate(const candidate* other) const {
return (*firstCand == *other) || (*secondCand == *other);
}
candidatePair() {}
candidatePair(const candidatePair& other) {
firstCand = other.firstCand;
secondCand = other.secondCand;
disparityGradient = other.disparityGradient;
isAssigned = other.isAssigned;
isDeleted = other.isDeleted;
//pairNum = other.pairNum;
candidateDistance = other.candidateDistance;
}
};
class StereoVision
{
public:
StereoVision(void);
~StereoVision(void);
static std::vector<candidate*> findCorrespPointsPMF(BV::ImageRGB&,BV::ImageRGB&);
static std::vector<candidate*> findCorrespPointsPMF(BV::Image&,BV::Image&);
static long getDisparityDifference(const unsigned&,const unsigned&,const unsigned&,const unsigned&);
private:
static void findEdges(BV::ImageRGB&,BV::ImageRGB&,std::vector<unsigned>&,std::vector<unsigned>&);
static void findEdges(BV::Image&,BV::Image&,std::vector<unsigned>&,std::vector<unsigned>&);
static double getCyclopDistanceEpipolar(const unsigned&,const unsigned&,const unsigned&,const unsigned&);
static double getDisparityGradient(const unsigned&,const unsigned&,const unsigned&,const unsigned&);
static bool arePixelSimilar(const BV::RGBPixel&,const BV::RGBPixel&);
};
|