我有这段代码:
Tesseract* tesseract = [[Tesseract alloc] initWithLanguage:@"eng"];
tesseract.delegate = self;
[tesseract setVariableValue:@"0123456789ABCDEFGHIJKLMNÑOPKRSTUVWXYZabcdefghijklmnñopqrstuvwxyz" forKey:@"tessedit_char_whitelist"]; //limit search
[tesseract setImage:[UIImage imageNamed:@"image1.jpg"]]; //image to check
[tesseract recognize];
这很好用。
但是,如果我更改图像以查看UIImageVIew的图像,则无效(EXC_BAD_ACCESS):
Tesseract* tesseract = [[Tesseract alloc] initWithLanguage:@"eng+ita"];
tesseract.delegate = self;
[tesseract setVariableValue:@"0123456789ABCDEFGHIJKLMNÑOPKRSTUVWXYZabcdefghijklmnñopqrstuvwxyz" forKey:@"tessedit_char_whitelist"]; //limit search
[tesseract setImage:self.imageview.image]; //image to check
[tesseract recognize];
你知道这是错的吗?
答案 0 :(得分:0)
Tesseract sholud仅允许UIImage。所以你应该将Imageview图像转换为UIImage然后执行。 请尝试代码。
Tesseract* tesseract = [[Tesseract alloc] initWithLanguage:@"eng+ita"];
tesseract.delegate = self;
[tesseract setVariableValue:@"0123456789ABCDEFGHIJKLMNÑOPKRSTUVWXYZabcdefghijklmnñopqrstuvwxyz" forKey:@"tessedit_char_whitelist"]; //limit search
UIImage *imageFromImageView = self.imageview.image
[tesseract setImage:imageFromImageView ]; //image to check
[tesseract recognize];