LArOpenCV
1
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Core
ImageMeta.h
Go to the documentation of this file.
1
14
#ifndef __LARCAFFE_IMAGEMETA_H__
15
#define __LARCAFFE_IMAGEMETA_H__
16
17
#include <iostream>
18
#include <opencv2/opencv.hpp>
19
#include <opencv2/core/core.hpp>
20
#include "
larbys.h
"
21
#include "
LArCVTypes.h
"
22
23
namespace
larcaffe {
24
25
class
Image2D
;
37
class
ImageMeta
{
38
39
friend
class
Image2D
;
40
41
public
:
42
44
ImageMeta
(
const
double
width
=0.,
const
double
height
=0.,
45
const
size_t
width_npixel=0.,
const
size_t
height_npixel=0,
46
const
double
origin_x=0.,
const
double
origin_y=0.)
47
:
_origin
(origin_x,origin_y)
48
,
_width
(
width
)
49
,
_height
(
height
)
50
{
51
if
(
width
< 0. )
throw
larbys
(
"Width must be a positive floating point!"
);
52
if
(
height
< 0. )
throw
larbys
(
"Height must be a positive floating point!"
);
53
update
(width_npixel,height_npixel);
54
}
55
57
~ImageMeta
(){}
58
59
const
Point2D
&
origin
()
const
{
return
_origin
; }
60
double
width
()
const
{
return
_width
; }
61
double
height
()
const
{
return
_height
; }
62
size_t
num_pixel_row
()
const
{
return
_width_npixel
; }
63
size_t
num_pixel_column
()
const
{
return
_height_npixel
; }
64
double
pixel_width
()
const
{
return
(
_width_npixel
?
_width
/
_width_npixel
: 0.); }
65
double
pixel_height
()
const
{
return
(
_height_npixel
?
_height
/
_height_npixel
: 0.); }
67
double
pixel_relative_x
(
size_t
w)
const
{
return
pixel_width
() * ((double)w + 0.5); }
69
double
pixel_relative_y
(
size_t
h)
const
{
return
pixel_height
() * ((double)h + 0.5); }
71
double
pixel_x
(
size_t
w)
const
{
return
_origin
.
x
+
pixel_relative_x
(w); }
73
double
pixel_y
(
size_t
h)
const
{
return
_origin
.
y
+
pixel_relative_y
(h); }
75
void
update
(
const
size_t
width_npixel,
const
size_t
height_npixel)
76
{
77
//if( !width_npixel ) throw larbys("Number of pixels must be non-zero (width)");
78
//if( !height_npixel ) throw larbys("Number of pixels must be non-zero (height)");
79
_width_npixel
= width_npixel;
80
_height_npixel
= height_npixel;
81
}
83
void
update
(const ::cv::Mat& mat)
84
{
update
(mat.rows,mat.cols); }
85
86
protected
:
87
88
larcaffe::Point2D
_origin
;
89
double
_width
;
90
double
_height
;
91
size_t
_width_npixel
;
92
size_t
_height_npixel
;
93
94
};
95
96
}
97
98
namespace
larcv {
103
typedef ::larcaffe::ImageMeta
ImageMeta
;
104
105
}
106
107
#endif
108
// end of doxygen group
109
Generated on Wed Jan 27 2016 14:36:23 for LArOpenCV by
1.8.4