python内存地址与c++内存地址_python和C++共享内存传输图像的示例

原理python没有办法直接和c++共享内存交互,需要间接调用c++打包好的库来实现流程C++共享内存打包成库python调用C++库往共享内存存图像数据C++测试代码从共享内存读取图像数据实现1.c++打包库创建文件example.cpp#include #include #include #include #include "opencv2/core.hpp"#include "opencv2...
摘要由CSDN通过智能技术生成

原理

python没有办法直接和c++共享内存交互,需要间接调用c++打包好的库来实现

流程

C++共享内存打包成库

python调用C++库往共享内存存图像数据

C++测试代码从共享内存读取图像数据

实现

1.c++打包库

创建文件

example.cpp

#include

#include

#include

#include

#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<

return -1;

}

cout << " shem id is  "<

image_head *buffer_head;

buffer_head = (image_head*) shmat(shm_id, NULL, 0);

if((long)buffer_head == -1)

{

cout<

return -1;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值