没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论


















python调用调用c++传递数组的实例传递数组的实例
今天小编就为大家分享一篇python调用c++传递数组的实例,具有很好的参考价值,希望对大家有所帮助。一起
跟随小编过来看看吧
如下所示:如下所示:
INPUT = c_int * 4
# 实例化一个长度为2的整型数组
input = INPUT()
# 为数组赋值(input这个数组是不支持迭代的)
input[0] = 11
input[1] = 2
input[2] = 3
input[3] = 4
dll.teststring.restype = c_char_p
# bytes(aaaa, encoding="utf-8")
a = dll.teststring(input,4)
MYLIBDLL char* teststring(int* plus1, int len);
char* teststring(int* plus1,int len) {
for (int i = 0; i < len; i++) {
printf("%d ", plus1[i]);
}
Mat mat;
//加载图片
mat = imread("bgs.jpg", CV_LOAD_IMAGE_COLOR);
printf("a %d %d", mat.rows, mat.cols);
//if (!mat.empty()) {
int m, n;
n = mat.cols * 3;
m = mat.rows;
unsigned char *data = (unsigned char*)malloc(sizeof(unsigned char) * m * n);
int p = 0;
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
data[p] = mat.at<unsigned char>(i, j);
p++;
}
}
*plus1 = p;
return (char*)data;
}
以上这篇python调用c++传递数组的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持我
们。
资源评论

- 「已注销」2020-12-20辣鸡,就一小段代码

weixin_38693657
- 粉丝: 0
- 资源: 926
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


安全验证
文档复制为VIP权益,开通VIP直接复制
