OPenCV的重要结构体Mat

一 Mat

Mat是什么?

Mat有什么好处?

cpp 复制代码
class CV_EXPORTS Mat{
public:
...
int dims;//维数
int rows,cols;//行列数
uchar *data;//存储数据的指针
int *refcount;//引用计数
...

};

二 Mat属性

三 Mat拷贝

1 Mat浅拷贝

cpp 复制代码
Mat A
A=imread(file,IMREAD_COLOR)
Mat B(A)

2 Mat深拷贝

cpp 复制代码
cv::Mat::clone()
cv::Mat::copyTo()
copy()
cpp 复制代码
import cv2
import numpy as np

img=cv2.imread('./2037548.jpg')
#浅拷贝
img2=img
#深拷贝
img3=img.copy()

img[10:100,10:100]=[0,0,255]


cv2.imshow('img',img)
cv2.imshow('img2',img2)
cv2.imshow('img3',img3)

cv2.waitKey(0)
相关推荐
智算菩萨12 分钟前
【论文精读】Automated machine learning for positive-unlabelled learning
论文阅读·人工智能·机器学习·论文笔记·贝叶斯优化·自动机器学习·无标签学习
小程故事多_8020 分钟前
破解Agent“半途摆烂”困局,OpenDev凭Harness架构,撕开Code Agents的工程化真相
人工智能·架构·aigc·harness
吴佳浩23 分钟前
Vibe Coding 时代:Vue 消失了还是 React 太强?
人工智能
Elastic 中国社区官方博客25 分钟前
Elasticsearch:如何在 Elastic AI Builder 里使用 DSL 来查询 Elasticsearch
大数据·人工智能·elasticsearch·搜索引擎·ai·全文检索
musicml32 分钟前
从 Vibe Coding 到 SDD(规范驱动开发):AI 原生时代的软件工程化实践
人工智能·驱动开发·软件工程
Deepoch37 分钟前
Deepoc具身模型:重塑无人机无遥控器作业
人工智能·科技·无人机·具身模型·deepoc
i建模39 分钟前
Claude Code在编程之外的能力
人工智能
言之。41 分钟前
用Claude Code搞定产品上线
人工智能
HIT_Weston44 分钟前
31、【Agent】【OpenCode】模型配置(OpenRouter&OpenCode)
人工智能·agent·opencode
Coder个人博客1 小时前
06_apollo_third_party子模块整体软件架构深入分析文档
linux·人工智能·架构