Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

about get range of Mat #1607

Closed
4714407 opened this issue Mar 16, 2021 · 13 comments
Closed

about get range of Mat #1607

4714407 opened this issue Mar 16, 2021 · 13 comments

Comments

@4714407
Copy link

4714407 commented Mar 16, 2021

I want to use javacv to implement the following C + + code, but I don't know how to write about range. Can you give me some guidance?

std::vector<cv::Range> batchRange{ cv::Range(0, 1), cv::Range::all(), cv::Range::all() };
cv::Mat mat1 = outputMat(batchRange).reshape(0, { outputMat.size[1], outputMat.size[2] });
@saudet
Copy link
Member

saudet commented Mar 16, 2021

Which part are you having problems with?

@4714407
Copy link
Author

4714407 commented Mar 16, 2021

I don't know how to implement outputmat (batchrange),C + + overloads the () operator here, and then takes out the submatrix through the () operator. I don't know how to do that in javacv

@4714407
Copy link
Author

4714407 commented Mar 16, 2021

I found that there is a submat method on class org.opencv.core.Mat to implement this transformation, but it seems that there is no submat method on class org.bytedeco.opencv.opencv_core.Mat?

@4714407
Copy link
Author

4714407 commented Mar 16, 2021

ohh~,Let me have a try!

@4714407
Copy link
Author

4714407 commented Mar 16, 2021

How to construct a range of three dimensions is similar to the following code:
std::vectorcv::Range batchRange{ cv::Range(0, 1), cv::Range::all(), cv::Range::all() };

@saudet
Copy link
Member

saudet commented Mar 16, 2021 via email

@4714407
Copy link
Author

4714407 commented Mar 16, 2021

Range ranges=new Range();
            ranges.put(new Range(0,1));
            ranges.put(Range.all());
            ranges.put(Range.all());

Like this?

@4714407
Copy link
Author

4714407 commented Mar 16, 2021

How can I generate a range array

saudet added a commit to bytedeco/javacpp-presets that referenced this issue Mar 16, 2021
@saudet
Copy link
Member

saudet commented Mar 16, 2021

Almost, something like this: bytedeco/javacpp-presets#824 (comment)

For convenience though, I've also added a RangeVector in commit bytedeco/javacpp-presets@ce0ceca.
Please give it a try with the snapshots: http://bytedeco.org/builds/

@4714407
Copy link
Author

4714407 commented Mar 19, 2021

Range ranges=new Range(3);
            ranges.position(0).put(new Range(0,1));
            ranges.position(1).put(Range.all());
            ranges.position(2).put(Range.all());
            Mat m1=mat1.apply(ranges);

Is that right?

@saudet
Copy link
Member

saudet commented Mar 19, 2021

No, you forgot the last call to position(0).

@4714407
Copy link
Author

4714407 commented Mar 19, 2021

Thank you. It's working!

@4714407 4714407 closed this as completed Mar 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants