HSV White Color Range In JS - OpenCV Q&A Forum
Có thể bạn quan tâm
First time here? Check out the FAQ!
Hi there! Please sign in help
faq tags users badges This forum is disabled, please visit https://forum.opencv.org | ALL UNANSWERED | Ask Your Question |
asked 2019-12-05 01:59:35 -0600
I would like to track white color using webcam and Opencv.js. Here is the question/answer with python. I want to do exactly the same with javascript and tried this
const hsv = new cv.Mat(); cv.cvtColor(initialImage, hsv, cv.COLOR_BGR2HSV) const lower_white = [0, 0, 0]; const upper_white = [0, 0, 255]; const low = new cv.Mat(hsv.rows, hsv.cols, hsv.type(), lower_white); const high = new cv.Mat(hsv.rows, hsv.cols, hsv.type(), upper_white); const dst = new cv.Mat(); cv.inRange(hsv, low, high, dst);But it doesn't work. I'm getting the following error
Uncaught TypeError: Incorrect number of tuple elements for Scalar: expected=4, actual=3Error is occurring on this line
const low = new cv.Mat(hsv.rows, hsv.cols, hsv.type(), lower_white);The problem is that it wants lower_white array to have 4 elements instead of 3.
What is the 4th element in HSV format?
I also tried to put the 4th element from 0 to 255
const lower_white = [0, 0, 0, 0]; const upper_white = [0, 0, 255, 255];In this case, there is no error but it doesn't seem right. It doesn't work. Any suggestions or explanations of what should be lower_white and upper_white values?
edit retag flag offensive close merge delete add a comment3 answers
Sort by » oldest newest most voted 2answered 2019-12-05 04:02:53 -0600
Nobody seems to know about the 4th element, but if I had to guess, JS stores even HSV images in four channels (unlike other platforms), and the fourth is the alpha channel.
edit flag offensive delete link more add a comment 1answered 2019-12-05 02:54:39 -0600
I would like to track white color
maybe you think about that again. -- white is not really a "color", it can be any hue value in hsv.
iif you're just begin coding with this, start with an easier color, like yellow or pink
edit flag offensive delete link more add a comment 0answered 2020-12-19 17:45:05 -0600
The way you created your ranges is incorrect, and initializing a Mat from a 3 column array instead of a 4 column array gives the error
"Incorrect number of tuple elements for Scalar: expected=4, actual=3",
The way to create the range works through using the factory method matFromArray(). the ranges must be created by
const low = cv.matFromArray(hsv.rows, hsv.cols, hsv.type(), lower_white);instead of
const low = new cv.Mat(hsv.rows, hsv.cols, hsv.type(), lower_white);https://docs.opencv.org/3.4/de/d06/tu...
edit flag offensive delete link more add a commentLinks
Official site
GitHub
Wiki
Documentation
Question Tools
Follow 1 followersubscribe to rss feed
Stats
Asked: 2019-12-05 01:59:35 -0600
Seen: 21,832 times
Last updated: Dec 19 '20
Related questions
How to use InRange at Different Color Space and Range.
Need to know the HSV value.
Hough Transform after removal of color [closed]
Create a HSV Range Palette
What's the best way to segment different coloured blobs?
Counting the number of colours in an image
How to get histogram of a rectangular area (ROI) of an image?
How to find the two most dominant colors in an image?
HSV-Range iOS vs. Mac OS [closed]
Core inRange
Copyright OpenCV foundation, 2012-2018. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license. about | faq | help | privacy policy | terms of service Powered by Askbot version 0.10.2Từ khóa » Hsv Color Space White
-
Tracking White Color Using Python Opencv - Stack Overflow
-
HSL And HSV - Wikipedia
-
Image Segmentation Using Color Spaces In OpenCV + Python
-
Find The Center Of A White Line In An Image Using OpenCV · GitHub
-
Tracking White Color Using Python Opencv - Win Mundo
-
HSV Color Wheel Figure 6 Illustrates How Hue, Saturation, And Value ...
-
The Three Dimensional HSV Color Space. Hue (H) Captures The ...
-
OpenCV Color Spaces ( tColor ) - PyImageSearch
-
Tracking White Color Using Python Opencv - TouSu Developer Zone ...
-
RGB To HSV Color Conversion
-
Detecting Colors (Hsv Color Space) - Opencv With Python - Pysource
-
Color Spaces In OpenCV | Python - GeeksforGeeks
-
White Color Code (Hex RGB CMYK), Paint, Palette, Image