简单记录一下ubantu18.04初步使用opencv所遇到的问题

1.ubantu18.04安装opencv

参考:Ubuntu 18.04 安装opencv4.2.0_ubuntu18.04安装opencv4.2.0-CSDN博客

2. _src.type() == CV_8UC1 in function 'cv::equalizeHist'

原因:这个错误通常出现在使用cv2.equalizeHist()函数时,输入图像类型不正确。cv2.equalizeHist()函数只能处理8位单通道图像(即CV_8UC1类型)。

解决方法:将输入图像转换为8位单通道图像,可以使用cv2.cvtColor()函数将彩色图像转换为灰度图像,然后使用cv2.equalizeHist()函数进行直方图均衡化。


    Mat infrared_img = imread("infrared.jpg");
    Mat grayInfrared;
    cvtColor(infrared_img, grayInfrared, COLOR_BGR2GRAY);
    Mat infrared_img_1,rgb_img_1;
    equalizeHist(grayInfrared,infrared_img_1);  //直方图均衡

参考:_src.type() == CV_8UC1 in function 'cv::equalizeHist' - CSDN文库

3.Opencv 解决问题 !_src.empty() in function 'cv::cvtColor' 

!_img.empty() in function 'imwrite'和size.width>0 && size.height>0 in function 'imshow'

得详细检查一下路径有没有问题,文件名有没有错,

参考:https://blog.csdn.net/hy_z_/article/details/103681088

error: (-215:Assertion failed) !_img.empty() in function ‘cv::imwrite‘已解决_error: (-215:assertion failed) !image.empty() in f-CSDN博客

解决OpenCV error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow'-CSDN博客 

4. The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array' in function 'arithm_op' 

出现这种情况的原因:

第一种:尺寸大小不一样 

解决方法:裁剪图片

参考:【已解决】OpenCV Error: Sizes of input arguments do not match-CSDN博客

opencv图像混合报错问题_the operation is neither 'array op array' (where a-CSDN博客 

第二种:出现原因,可能是读取照片时,选择了不同的读取图像方式 

    string left_file = "./infrared.jpg";
    Mat infrared_img = imread(left_file,0);
    Mat rgb_img = imread("rgb.jpg",1);
    Mat blended_img;
    addWeighted(rgb_img, 0.6, infrared_img, 0.4, 0.0, blended_img);

只要把读取方式改为同一种方式就可以了,熟悉imread函数参考:opencv学习——imread()读取图像-CSDN博客

相关推荐

  1. 记录一下初次使用linux服务器问题解决

    2024-07-20 11:52:04       28 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-20 11:52:04       52 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-20 11:52:04       54 阅读
  3. 在Django里面运行非项目文件

    2024-07-20 11:52:04       45 阅读
  4. Python语言-面向对象

    2024-07-20 11:52:04       55 阅读

热门阅读

  1. YOLO 各版本对比

    2024-07-20 11:52:04       18 阅读
  2. 基于gunicorn+flask+docker模型 高并发部署

    2024-07-20 11:52:04       17 阅读
  3. 跟着GPT学设计模式之模板模式

    2024-07-20 11:52:04       18 阅读
  4. 动态美学:WebKit中CSS转换与动画的魔力

    2024-07-20 11:52:04       17 阅读
  5. 华为AI认证必刷题100道(上)

    2024-07-20 11:52:04       19 阅读
  6. 概率论中的卷积公式

    2024-07-20 11:52:04       13 阅读
  7. 数据结构:栈

    2024-07-20 11:52:04       15 阅读
  8. 数据质量8个衡量标准

    2024-07-20 11:52:04       14 阅读
  9. abc362(abcde)

    2024-07-20 11:52:04       15 阅读
  10. [jieba_fast][python]jieba_fast所有whl文件下载地址汇总

    2024-07-20 11:52:04       18 阅读