#include "tensorflow_lite_support/cc/task/vision/utils/frame_buffer_utils.h"
#include <algorithm>
#include <iterator>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "absl/memory/memory.h"
#include "absl/status/status.h"
#include "absl/strings/str_format.h"
#include "tensorflow/lite/kernels/internal/compatibility.h"
#include "tensorflow/lite/kernels/op_macros.h"
#include "tensorflow_lite_support/cc/port/status_macros.h"
#include "tensorflow_lite_support/cc/task/vision/utils/frame_buffer_common_utils.h"
#include "tensorflow_lite_support/cc/task/vision/utils/libyuv_frame_buffer_utils.h"
namespace tflite {
namespace task {
namespace vision {
namespace {
constexpr int kExifGroup[] = …;
constexpr int kExifGroupSize = …;
static int GetOrientationIndex(FrameBuffer::Orientation orientation) { … }
static BoundingBox RotateBoundingBox(const BoundingBox& box, int angle,
FrameBuffer::Dimension frame_dimension) { … }
static void RotateCoordinates(int from_x, int from_y, int angle,
const FrameBuffer::Dimension& frame_dimension,
int* to_x, int* to_y) { … }
}
int GetBufferByteSize(FrameBuffer::Dimension dimension,
FrameBuffer::Format format) { … }
FrameBufferUtils::FrameBufferUtils(ProcessEngine engine) { … }
BoundingBox OrientBoundingBox(const BoundingBox& from_box,
FrameBuffer::Orientation from_orientation,
FrameBuffer::Orientation to_orientation,
FrameBuffer::Dimension from_dimension) { … }
BoundingBox OrientAndDenormalizeBoundingBox(
float from_left, float from_top, float from_right, float from_bottom,
FrameBuffer::Orientation from_orientation,
FrameBuffer::Orientation to_orientation,
FrameBuffer::Dimension from_dimension) { … }
void OrientCoordinates(int from_x, int from_y,
FrameBuffer::Orientation from_orientation,
FrameBuffer::Orientation to_orientation,
FrameBuffer::Dimension from_dimension, int* to_x,
int* to_y) { … }
OrientParams GetOrientParams(FrameBuffer::Orientation from_orientation,
FrameBuffer::Orientation to_orientation) { … }
bool RequireDimensionSwap(FrameBuffer::Orientation from_orientation,
FrameBuffer::Orientation to_orientation) { … }
absl::Status FrameBufferUtils::Crop(const FrameBuffer& buffer, int x0, int y0,
int x1, int y1,
FrameBuffer* output_buffer) { … }
FrameBuffer::Dimension FrameBufferUtils::GetSize(
const FrameBuffer& buffer, const FrameBufferOperation& operation) { … }
std::vector<FrameBuffer::Plane> FrameBufferUtils::GetPlanes(
const uint8* buffer, FrameBuffer::Dimension dimension,
FrameBuffer::Format format) { … }
FrameBuffer::Orientation FrameBufferUtils::GetOrientation(
const FrameBuffer& buffer, const FrameBufferOperation& operation) { … }
FrameBuffer::Format FrameBufferUtils::GetFormat(
const FrameBuffer& buffer, const FrameBufferOperation& operation) { … }
absl::Status FrameBufferUtils::Execute(const FrameBuffer& buffer,
const FrameBufferOperation& operation,
FrameBuffer* output_buffer) { … }
absl::Status FrameBufferUtils::Resize(const FrameBuffer& buffer,
FrameBuffer* output_buffer) { … }
absl::Status FrameBufferUtils::ResizeNearestNeighbor(
const FrameBuffer& buffer, FrameBuffer* output_buffer) { … }
absl::Status FrameBufferUtils::Rotate(const FrameBuffer& buffer,
RotationDegree rotation,
FrameBuffer* output_buffer) { … }
absl::Status FrameBufferUtils::FlipHorizontally(const FrameBuffer& buffer,
FrameBuffer* output_buffer) { … }
absl::Status FrameBufferUtils::FlipVertically(const FrameBuffer& buffer,
FrameBuffer* output_buffer) { … }
absl::Status FrameBufferUtils::Convert(const FrameBuffer& buffer,
FrameBuffer* output_buffer) { … }
absl::Status FrameBufferUtils::Orient(const FrameBuffer& buffer,
FrameBuffer* output_buffer) { … }
absl::Status FrameBufferUtils::Execute(
const FrameBuffer& buffer,
const std::vector<FrameBufferOperation>& operations,
FrameBuffer* output_buffer) { … }
absl::Status FrameBufferUtils::Preprocess(
const FrameBuffer& buffer, absl::optional<BoundingBox> bounding_box,
FrameBuffer* output_buffer, bool uniform_resizing) { … }
}
}
}