Fawkes API
Fawkes Development Version
rectinfo_block.cpp
1
2
/***************************************************************************
3
* rectinfo_block.cpp - Rectification info block encapsulation
4
*
5
* Created: Wed Oct 31 14:35:36 2007
6
* Copyright 2007 Tim Niemueller [www.niemueller.de]
7
*
8
****************************************************************************/
9
10
/* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version. A runtime exception applies to
14
* this software (see LICENSE.GPL_WRE file mentioned below for details).
15
*
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU Library General Public License for more details.
20
*
21
* Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22
*/
23
24
#include <core/exceptions/software.h>
25
#include <core/exceptions/system.h>
26
#include <fvutils/rectification/rectinfo_block.h>
27
28
#include <cstdlib>
29
#include <cstring>
30
31
namespace
firevision {
32
33
/** @class RectificationInfoBlock <fvutils/rectification/rectinfo_block.h>
34
* Rectification info block.
35
* This base class defines the basic interface to interact with rectification
36
* info blocks. It manages a small memory chunk that may later be used via
37
* other recitification information classes in an easy manner. Concrete
38
* implementations of a specific block type shall be derived from this
39
* class.
40
* @author Tim Niemueller
41
*/
42
43
/** @var RectificationInfoBlock::_block_header
44
* Rectification block header.
45
* This is a pointer to the content-specific block header for rectification info blocks.
46
*/
47
48
/** @fn void RectificationInfoBlock::mapping(uint16_t x, uint16_t y, uint16_t *to_x, uint16_t *to_y) = 0
49
* Get mapping (to_x, to_y) for (x, y).
50
* This can be used as a general method to access the RectificationInfoBlock mapping.
51
* For many models there may be a better (faster) way to access the mapping information.
52
* It performance matters (and it most probably will) exploit this and use the
53
* provided shortcut.
54
* @param x X pixel coordinate to get mapping for
55
* @param y Y pixel coordinate to get mapping for
56
* @param to_x Upon return contains the X pixel coordinate of the unrectified image
57
* @param to_y Upon return contains the Y pixel coordinate of the unrectified image
58
*/
59
60
/** Recommended constructor.
61
* With this constructor a chunk of memory is allocated that is sufficient
62
* to hold the internal block header and the data of the given size. Note
63
* that the size you give is only meant to hold your type specific header
64
* and data. Some extra bytes are internally added for the type agnostic
65
* block header.
66
* @param block_type type of the block as defined per rectinfo_block_type_t
67
* @param camera camera identifier
68
* @param block_data_size size of the data block, this means only the sum of
69
* the size of the type specific header and the data itself, NOT including
70
* the type agnostic block header.
71
*/
72
RectificationInfoBlock::RectificationInfoBlock
(uint8_t block_type,
73
uint8_t camera,
74
size_t
block_data_size)
75
: FireVisionDataFileBlock(block_type, block_data_size, sizeof(rectinfo_block_header_t))
76
{
77
if
(_data_size > UINT32_MAX) {
78
throw
fawkes::OutOfBoundsException
(
"RectInfoBlock: block_data_size is too large"
,
79
block_data_size,
80
0,
81
UINT32_MAX);
82
}
83
84
_block_header = (
rectinfo_block_header_t
*)_spec_header;
85
_block_header->camera = camera;
86
}
87
88
/** Copy constructor.
89
* Copies data from the given FireVisionDataFileBlock. It is assumed that this
90
* actually is a rectification info block, check that before calling this
91
* method.
92
* @param block FireVision data file block
93
*/
94
RectificationInfoBlock::RectificationInfoBlock
(
FireVisionDataFileBlock
*block)
95
:
FireVisionDataFileBlock
(block)
96
{
97
_block_header
= (
rectinfo_block_header_t
*)
_spec_header
;
98
}
99
100
/** Destructor.
101
* Destructs the chunk, if and only if _free_block_chunk is true.
102
*/
103
RectificationInfoBlock::~RectificationInfoBlock
()
104
{
105
_block_header
= NULL;
106
}
107
108
/** Get block camera identifier.
109
* @return camera identifier
110
* @see rectinfo_block_header_t
111
*/
112
uint8_t
113
RectificationInfoBlock::camera
()
const
114
{
115
if
(
_block_header
== NULL) {
116
throw
fawkes::NullPointerException
(
"No memory chunk loaded for rectinfo block"
);
117
}
118
return
_block_header
->
camera
;
119
}
120
121
}
// end namespace firevision
firevision::_rectinfo_block_header_t
The per-image rectification info block header.
Definition:
rectinfo.h:107
firevision::RectificationInfoBlock::camera
uint8_t camera() const
Get block camera identifier.
Definition:
rectinfo_block.cpp:117
fawkes::OutOfBoundsException
Definition:
software.h:89
firevision::RectificationInfoBlock::~RectificationInfoBlock
virtual ~RectificationInfoBlock()
Destructor.
Definition:
rectinfo_block.cpp:107
firevision::RectificationInfoBlock::RectificationInfoBlock
RectificationInfoBlock(uint8_t block_type, uint8_t camera, size_t block_size)
Recommended constructor.
Definition:
rectinfo_block.cpp:76
firevision::FireVisionDataFileBlock::_spec_header
void * _spec_header
Definition:
fvfile_block.h:65
firevision::RectificationInfoBlock::_block_header
rectinfo_block_header_t * _block_header
Definition:
rectinfo_block.h:54
firevision::FireVisionDataFileBlock
Definition:
fvfile_block.h:37
fawkes::NullPointerException
Definition:
software.h:35
firevision::_rectinfo_block_header_t::camera
uint32_t camera
camera, as specified per rectinfo_camera_t
Definition:
rectinfo.h:109
src
libs
fvutils
rectification
rectinfo_block.cpp
Generated by
1.8.16