33 #include <Base/Image/ROI.hh>
38 void WriteRead(
const ROI src,
ROI& dst);
43 const unsigned w=100, h=75;
48 const unsigned ulx=10, uly=10, lrx=50, lry=50;
51 unsigned mulx, muly, mlrx, mlry;
53 if (ulx!=mulx || uly!=muly || lrx!=mlrx || lry!=mlry){ BIASABORT; }
56 vector<unsigned> start(h, 0), end(h, w);
61 vector<unsigned> mstart, mend;
64 if (!dst.
GetRows(mstart, mend)) { BIASABORT; }
65 if (mstart.size()!=h || mend.size()!=h) { BIASABORT; }
66 for (
unsigned y=0; y<h; y++){
67 if (mstart[y] != start[y]) { BIASABORT; }
68 if (mend[y] != end[y]) { BIASABORT; }
72 vector<Position> pos(2);
77 vector<Position> dst_pos;
78 if (!dst.
GetVector(dst_pos)) { BIASABORT; }
79 if (dst_pos.size()!=2) { BIASABORT; }
80 for (
int i=0; i<2; i++){
81 if (dst_pos[i].x!=pos[i].x) { BIASABORT; }
82 if (dst_pos[i].y!=pos[i].y) { BIASABORT; }
88 if (dst.
Mask(42, 42)!=
false) { BIASABORT; }
89 if (dst.
Mask(10, 10)!=
true) { BIASABORT; }
94 int main(
int argc,
char *argv[])
101 void WriteRead(
const ROI src,
ROI& dst)
103 const string file(
"roi.bin");
104 ofstream of(file.c_str());
107 ifstream is(file.c_str());
stores valid/nvalid positions in image
class for handling different region of interest (ROI) representations...
int SetCorners(unsigned UpperLeftX, unsigned UpperLeftY, unsigned LowerRightX, unsigned LowerRightY)
Sets a rectangular region of interest.
void Resize(unsigned width, unsigned height)
Resizes parent image.
void GetCorners(unsigned &UpperLeftX, unsigned &UpperLeftY, unsigned &LowerRightX, unsigned &LowerRightY) const
Return the region of interest, by saving the coordinates within the variables defined by the paramete...
bool Mask(const unsigned &x, const unsigned &y) const
Direct access to the mask data, const version.
unsigned GetWidth() const
width capacity of roi (image width)
int WriteBinary(std::ostream &os) const
binary output to stream
std::vector< Position > * GetVector()
returns a pointer to the vector representation of the ROI
int ReadBinary(std::istream &is)
binary input from stream
bool GetRows(std::vector< unsigned > &start, std::vector< unsigned > &end) const
Horizontal start and end position per image row, the length of the vectors always corresponds to the ...
unsigned GetHeight() const
height capacity of roi (image height)
void SetMask(const unsigned &x, const unsigned &y, const bool val)
Direct access to the mask data.
void SetVector(std::vector< Position > &pos)
Sets MaskValid_=false and VectorValid_=true.
void SetRows(const std::vector< unsigned > &start, const std::vector< unsigned > &end)
Horizontal start and end position per image row, the length of the vectors always corresponds to the ...