首页 版块 访问AI主站 注册 发帖
沉默123h
14
积分 积分商城
0
获赞
调用OCR API识别文字为乱码,如何解决
Ta的回复 :直接调用数据接口 老是返回这个 words_result:{     "error_code" = 216201;     "error_msg" = "image format error";     "log_id" = 8051115; } 图片格式是没有问题的 我用的是 你们官方测试图片 不知道是不是 图片Base64 编码出问题还是 URL编码出问题了? 我想知道 你们这边 iOS 图片Base64以及 URL编码是怎样编码的?
12
原帖已删除
Ta的回复 :    NSImage* i= [NSImage imageNamed:@"test.png"];     [i lockFocus];     NSBitmapImageRep *bitmapRep = [[NSBitmapImageRep alloc] initWithFocusedViewRect:NSMakeRect(0, 0, i.size.width, i.size.height)];     [i unlockFocus];     NSDictionary* p = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithFloat:2.0],                                               NSImageCompressionFactor, nil];     NSData * imageData = [bitmapRep representationUsingType:NSPNGFileType properties:p];     NSString *base64String = [imageData base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];     NSString *requestKey = @"image=";     requestKey = [requestKey stringByAppendingString:[base64String stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]];     NSData *requestBody = [NSData dataWithBytes: [requestKey UTF8String] length: [requestKey length]];          NSString* requestString = [NSString stringWithFormat:@"%@?access_token=%@",GENERAL_BASIC,self.access_token];          NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:requestString]];          NSDictionary* HTTPHeader = @{@"Content-Type":@"application/x-www-form-urlencoded"};     request.HTTPBody = requestBody;     request.allHTTPHeaderFields = HTTPHeader;     request.HTTPMethod = @"POST";     NSURLResponse* response = nil; 你能不能 帮我看一下 啊?  还是有问题啊??
0
切换版块
智能客服