Blue Background Removal

69 views
Skip to first unread message

Larienas

unread,
May 12, 2020, 4:56:30 PM5/12/20
to javacv
Hi Samuel,

  I following the instruction in the https://medium.com/fnplus/blue-or-green-screen-effect-with-open-cv-chroma-keying-94d4a6ab2743 to remove the blue background from an image

  I am not familiar with how to specify the values written below in Python and so the same 

lower_blue = np.array([0, 0, 100]) ##[R value, G value, B value]
upper_blue = np.array([120, 100, 255])
mask = cv2.inRange(image_copy, lower_blue, upper_blue)
masked_image[mask != 0] = [0, 0, 0]

in JavaCV to make it work. Could you please help

With Regards,
Lariena

Samuel Audet

unread,
May 12, 2020, 8:18:40 PM5/12/20
to jav...@googlegroups.com, Larienas

Samuel Audet

unread,
May 12, 2020, 8:29:10 PM5/12/20
to jav...@googlegroups.com, Larienas
Actually, the C++ API doesn't use Scalar directly:
http://bytedeco.org/javacpp-presets/opencv/apidocs/org/bytedeco/opencv/global/opencv_core.html#inRange-org.bytedeco.opencv.opencv_core.Mat-org.bytedeco.opencv.opencv_core.Mat-org.bytedeco.opencv.opencv_core.Mat-org.bytedeco.opencv.opencv_core.Mat-

But it's possible to do something like this:
lower_blue = new Mat(new Scalar(...));
upper_blue = new Mat(new Scalar(...));
inRange(image_copy, lower_blue, upper_blue, mask)


Samuel
Reply all
Reply to author
Forward
0 new messages