Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

通过传入本地图片url识别报错,请大神帮忙 #18

Open
YanzhaoMa opened this issue Nov 29, 2016 · 1 comment
Open

通过传入本地图片url识别报错,请大神帮忙 #18

YanzhaoMa opened this issue Nov 29, 2016 · 1 comment

Comments

@YanzhaoMa
Copy link

-(void)start{
cout << "test_plate_recognize" << endl;

pr.setLifemode(true);
pr.setDebug(true);
pr.setMaxPlates(4);

// pr.setDetectType(PR_DETECT_COLOR | PR_DETECT_SOBEL);
pr.setDetectType(easypr::PR_DETECT_CMSER);

NSString *nsstring=[[NSBundle mainBundle] pathForResource:@"test" ofType:@"jpg"];
NSLog(@"%@",nsstring );
string image_path=[nsstring UTF8String];

source_image=imread(image_path);
resize(source_image, source_image,cv::Size(source_image.cols/2,source_image.rows/2));
[self plateRecognition:source_image];

}

-(id) initWithurl:(NSString *)imageurl
{
self = [super init] ;
if ( self ) {
self.imageurl=imageurl;
}
return self ;
}

-(UIImage*)plateRecognition:(cv::Mat&)src
{
UIImage plateimage;
vector plateVec;
double t=cv::getTickCount();
int result = pr.plateRecognize(src, plateVec); //此行以后程序停止但是不报任何错误。
t=cv::getTickCount()-t;
NSLog(@"time %f",t
1000/cv::getTickFrequency());
if (result == 0) {
size_t num = plateVec.size();
for (size_t j = 0; j < num; j++) {
cout << "plateRecognize: " << plateVec[j].getPlateStr() << endl;
}
}

if (result != 0) cout << "result:" << result << endl;
if(plateVec.size()==0){
    [SVProgressHUD dismiss];
    return plateimage;
}
string name=plateVec[0].getPlateStr();
NSString *resultMessage = [NSString stringWithCString:plateVec[0].getPlateStr().c_str()
                                             encoding:NSUTF8StringEncoding];

NSLog(@"%@",resultMessage);

if (result != 0)
cout << "result:" << result << endl;
[SVProgressHUD dismiss];
return plateimage;

}

@zhoushiwei
Copy link
Owner

你检查下图片是不是空的,可能你图片的读取方式有问题

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants