首页 > 解决方案 > Access 4d matrix JS opencv

问题描述

I'm using electron with openCV with opencv4nodejs.

I have a 4d Matrix object and I want to access the 4 dimension elements of this matrix. The at function is not working: mat.at(0,0,0,1) is equal to mat.at(0,0,0,2) and they are both equal to mat.at(0,0,0,0) which I know is the true value.

This makes sense since the openCV c++ matrix documentation shows that at function can get at most 3 parameters int i0, int i1, int i2.

How do I access the 4d elements in a matrix?

Thanks in advance

标签: javascriptopencvmatrix

解决方案


In order to access any element in dimension higher than 3d you will need to use the at function and pass it an array. Here is the formal c++ documentation of the function.

For example:

var element1234 = myMatrix.at([1, 2, 3, 4]);

Will work.


推荐阅读