Ich versuche, die CloudSight-API aus Spaß in ein iOS-Objective-C-Projekt zu implementieren. Wenn ich jedoch ein Bild an cloudSight senden möchte, werden alle cloudSightQuery-Parameter auf null gesetzt.cloudsight cloudSightQuery-Parameter auf null gesetzt
Ich habe CloudSight zu meiner Anwendung als Cocoapod hinzugefügt und alles lädt gut und wenn ich diesen Code unter es ausführen, nur keine Antwort vom Server zurück, tatsächlich bin ich nicht einmal sicher, dass es sendet.
firstview.h
#import <UIKit/UIKit.h>
#import "CloudSight.h"
#import <CloudSight/CloudSightQueryDelegate.h>
@interface FirstViewController : UIViewController <CloudSightQueryDelegate>
{
CloudSightQuery *cloudSightQuery;
}
- (void)searchWithImage;
- (NSData *)imageAsJPEGWithQuality:(float)quality;
@end
firstview.m
#import "FirstViewController.h"
#import <CoreLocation/CoreLocation.h>
#import "CloudSightConnection.h"
#import "UIImage+it_Image.h"
#import <CloudSight/CloudSightQuery.h>
@interface FirstViewController()
@end
@implementation FirstViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
cloudSightQuery.queryDelegate = self;
[self searchWithImage];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)searchWithImage {
UIImage * myImage = [UIImage imageNamed: @"car.jpg"];
NSData *imageData = [self imageAsJPEGWithQuality:0.7 image:myImage];
// Start CloudSight
cloudSightQuery = [[CloudSightQuery alloc] initWithImage:imageData
atLocation:CGPointZero
withDelegate:self
atPlacemark:nil
withDeviceId:@""];
[cloudSightQuery start];
}
#pragma mark CloudSightQueryDelegate
- (void)cloudSightQueryDidFinishIdentifying:(CloudSightQuery *)query {
if (query.skipReason != nil) {
NSLog(@"Skipped: %@", query.skipReason);
} else {
NSLog(@"Identified: %@", query.title);
}
}
- (void)cloudSightQueryDidFail:(CloudSightQuery *)query withError:(NSError *)error {
NSLog(@"Error: %@", error);
}
#pragma mark image
- (NSData *)imageAsJPEGWithQuality:(float)quality image:(UIImage *)image
{
return UIImageJPEGRepresentation(image, quality);
}
@end
Hier ist die Bibliothek: https://libraries.io/github/cloudsight/cloudsight-objc
Probleme mit der Aktualisierung dieses Pods. Ich werde es am Morgen noch einmal versuchen und Sie wissen lassen, wie ich gehe, danke für die schnelle Antwort! – HurkNburkS
Das hat sehr gut geklappt! – HurkNburkS