没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
原理 python没有办法直接和c++共享内存交互,需要间接调用c++打包好的库来实现 流程 C++共享内存打包成库 python调用C++库往共享内存存图像数据 C++测试代码从共享内存读取图像数据 实现 1.c++打包库 创建文件 example.cpp #include <iostream> #include <cassert> #include <stdlib> #include <sys> #include opencv2/core.hpp #include opencv2/imgproc.hpp #include opencv2/highg
资源推荐
资源详情
资源评论
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![py](https://img-home.csdnimg.cn/images/20210720083646.png)
![mp4](https://img-home.csdnimg.cn/images/20210720083504.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/release/download_crawler_static/14839819/bg1.jpg)
python和和C++共享内存传输图像的示例共享内存传输图像的示例
原理原理
python没有办法直接和c++共享内存交互,需要间接调用c++打包好的库来实现
流程流程
C++共享内存打包成库
python调用C++库往共享内存存图像数据
C++测试代码从共享内存读取图像数据
实现实现
1.c++打包库打包库
创建文件
example.cpp
#include <iostream>
#include <cassert>
#include <stdlib.h>
#include <sys/shm.h>
#include "opencv2/core.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/videoio.hpp"
#define key 650
#define image_size_max 1920*1080*3
using namespace std;
using namespace cv;
typedef struct{
int rows;
int cols;
uchar dataPointer[image_size_max];
}image_head;
int dump(int cam_num,int row_image, int col_image, void* block_data_image)
{
int shm_id = shmget(key+cam_num,sizeof(image_head),IPC_CREAT);
if(shm_id == -1)
{
cout<<"shmget error"<<endl;
return -1;
}
cout << " shem id is "<<shm_id<<endl;
image_head *buffer_head;
buffer_head = (image_head*) shmat(shm_id, NULL, 0);
if((long)buffer_head == -1)
{
cout<<"Share memary can't get pointer"<<endl;
return -1;
}
assert(row_image*col_image*3<=image_size_max);
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
- hunkshang2023-08-10资源很不错,内容和描述一致,值得借鉴,赶紧学起来!
- hbirdflyfly2023-04-17总算找到了想要的资源,搞定遇到的大问题,赞赞赞!
- dbjsjw2023-08-24资源太好了,解决了我当下遇到的难题,抱紧大佬的大腿~
- BABALAAA2023-11-10发现一个超赞的资源,赶紧学习起来,大家一起进步,支持!
- blueforest2024-07-01资源不错,对我启发很大,获得了新的灵感,受益匪浅。
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
weixin_38537315
- 粉丝: 6
- 资源: 876
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)