#ifndef SERVICES_SHAPE_DETECTION_DETECTION_UTILS_MAC_H_
#define SERVICES_SHAPE_DETECTION_DETECTION_UTILS_MAC_H_
#import <CoreImage/CoreImage.h>
#import <Foundation/Foundation.h>
#import <Vision/Vision.h>
#include <memory>
#include "base/functional/callback.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/geometry/rect_f.h"
namespace shape_detection {
CIImage* CIImageFromSkBitmap(const SkBitmap& bitmap);
gfx::RectF ConvertCGToGfxCoordinates(CGRect bounds, int height);
class VisionAPIAsyncRequestMac {
public:
using Callback =
base::RepeatingCallback<void(VNRequest* request, NSError* error)>;
VisionAPIAsyncRequestMac(const VisionAPIAsyncRequestMac&) = delete;
VisionAPIAsyncRequestMac& operator=(const VisionAPIAsyncRequestMac&) = delete;
~VisionAPIAsyncRequestMac();
static std::unique_ptr<VisionAPIAsyncRequestMac> Create(
Class request_class,
Callback callback,
NSArray<VNBarcodeSymbology>* symbology_hints = nullptr);
bool PerformRequest(const SkBitmap& bitmap);
private:
VisionAPIAsyncRequestMac(Callback callback,
Class request_class,
NSArray<VNBarcodeSymbology>* symbology_hints);
VNRequest* __strong request_;
const Callback callback_;
};
}
#endif