#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 <os/availability.h>
#include <memory>
#include "base/functional/callback.h"
#include "base/mac/scoped_nsobject.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/geometry/rect_f.h"
namespace shape_detection {
base::scoped_nsobject<CIImage> CreateCIImageFromSkBitmap(
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);
base::scoped_nsobject<VNRequest> request_;
const Callback callback_;
};
}
#endif