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

OpenCV: Added support for nD to AbstractMat #647

Merged
merged 3 commits into from
Nov 30, 2018
Merged

OpenCV: Added support for nD to AbstractMat #647

merged 3 commits into from
Nov 30, 2018

Conversation

HGuillemet
Copy link
Collaborator

AbstractArray.createIndexer doesn't support Mat with more than 2 dimensions.
Added AbstractMat.createIndexer that does.
The channels are considered as an additional dimension in the indexer, but this dimension
can be omitted in a long[] array of indices for mats with only 1 channel.
One limitation : Mat theoretically accepts steps that are not multiple of the element size, but indexer does not. An exception is thrown by createIndexer if this occurs.
In JavaCPP, Indexer.rows, cols, width, heads, channels should also be deprecated or modified to return -1 if the number of dimensions of the indexer is not 3.

@HGuillemet HGuillemet changed the title Added support for nD to AbstractMat OpenCV: Added support for nD to AbstractMat Nov 28, 2018
int size = arraySize();
int dims = dims();
int depth = depth();
int elemSize = CV_ELEM_SIZE1(depth);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could just call elemSize1() here instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I didn't spot this method. It'll trigger a JNI call but I guess we don't care here.
CV_ELEM_SIZE1 definition can be deleted then.

@saudet
Copy link
Member

saudet commented Nov 29, 2018

BTW, IplImage used to support steps that are not a multiple of the element size, but I don't think Mat supports that anymore, because step1() always returns step/elemSize1() without throwing an exception or failing in some other way.

@HGuillemet
Copy link
Collaborator Author

I think it may theoretically still happen. But in practice that would be a very weird data layout. I'd keep the check and the exception thrown.

@saudet saudet merged commit 5bf14d4 into bytedeco:master Nov 30, 2018
@HGuillemet HGuillemet deleted the hg_abstractarray_nD branch December 1, 2018 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants