Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

BindingError, message: "Cannot pass "0,132,255,0" as a Mat

Attempting to use cv.inRange(); to get the select colour pixels in the range based on the following code:

cv.cvtColor(src,hsvMat,cv.COLOR_RGBA2BGR);
cv.cvtColor(hsvMat,hsvMat,cv.COLOR_BGR2HSV);

lh = 0; //low hue value
ls = 132; //low saturation value
lv = 255; //low value value

hh = 10;
hs = 255;
hv = 160;

cv.inRange(hsvMat, [lh,ls,lv,0], [hh,hs,hv,0], mask);

The arguments stated on the opencv 4.1.0 documentation show cv.inRange(src,lowerBoundary(mat/scalar),upperBoundary(mat/scalar),dst);

Parameters

  • src first input array.
  • lowerb inclusive lower boundary array or a scalar.
  • upperb inclusive upper boundary array or a scalar.
  • dst output array of the same size as src and CV_8U type.

BindingError {name: "BindingError", message: "Cannot pass "0,132,255,0" as a Mat", stack: "BindingError: Cannot pass "0,132,255,0" as a Mat↵ …acking.js-master/examples/opencvtest2.html:451:5)"}

The above error states that the scalar array can not be passed as a Mat, but the documentation says i can pass a scalar array? i've tried removing the "0" in the array as well, the way i've written this has worked in a different part of my code not using cv.inRange();

BindingError, message: "Cannot pass "0,132,255,0" as a Mat

Attempting to use cv.inRange(); cv.inRange(); to get the select colour pixels in the range based on the following code:

cv.cvtColor(src,hsvMat,cv.COLOR_RGBA2BGR);
cv.cvtColor(hsvMat,hsvMat,cv.COLOR_BGR2HSV);

lh = 0; //low hue value
ls = 132; //low saturation value
lv = 255; //low value value

hh = 10;
hs = 255;
hv = 160;

cv.inRange(hsvMat, [lh,ls,lv,0], [hh,hs,hv,0], mask);

The arguments stated on the opencv 4.1.0 documentation show cv.inRange(src,lowerBoundary(mat/scalar),upperBoundary(mat/scalar),dst);

Parameters

  • src first input array.
  • lowerb inclusive lower boundary array or a scalar.
  • upperb inclusive upper boundary array or a scalar.
  • dst output array of the same size as src and CV_8U type.

BindingError {name: "BindingError", message: "Cannot pass "0,132,255,0" as a Mat", stack: "BindingError: Cannot pass "0,132,255,0" as a Mat↵ …acking.js-master/examples/opencvtest2.html:451:5)"}

The above error states that the scalar array can not be passed as a Mat, but the documentation says i can pass a scalar array? i've tried removing the "0" in the array as well, the way i've written this has worked in a different part of my code not using cv.inRange();