图像内几乎没有甚至没有关于AWS iOS文本识别的文档。我已经完成了AWS创建IAM(具有执行Rekognition等权限)的过程,我从该配置文件在AWS上创建了“移动应用”,并获得了包含在我的项目中的json文件。
我正在初始化AWS“ stack”,在App Delegate中也没有问题
#include <iostream>
using namespace std;
// parametrize true_type
template <int> using true_int = true_type; // works
template <auto> using true_auto = true_type; // does not work
// detect if T::value() is a valid compile-time expression
template <class T> true_int<(T::value(), void(), 0)> match_int(int);
template <class T> true_auto<(T::value(), void(), 0)> match_auto(int);
template <class> false_type match_int(...); // sometimes called
template <class> false_type match_auto(...); // always called
template <class T>
static constexpr bool has_value_int = decltype(match_int<T>(0))::value;
template <class T>
static constexpr bool has_value_auto = decltype(match_auto<T>(0))::value;
template <class T>
void demo() {
cout << has_value_int<T> << "(int), " // sometimes false
<< has_value_auto<T> << "(auto)" << endl; // always false
}
int main() {
struct pass { static constexpr int value() { return 1; } };
using fail = float;
cout << "has_value<pass> = "; demo<pass>(); // 1(int), 0(auto)
cout << "has_value<fail> = "; demo<fail>(); // 0(int), 0(auto)
return 0;
}
我的ViewController崩溃了:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
AWSDDLog.add(AWSDDTTYLogger.sharedInstance)
AWSDDLog.sharedInstance.logLevel = .info
return AWSMobileClient.sharedInstance().interceptApplication(
application,
didFinishLaunchingWithOptions: launchOptions)
}
崩溃显示了这一点:
override func viewDidLoad() {
super.viewDidLoad()
let rekognitionClient = AWSRekognition.default() // CRASH HERE BOOM
let sourceImage = UIImage(named: "corolla")
let image = AWSRekognitionImage()
image!.bytes = UIImageJPEGRepresentation(sourceImage!, 0.7)
guard let request = AWSRekognitionDetectLabelsRequest() else {
puts("Unable to initialize AWSRekognitionDetectLabelsRequest.")
return
}
request.image = image
request.maxLabels = 3
request.minConfidence = 90
rekognitionClient.detectLabels(request) { (response:AWSRekognitionDetectLabelsResponse?, error:Error?) in
if error == nil {
print(response!)
}
}
}
据我所知,似乎我应该以某种方式在json文件中配置Rekognition?在AWS网站上创建json文件时,我没有看到该选项...
有什么想法吗?
答案 0 :(得分:1)
我在尝试使用其他AWS服务时遇到了相同的问题。像这样将服务添加到我的awsconfiguration.json
文件中:
"Rekognition": {
"Default": {
"Region": "us-east-1"
}
}
来源:我在文档中找不到此文件,但SDK为open source