How to draw square with HSV color in OpenFrameworks / OpenCV

半城伤御伤魂 提交于 2019-12-11 18:45:22

问题


I have a OpenFrameworks project that is using OpenCv. I have histogram of the hue and saturation values of my image. To show the histogram I am drawing a grid of gray square's based on the values from the histogram. To make it easier to understand I want to draw a box under each grid column the hue that it represents. But given the HSV values how do I specify the color to draw the box?

Normally you would use ofSetColor or ofSetHexColor but those are RGB based, and I dont know the RGB values.


回答1:


Perhaps this only came in with a later version but you can now do the following using ofColor

ofColor c = ofColor::fromHsb( 0, 255, 255 ); // bright red
c.setHue( 128 ); // now bright cyan

ofColor c( 0, 0, 255 ); // vibrant blue
c.setSaturation( 128 ); // pale blue

ofColor c = ofColor_::setHsb(float hue, float saturation, float brightness)

You can then use ofSetColor(c);

source



来源:https://stackoverflow.com/questions/11528325/how-to-draw-square-with-hsv-color-in-openframeworks-opencv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!