简体   繁体   English

将C ++中的数组指针转换为Java(OpenCV)

[英]Converting a pointer to an array in C++ to Java (OpenCV)

I'm in the process of converting a function in OpenCV which is in C++ to Java. 我正在将C ++中的OpenCV中的功能转换为Java。 Link. 链接。

I don't know too much about C++ and struggling to convert this part: 我对C ++不太了解,因此很难转换此部分:

/// Set the ranges ( for B,G,R) )
float range[] = { 0, 256 } ; //the upper boundary is exclusive
const float* histRange = { range };

This is what I have so far: 这是我到目前为止的内容:

//Set of ranges
float ranges[] = {0,256};
final float histRange = {ranges};

Edit: 编辑:

Thanks for your help, I have managed to get it working. 感谢您的帮助,我已经设法使其正常运行。 This question was in the context of OpenCV (Sorry if I didn't make it clear). 这个问题是在OpenCV的背景下进行的(抱歉,如果我不清楚的话)。 Code: 码:

//Set of ranges
float ranges[] = {0,256};
MatOfFloat histRange = new MatOfFloat(ranges);

Unless I am mistaken with my pointers today, the second line in the c++ code duplicates pointer of range, so they both point at the same pair of values. 除非今天我对指针有误,否则C ++代码中的第二行将复制range指针,因此它们都指向同一对值。 What you want in Java should be this: 您在Java中想要的应该是这样的:

float ranges[] = {0,256};
final float histRange[] = ranges;

Thanks for your help, I have managed to get it working. 感谢您的帮助,我已经设法使其正常运行。 This question was in the context of OpenCV (Sorry if I didn't make it clear). 这个问题是在OpenCV的背景下进行的(抱歉,如果我不清楚的话)。 Code: 码:

//Set of ranges
float ranges[] = {0,256};
MatOfFloat histRange = new MatOfFloat(ranges);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM