J'essaie d'implémenter l'API CloudSight dans un projet iOS Objective C pour le plaisir, mais pour une raison quelconque, lorsque j'essaie d'envoyer une image à cloudSight, les paramètres cloudSightQuery sont tous définis sur null. J'ai ajouté CloudSight à mon application en tant que Cocoapod et tout se charge bien et quand j'exécute ce code ci-dessous, il ne renvoie jamais de réponse du serveur en fait, je ne suis même pas sûr qu'il envoie.cloudsight Paramètres cloudSightQuery définis sur null
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
Voici la bibliothèque: https://libraries.io/github/cloudsight/cloudsight-objc
Juste des problèmes de mise à jour de ce pod. Je vais essayer à nouveau le matin et vous laisser savoir comment je vais merci pour la réponse rapide! – HurkNburkS
Cela a fonctionné beaucoup merci! – HurkNburkS