c++ - 更改常量 Mat opencv 的值
问题描述
我想将 180 添加到 opencv 中的常量 Mat 中。由于我无法更改常量值,因此我想将其保存到临时垫中,然后将 180 添加到该值中。但是,当我尝试它时,当我打印出这些值时会得到否定的结果。
如果我将 180 添加到 temp 并打印出来,我会得到不需要的输出,即负数。
如果我将 180 添加到 dir ,我会得到正确的值和正数。
我是否为 temp 分配了错误的值?
Mat y(const Mat &image, const Mat &dir) {
image.copyTo(non_max_sup);
Mat temp ( dir.size(), CV_32F, Scalar(0));
dir.copyTo(temp);
for ( int x = 0; x < dir.rows; x++) {
for (int y = 0; y < dir.cols; y++) {
if(dir.at<int>(x,y)<0){
temp.at<int>(x,y)= (dir.at<int>(x,y));
temp.at<int>(x,y)=temp.at<int>(x,y)+180;
std::cout<<temp.at<float>(x,y)<<std::endl; //wrong numbers
//std::cout<<dir.at<float>(x,y)+180<<std::endl; correct numbers
}
}
}
}
解决方案
推荐阅读
- html - 如何将 CSS 样式应用于网格中的整行?
- html - 尽管我使用顶部,但位置粘性不适用于 flex child
- sql-server - 自定义列包含多个值
- java - Java:线程能够调用位于其他线程同步块中的方法
- azure - 使用 Terraform random_id 创建多个资源未按预期工作
- induction - 通过归纳证明每个高度为 h 的非空树包含少于 2^n+1 个节点
- javascript - 在下拉列表中使用 Jquery 解析 JSON
- reactjs - Prevent React from re-render partial SSR content on hydrate
- c# - 统一从网格中删除重复的顶点
- javascript - Inserting variables into regular expressions