Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

在iOS上 运行报错 #404

Open
goodcyg opened this issue Oct 19, 2024 · 4 comments
Open

在iOS上 运行报错 #404

goodcyg opened this issue Oct 19, 2024 · 4 comments

Comments

@goodcyg
Copy link

goodcyg commented Oct 19, 2024

下载是百度网盘里mnn和opencv,在iOS真机上运行报错如下?难道HyperLPR3不支持iOS?

Error for concat size of op [ 866 ], the 2 input not match output
Compute Shape Error for 866
Reshape error: 480 -> 0
Compute Shape Error for /neck/encoder/svtr_block.0/mixer/Reshape_1_output_0
Invalid Tensor, the session may not be ready
Can't run session because not resized

@qianxiaoer
Copy link

qianxiaoer commented Oct 19, 2024 via email

@goodcyg
Copy link
Author

goodcyg commented Oct 21, 2024

iOS中测试代码如下?
-(void)test {
UIImage *image=[UIImage imageNamed:@"999"];
// 将 UIImage 转换为 raw data
NSData *imageData=UIImagePNGRepresentation(image);
uint8_t *data = (uint8_t *)[imageData bytes];
_imageData=imageData;
int width = image.size.width;
int height = image.size.height;

// 创建 Data Buffer
HLPR_ImageData imgData = {0};
imgData.data = data;
imgData.width = width;
imgData.height = height;
imgData.format = STREAM_BGR;
imgData.rotation = CAMERA_ROTATION_0;

HLPR_ContextConfiguration config = {0};
// 设置模型路径
config.models_path =(char *)[self dir].UTF8String;
//config.models_path = "/path/to/your/models";
// 最大识别数量
config.max_num = 5;
// 使用一个线程
config.threads = 1;
// 不使用半精度推理
config.use_half = false;
// 检测框阈值
config.box_conf_threshold = 0.3f;
// 非极大值抑制阈值
config.nms_threshold = 0.4f;
// 识别置信度阈值
config.rec_confidence_threshold = 0.5f;
// 使用高开销检测模式
config.det_level = DETECT_LEVEL_LOW;

_context= HLPR_CreateContext(&config);

HREESULT ret=HLPR_ContextQueryStatus(_context);
if (ret != 0) {
    NSLog(@"Error creating context.");
    return;
}
P_HLPR_DataBuffer buffer = HLPR_CreateDataBuffer(&imgData);
HLPR_DataBufferSetStreamFormat(buffer, imgData.format);

// 更新 Context 并获取识别结果
HLPR_PlateResultList resultList = {0};
HLPR_ContextUpdateStream(_context, buffer, &resultList);

// 显示结果
if (resultList.plate_size > 0) {
    P_HLPR_PlateResult plate = resultList.plates;
    self.resultLabel.text = [NSString stringWithFormat:@"车牌号:%s", plate->code];
} else {
    self.resultLabel.text = @"未识别到车牌号";
}

// 释放 Data Buffer
HLPR_ReleaseDataBuffer(buffer);

}
-(NSString *)dir {
NSString *str2=[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"models/r2_mobile"];
NSLog(@"models:%@",str2);
return str2;
}

@goodcyg
Copy link
Author

goodcyg commented Oct 21, 2024

麻烦看一下,我一直卡在这里?多谢

@goodcyg
Copy link
Author

goodcyg commented Oct 21, 2024

我重新整理一下代码,mnn和opencv2都用百度网盘里的,运行demo,测试代码如上test,不报错了,但是返回resultList.plate_size=0? 也就是没有识别出来车牌?

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

No branches or pull requests

2 participants