Ask Your Question
0

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

asked 2019-06-18 11:37:07 -0600

B.C gravatar image

updated 2020-05-03 21:02:28 -0600

supra56 gravatar image

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();

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
1

answered 2020-05-03 17:36:07 -0600

kpachinger gravatar image

the scalar is a mat set to a scalar. so it is a mat, not a scalar. a mat with a scalar. https://docs.opencv.org/3.4.8/db/d64/tutorial_js_colorspaces.html

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-06-18 11:37:07 -0600

Seen: 1,570 times

Last updated: May 03 '20