Alex Vakulenko | e4eec20 | 2017-01-27 14:41:04 -0800 | [diff] [blame^] | 1 | #ifndef ANDROID_DVR_LOOKUP_RADIAL_DISTORTION_H_ |
| 2 | #define ANDROID_DVR_LOOKUP_RADIAL_DISTORTION_H_ |
| 3 | |
| 4 | #include <vector> |
| 5 | |
| 6 | #include <private/dvr/color_channel_distortion.h> |
| 7 | |
| 8 | namespace android { |
| 9 | namespace dvr { |
| 10 | |
| 11 | // LookupRadialDistortion implements a radial distortion based using using a |
| 12 | // vector of tan(angle) -> multipliers. This can use measured data directly. |
| 13 | class LookupRadialDistortion : public ColorChannelDistortion { |
| 14 | public: |
| 15 | // lookup.x = tan(angle), lookup.y = distance from center multiplier. |
| 16 | explicit LookupRadialDistortion(const vec2* lookup, size_t count); |
| 17 | |
| 18 | vec2 Distort(vec2 p) const override; |
| 19 | vec2 DistortInverse(vec2 p) const override; |
| 20 | |
| 21 | private: |
| 22 | float DistortionFactor(float r) const; |
| 23 | float DistortRadius(float r) const; |
| 24 | |
| 25 | std::vector<vec2> lookup_; |
| 26 | }; |
| 27 | |
| 28 | } // namespace dvr |
| 29 | } // namespace android |
| 30 | |
| 31 | #endif // ANDROID_DVR_LOOKUP_RADIAL_DISTORTION_H_ |