SatDump
2.0.0-alpha-76a915210
Loading...
Searching...
No Matches
warp_bkd.h
1
#pragma once
2
3
#include "
image/image.h
"
4
#include "projection/thinplatespline.h"
5
#include <memory>
6
#include <algorithm>
7
#include "warp.h"
8
9
namespace
satdump
10
{
11
namespace
warp
12
{
13
/*
14
Initialize the Thin Plate Spline transform we need for warping
15
imagery.
16
*/
17
std::shared_ptr<projection::VizGeorefSpline2D> initTPSTransform(
WarpOperation
&op);
18
std::shared_ptr<projection::VizGeorefSpline2D> initTPSTransform(std::vector<projection::GCP> gcps,
int
shift_lon,
int
shift_lat);
19
20
/*
21
More or less internal structs that holds the required area to
22
cover given input GCPs.
23
*/
24
struct
WarpCropSettings
25
{
26
float
lat_min;
27
float
lat_max;
28
float
lon_min;
29
float
lon_max;
30
int
y_min;
31
int
y_max;
32
int
x_min;
33
int
x_max;
34
};
35
36
/*
37
Returns the required "croped" area to cover provided GCPs.
38
*/
39
WarpCropSettings
choseCropArea(
WarpOperation
&op);
40
41
/*
42
Reproject a provided image with GCPs to an equirectangular projection,
43
from where other projections can be done.
44
45
A WarpOperation is the input. At least once, but otherwise each time
46
GCPs or output size is changed, update() should be called to recompute
47
the transformer. Doing this is more-or-less intensive, so it not
48
automatically called as that would introduce potentially unwanted
49
latencies.
50
51
After update() was called, warp() can be called. That function
52
will return a WarpResult containing the output image and resulting
53
GCPs, as an equirectangular projection.
54
*/
55
class
ImageWarper
56
{
57
private
:
58
WarpCropSettings
crop_set;
59
std::shared_ptr<projection::VizGeorefSpline2D> tps;
60
61
private
:
62
// Slower, generic CPU implementation
63
void
warpOnCPU(
WarpResult
&result);
64
65
#ifdef USE_OPENCL
66
// 64-bits GPU implementation, more accurate and faster than CPU, but not all GPUs
67
// have FP64 cores and if they do, usually quite few of them
68
void
warpOnGPU_fp64(
WarpResult
&result);
69
70
// 32-bits GPU implementation, less accurate than FP64 but really, as long as
71
// you are not re-projecting something super high resolution, no difference to
72
// FP64. The big plus though is, most GPU especially on the consumer end and older
73
// generations pack a LOT more FP32 cores (On recent Pascal GPUs, it's 24x more than
74
// FP64!). This is the default, and gives quite impressive performances.
75
void
warpOnGPU_fp32(
WarpResult
&result);
76
#endif
77
78
public
:
79
WarpOperation
op;
80
81
public
:
82
// Call this if the GCPs or height/width in the WarpOperation changed. Has to be called at least once.
83
void
update(
bool
skip_tps =
false
);
84
85
// Set TPS externally if it was already processed
86
void
set_tps(std::shared_ptr<projection::VizGeorefSpline2D> tps)
87
{
88
this->tps = tps;
89
}
90
91
// Warp and return result.
92
// This will if possible try to use a graphics accelerator
93
// (GPU, iGPU, or CPUs that have OpenCL support),
94
// and if not available or in case of a failure, will use
95
// a slower CPU function instead.
96
WarpResult
warp(
bool
force_double =
false
);
97
};
98
}
99
}
satdump::warp::ImageWarper
Definition
warp_bkd.h:56
image.h
Core Image class.
satdump::warp::WarpCropSettings
Definition
warp_bkd.h:25
satdump::warp::WarpOperation
Definition
warp.h:19
satdump::warp::WarpResult
Definition
warp.h:37
src-core
projection
warp
warp_bkd.h
Generated by
1.14.0