OpenCV使用msvc2019编译时world库报错: 错误 C2666 “operator !=”: 14 个重载有相似的转换;

问题

csl::Tensor<T> weightsTensor;
T weight;
if (weight != 1.0) {		//此处报错

}

if (nms_iou_threshold > 0) {		//此处报错
   	auto output_mat = output_wrapper->getMutableHostMat();
   	CV_Assert(output_mat.type() == CV_32F);
   	for (int i = 0; i < input.get_axis_size(0); i++) {
       	auto sample_size = rows * cols * boxes_per_cell * cell_box_size;
       	do_nms_sort(reinterpret_cast<float*>(output_mat.data) + i * sample_size, rows * cols * boxes_per_cell, class_prob_cutoff, nms_iou_threshold);
    }
}

解决方式:

确保!=运算符与相同类型的操作数一起使用,有助于编译器解决歧义。如果T不是double,请使用适当的类型转换替换static_cast<T>(1.0)。

if (weight != static_cast<T>(1.0)) {

}
if (nms_iou_threshold > static_cast<T>(0)) {		//修改此处
   	auto output_mat = output_wrapper->getMutableHostMat();
   	CV_Assert(output_mat.type() == CV_32F);
   	for (int i = 0; i < input.get_axis_size(0); i++) {
       	auto sample_size = rows * cols * boxes_per_cell * cell_box_size;
       	do_nms_sort(reinterpret_cast<float*>(output_mat.data) + i * sample_size, rows * cols * boxes_per_cell, class_prob_cutoff, nms_iou_threshold);
    }
  • 10
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值