opencv学习随记,从入门到入土

morimori0401 Lv2

报错

  • IndentationError: unexpected indent
    • python代码缩进问题
  • AttributeError: module ‘matplotlib’ has no attribute ‘subplot’
    • 将import matplotlib as plt改成import matplotlib.pyplot as plt
  • ValueError: all the input array dimensions except for the concatenation axis must match exactly, but along dimension 0, the array at index 0 has size 200 and the array at index 1 has size 100
    • 在np.hstack的时候产生的错误,注意仔细辨别np.hstack跟np.vstack是否写错,图像对应轴尺寸对不上就会产生这种报错
  • ATTENTION PLEASE:在输入路径的时候,需要将复制后的\全部转为/才能正确读入!
  • 650:error: (-209:Sizes of input arguments do not match) 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
    • 一般出现这种错误是因为读入的图片格式是.png,换成.jpg就可以
  • error: (-215:Assertion failed) (mtype == CV_8U || mtype == CV_8S) && _mask.sameSize(*psrc1) in function
    • 可能错误:
      • 原图片与掩模图片大小不一样
      • 掩膜图片要转化为灰度图片:cv2.imread(‘…/xx.jpg’, 0)
      • 确保类型一样:例如都为uint8

知识点(?

图像的复制(np.copy)

  • 不能通过直接赋值来进行图像的复制。但是可以通过np.copy()函数深拷贝,改变被拷贝的图像数值之后,之前的图像并没有发生改变;而直接赋值的时候,改变拷贝生成的图像之后,原来的图像是发生了改变的,所以原来图像的数值可以变得跟新的一样
  • Title: opencv学习随记,从入门到入土
  • Author: morimori0401
  • Created at: 2024-03-05 20:34:43
  • Updated at: 2024-04-25 21:10:28
  • Link: https://morimori0401.github.io/2024/03/05/opencv从入门到入土/
  • License: This work is licensed under CC BY-NC-SA 4.0.
On this page
opencv学习随记,从入门到入土