兄弟们看看完整报错内容:

Traceback (most recent call last):File "<string>", line 12, in <module>
cv2.error: OpenCV(4.6.0) :-1: error: (-5:Bad argument) in function 'rectangle'
> Overload resolution failed:
>  - Layout of the output array img is incompatible with cv::Mat
>  - Expected Ptr<cv::UMat> for argument 'img'
>  - Layout of the output array img is incompatible with cv::Mat
>  - Expected Ptr<cv::UMat> for argument 'img'

我这边想检查一下数据有效性,于是中间取数据绘图看下是不是 xcycwhx_cy_cwhxc​yc​wh

im = img.permute(1, 2, 0).numpy()
im = (im * [0.229, 0.224,0.225] + [0.485, 0.456, 0.406]) * 255
im = im.astype(int).astype("uint8")h, w, _ = im.shape
bbox = target[2]['boxes'][0].cpu().numpy() * [w, h, w, h]
xc, yc, bw, bh = bbox.astype(int)x1, y1, x2, y2 = int(xc-bw//2), int(yc-bh//2), int(xc+bw//2), int(yc+bh//2)# im = np.ascontiguousarray(im)
xx = cv2.rectangle(im, (x1, y1), (x2, y2), 255, 2, 8)   # 这里报了错
cv2.imwrite("xxx.png", im)

结果在 cv2.rectangle 那里报了错,Layout不兼容,意思是内存布局不兼容,那就调用np.ascontiguousarray,让它变成C连续数组就好

im = np.ascontiguousarray(im)
xx = cv2.rectangle(im, (x1, y1), (x2, y2), 255, 2, 8)   # 这里报了错

numpy array 报错 Layout of the output array img is incompatible with cv::Mat相关推荐

  1. Layout of the output array img is incompatible with cv::Mat (step[ndims-1] !

    Layout of the output array img is incompatible with cv::Mat (step[ndims-1] https://blog.csdn.net/tqc ...

  2. TypeError: Layout of the output array image is incompatible with cv::Mat

    TypeError: Layout of the output array image is incompatible with cv::Mat (step[ndims-1] != elemsize ...

  3. jupyter notebook导入numpy 失败 报错:Original error was: DLL load failed while importing _multiarray_umath:

    jupyter notebook导入numpy 失败 报错:Original error was: DLL load failed while importing _multiarray_umath: ...

  4. Idea编译项目报错Error:Kotlin: Module was compiled with an incompatible version of Kotlin.

    1.项目报错 error:Kotlin:module was compiled with an incompatible version of kotlin the binary version of ...

  5. win10 python3.6安装numpy路径报错_Python3.6的组件numpy的安装 猪悟能

    安装numpy,scipy,scikit-learn,matplotlib 下载地址:https://www.lfd.uci.edu/~gohlke/pythonlibs/ 我的版本是win10+py ...

  6. Python音频转成numpy数组:numpy.frombuffer报错ValueError: buffer size must be a multiple of element size

    使用背景:导入音频信号,下面代码段最后一句报错 import wave import numpy as npf = wave.open(wav_path) params = f.getparams() ...

  7. tp5 报错variable type error: array解决方法

    当你在tp5框架中写方法时返回一个数组时,tp5会报错:variable type error: array 这是因为tp5不支持返回数组. 下面是小编亲测的2种解决方法,大家就看自己实际需求,来决定 ...

  8. 解决Collection Object ([:protected]=Array())报错

    今天用laravel的DB取多个表的数据做统计运算,里面使用了多次DB查询并嵌套三个for循环.多个->leftJoin()一次使用.->select()多键,结果只能取到数据中的第一条数 ...

  9. Nodejs: Buffer报错argument must be an Array of Buffer or Uint8Array instances

    最近项目有个需求需要在和第三方API接口进行交互时,在JSON字符串最前面加上16个字节的签名字节,为了简化问题忽略JSON以及16个字节的具体取值. 错误代码: buff = Buffer.from ...

最新文章

  1. SQL调优:带函数的谓词导致CBO Cardinality计算误差
  2. Mono新突破:CentOS 7.2下安装Mono 5.0
  3. 使对易失性字段的操作原子化
  4. python异常处理_Python 工匠: 异常处理的三个好习惯
  5. mysql连接被拒绝 密码也对_解决Mysql数据库拒绝远程连接和忘记密码的问题
  6. 局域网的分层结构的优点及分层原理
  7. 子元素margin-top为何会影响父元素?
  8. [Swift]LeetCode874. 模拟行走机器人 | Walking Robot Simulation
  9. FFmpeg编解码常用函数ffmpeg av_parser_parse2()函数
  10. 隔行换色+删除+批量删除+排序+模糊查询+修改+添加
  11. win7电脑无线网卡服务器,win7如何安装无线网卡驱动|win7安装无线网卡驱动的方法...
  12. 电力电子pwm控制技术
  13. 【数据库】GaussDB客户端工具介绍
  14. Pycharm下同一目录的py文件不能相互调用的原因分析
  15. python自制简易二维码代码_用python把自己的二维码制作成动态码,一行代码即可搞定!敲简单!...
  16. 第一个C编译器的诞生图
  17. c语言绝对值题目,初中数学绝对值练习题答案及解析
  18. 超频心得8:最简单超频调试之映泰TA770A2+SE
  19. USR-TCP232-T2济南有人以太网模块
  20. Access 2003中文版即学即会视频教程(下)

热门文章

  1. scrapy学习笔记(三)-关于动态加载网页的爬取(序)
  2. VUE指令大全(详解)
  3. IOS学习---OC基础学习(Foundation)
  4. C语言求1到20的阶乘之和
  5. 计算机组成原理实验logisim(三)之偶校验编码与检错
  6. 总线干扰神器——VH6501
  7. Spring @Configuration和@Component的区别(enhancer的原因)
  8. 从一个资深面试官角度看Java面试:面试了20家大厂与面试了上百人之后,发现这样介绍项目经验,显得项目很牛逼!
  9. 欧几里德关系的S5---刘易斯逻辑之十一
  10. 2020年,多源域适应(域迁移) MDA最新方法总结综述